콘텐츠로 건너뛰기

[LaTeX] \cal 명령어 \mathcal로 대체하기

작성해둔 논문의 template을 변경해야 할 일이 있었는데 (IEEE -> ACM) 대충 양식만 바꾸고 컴파일 하니까 에러가 발생했다.

main.tex:492: Undefined control sequence.
l.492 For an input circuit ${\cal
                                  C}$, let ${\cal F}_{all}$ and ${\cal F}_{s...
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

원래는 잘 컴파일되던 코드였는데? 문제가 뭔가 하니, \cal 명령어는 LaTeX 2.09까지 사용되었다가 LaTeX2e (1999)의 등장과 함께 더이상 사용되지 않는다고 한다. 대신 \mathcal 명령어를 사용해야 하며, syntax가 조금 다르다.

${\cal C}$ % cal
$\mathcal{C}$ % mathcal

물론 .tex 파일 내 모든 명령어를 \mathcal로 대체하면 해결할 수 있는 문제이지만 그러기에는 고칠 부분이 너무 많고 귀찮았다. vim에서 한 번에 처리가 가능할 것 같긴 한데 방법을 모르겠고. 그런데 기존에는 컴파일이 되던 코드였으니 원래 사용하던 template file (IEEEtran.cls)를 살펴봤고 아래와 같은 명령어를 발견할 수 있었다.

% provide the user with some old font commands
% got this from article.cls
% (중간 생략)
\DeclareRobustCommand*\cal{\@fontswitch\relax\mathcal}

와! 원래 사용할 수 없는 명령어를 저렇게 우회하고 있어서 컴파일이 가능했나 보다. 친절하기도 해라!

비슷하게 .tex 파일 앞부분에 아래 명령어를 넣어서 해결했다.

\makeatletter 
\DeclareRobustCommand*\cal{\@fontswitch\relax\mathcal} % \cal -> \mathcal 
\makeatother
Share this post!
태그:

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.