매크로를 둘러싸는 인수로 라인을 사용하는 코빙턴

매크로를 둘러싸는 인수로 라인을 사용하는 코빙턴

글로스가 좀 필요해서 써봐야겠어요covington.sty(당신이 내 문제를 해결할 수 있다면다른 패키지상관없습니다. 어쨌든 솔루션을 위해 모든 것을 리팩터링해야 합니다.) \gll두 줄이 필요합니다: 텍스트가 광택 처리( Hallo Welt예제에서)되고 텍스트가 광택( Hello World예제에서)됩니다. 이제 \autogloss두 번째 줄을 자동으로 작성하는 명령이 필요합니다 . 즉, \hello{} \world{}의 두 줄에 공통되는 명령이 \gll의 첫 번째 인수가 됩니다 \autogloss. 그러나 이것은 Something's wrong--perhaps a missing \item..

나는 인수가 확장되지 않았기 때문에 그럴 수도 있다고 추측했지만, 그래도 여전히 그것을 얼버무렸어야 했습니다(단지 적절하지 않음). 그리고 아무 것도 \expandafter작동하지 않는 것 같습니다.

%작업 예제의 줄 끝에 a를 넣으면 동일한 메시지가 표시되므로 다음에서 해결책을 생각했습니다.이 문제작동할 수도 있지만 그렇지 않은 것 같습니다(하지만 제가 뭔가 잘못했을 수도 있습니다).

\documentclass{article}
\usepackage{etoolbox}
\usepackage{covington}

\newcounter{@language}
\setcounter{@language}{0}
\def\english{\setcounter{@language}{0}}
\def\german{\setcounter{@language}{1}}

\newcommand\hello{\ifnumcomp{\value{@language}}{=}{0}{Hello}{Hallo}}
\newcommand\world{\ifnumcomp{\value{@language}}{=}{0}{World}{Welt}}

\newcommand\autogloss[2]{%
    \gll \german{}#1
    \english{}#1
    \glt `#2'
    \glend
}

\begin{document}
\begin{examples}
\item this one works:
    \gll \german{}\hello{} \world{}
    \english{}\hello{} \world{}
    \glt `Hello World.'
    \glend
\item this one doesn't: % comment next line to compile.
    \autogloss{\hello{} \world{}}{`Hello World.'}
\end{examples}
\end{document}

답변1

와 함께 gb4e?

\documentclass{article}
\usepackage{etoolbox}
\usepackage{gb4e}

\newcounter{@language}
\setcounter{@language}{0}
\def\english{\setcounter{@language}{0}}
\def\german{\setcounter{@language}{1}}

\newcommand\hello{\ifnumcomp{\value{@language}}{=}{0}{Hello}{Hallo}}
\newcommand\world{\ifnumcomp{\value{@language}}{=}{0}{World}{Welt}}

\newcommand\autogloss[2]{%
    \gll \german{}#1\\
    \english{}#1\\
    \glt `#2'
}

\let\eachwordone=\it

\begin{document}
\begin{exe}
\ex this one works:
    \gll \german{}\hello{} \world{}\\
    \english{}\hello{} \world{}\\
    \glt `Hello World.'
\ex this one does, as well:
    \autogloss{\hello{} \world{}}{Hello World.}
\end{exe}
\end{document} 

산출

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

관련 정보