암호

암호

소스 코드에 새 명령을 정의했습니다.

\newcommand{\IN}{interface}

출력되는 것상호 작용, 하지만 인쇄하고 싶은 경우도 있습니다.상호 작용(대문자 I 사용) 또는인터페이스대신, 2개의 새로운 명령을 더 정의하지 않고 어떻게 이 작업을 수행할 수 있습니까?

답변1

이 같은?

암호

\documentclass{article}
\newcommand*{\IN}[1][0]{%
    \ifnum#1=0 interface\fi
    \ifnum#1=1 Interface\fi
    \ifnum#1=2 interfaces\fi
}
\begin{document}
    \IN, \IN[1], \IN[2]
\end{document}

산출

여기에 이미지 설명을 입력하세요

그러나 Egreg가 말했듯이 '인터페이스'를 입력하는 것은 쉽습니다. :)

답변2

대문자에 별표 표시된 명령을 정의하고 s복수형에 간단히 추가할 수도 있습니다.

\documentclass{article}
\makeatletter
\DeclareRobustCommand*{\IN}{%
    \@ifstar{Interface}{interface}}
\makeatother
\begin{document}
Singular: \IN, \IN*
\par Ways to write plurals: \IN s, \IN{s}, \IN{}s, \IN*s
\end{document}

\DeclareRobustCommand\protect명령이 취약하지 않게 만드는 데 필요하므로 제목 등에는 필요하지 않습니다 .

관련 정보