2017-10-30 7 views
1

저는 이력서에 여러 세부 사항을 표시 할 수있는 매크로를 만들려고합니다. 아이디어는 특정 주제를 말하고 내 이력서의 관련 항목에 대해서만 세부 사항을 얻을 수있게하는 것입니다.라텍스 - 매크로에서 주석 환경이 작동하지 않는 이유는 무엇입니까?

\ newcomment 함수를 사용하려면 "회상록"클래스를 사용하고 있습니다. 나는 moderncv를 시도했다, 그러나 나는 진짜로 납득되지 않았다.

\newcomment{Item} 
\newcomment{Descr} 
\newcomment{Details} 

\newcommand{\cvitem}[3]{ 
    \begin{Item}\textbf{#1}\end{Item} 
    \begin{Descr}\hspace{1cm} {#2}\end{Descr} 
    \begin{Details}\\ {\small #3}\end{Details}\vspace{2em} 
    } 

\commentsoff{Item} 
\commentsoff{Descr} 
\commentsoff{Details} 

그것은 그대로 작동하지만, 나는 그런

\commentson{Details} 

을 명시하면 나는 오류 얻을 : 여기

내가 지금까지 가지고 올 한 것입니다

! File ended while scanning use of \next. 
<inserted text> 
\par 
<*> cv_master.tex 
I suspect you have forgotten a `}', causing me 
to read past where you wanted me to stop. 
I'll try to recover; but if the error is serious, 
you'd better type `E' or `X' now and fix your file. 

그 이유는 무엇입니까?

답변

1

전통적으로 조건문을 사용하는 것이 좋습니다.

enter image description here

\documentclass{article} 

\newif\ifItem 
\newif\ifDescr 
\newif\ifDetails 

\newcommand{\cvitem}[3]{% 
    \ifItem 
    \textbf{#1} 
    \fi 
    \ifDescr 
    \hspace{1cm} #2 
    \fi 
    \ifDetails 
    \\ {\small #3} 
    \fi 
    \vspace{2em} 
} 

\Itemtrue 
\Descrtrue 
\Detailsfalse 

\begin{document} 

\cvitem{First}{Second}{Third} 

\end{document} 

이유 : 즉, 당신이 ON/OFF를 전환 할 수 \if -like 문을 사용한다? 모든 환경/클래스에서 더 쉽고 효과적입니다.

+0

Waww super nice! 감사합니다 @Werner, 나는 어떤 시점에서 if 진술로 뛰어 들기를 생각하고있었습니다, 나는 확실히 할 것입니다! –