새 명령에서 순서를 변경하는 방법

새 명령에서 순서를 변경하는 방법

LaTeX에 대한 아마추어이기 때문에 죄송합니다. 전체 이야기를 말하지 않고 질문하는 방법을 모르겠습니다.

큰 문서에서 나는 현대 저자를 인용하는 데 사용하는 것(BibTeX 등을 사용하는 경우)보다 다른 규칙에 따라 (고전 라틴어) 저자를 인용하기 위한 다소 간단한 명령을 만들었습니다. 이것은 내가 사용하는 명령입니다:

\newcommand{\citeCL}[3]{#1, \emph{#2}, \textbf{#3}}
%\citeCL{author}{text}{chapter}

처음 두 인수로 저자 이름과 텍스트 제목 목록의 다른 명령을 사용합니다(모든 이름을 여러 번 사용하고 매번 전체 이름을 쓰면 일관성이 없을 수 있으므로). 예:

\newcommand{\Per}{N. Per.}
\newcommand{\PerRud}{Rud. gram.}

문서 내에서 다음과 같이 cite 명령을 호출할 수 있습니다.

\citeCL{\Per}{\PerRud}{1117}

각주와 이 인용 환경 모두에서 사용하는 인용 명령은 다음과 같습니다.

\newcommand{\QuoteCL}[4]{
\vspace{5pt}
\begin{quote}\itemsep1pt\parskip0pt\parsep0pt\begin{spacing}{1}
#4 \par\hspace*{\fill}\footnotesize{\citeCL{#1}{#2}{#3}}
\end{spacing}
\end{quote}
\vspace{-20pt}
}

문서에서 나는 와 동일한 세 가지 인수 \citeCL와 추가로 인용할 텍스트를 사용하여 명령을 호출합니다.

\QuoteCL{\Per}{\PerRud}{§ 1119}{Quis maxime proponendus est quem studeant adolescentes imitari? Marcus Cicero.}

이 모든 것이 잘 작동하며 논문 전반에 걸쳐 이를 사용했습니다. 이제 나는 각주에 축약된 형식을 사용하고 인용에 새로운 긴 형식을 사용하여 저자 이름과 제목을 각주와 인용에 작성하는 방식을 다르게 하고 싶습니다. 내 직관적이고 순진한 접근 방식은 다음과 같습니다.

\newcommand{\citeCL}[3]{#1, \emph{#2}, \textbf{#3}}
% Original command now used for footnotes

\newcommand{\citeCLLong}[3]{#1Long, \emph{#2Long}, \textbf{#3}}
% New command to be called by the \quoteCL command.

\newcommand{\Per}{N. Per.}
\newcommand{\PerLong}{Niccolò Perotti}
\newcommand{\PerRud}{Rud. gram.}
\newcommand{\PerRudLong}{Rudimenta grammatices}
% Duplicating the list of names and titles, adding a long version to be called by the \citeCLLong:

\newcommand{\QuoteCL}[4]{
\vspace{5pt}
\begin{quote}\itemsep1pt\parskip0pt\parsep0pt\begin{spacing}{1}
#4 \par\hspace*{\fill}\footnotesize{\citeCLLong{#1}{#2}{#3}}
\end{spacing}
\end{quote}
\vspace{-20pt}
}
% The command is changed to call the new \citeCLLong

\begin{document}
\QuoteCL{\Per}{\PerRud}{§ 1119}{Quis maxime proponendus est quem studeant adolescentes imitari? Marcus Cicero.}
\end{document}

이제 내 질문에: 나는 ( ) Long의 인수를 추가하면 LaTeX가 인수를 사용하여 명령을 호출하더라도 단순히 내 작성자 목록 대신 선택하게 되기를 바랐습니다 . 읽을지 , 읽을지 결정되기 전에 해당 부분을 추가하겠다는 것 . 그러나 예를 들어 = "Niccolò Perotti"를 선택하는 대신 "N. Per.Long"이라고 씁니다 .\citeCLLong#1Long, \emph{#2Long}\PerLong\Per\quoteCL\PerLong\Per\PerLong\PerLong

어떻게든 이 작업을 수행할 수 있습니까? 아니면 모든 인용문의 모든 인수를 변경하여 전체 논문을 검토할 필요가 없지만 서문에서 제어할 수 있게 해주는 다른 더 똑똑한 솔루션이 있습니까? 그러면 각주에 인용된 내용이 원본 형식과 동일하게 유지됩니까?

답변1

조건부를 사용하세요. 새로운 명령을 사용하면 "짧은" 형식과 "긴" 형식의 명령을 일관된 방식으로 정의할 수 있습니다. 그런 다음 \citeCL사용할 \citeCLLong수 있습니다

\documentclass{article}
\usepackage[utf8]{inputenc}

\newif\ifCLLong

\newcommand{\citeCL}[3]{\CLLongfalse #1, \emph{#2}, \textbf{#3}}

\newcommand{\citeCLLong}[3]{\CLLongtrue #1, \emph{#2}, \textbf{#3}}

\newcommand{\QuoteCL}[4]{%
\begin{quote}
#4 \par\hspace*{\fill}\footnotesize\citeCLLong{#1}{#2}{#3}
\end{quote}
}

% Abstraction for easing the definition    
\newcommand{\newshortlongcommand}[3]{\newcommand{#1}{\ifCLLong #3\else #2\fi}}

\newshortlongcommand{\Per}{N. Per.}{Niccolò Perotti}
\newshortlongcommand{\PerRud}{Rud. gram.}{Rudimenta grammatices}

\begin{document}

Testo introduttivo\footnote{\citeCL{\Per}{\PerRud}{§ 1119}}

\QuoteCL{\Per}{\PerRud}{§ 1119}{Quis maxime proponendus est quem studeant adolescentes imitari? Marcus Cicero.}
\end{document}

\end{document}

( 필수적인 것을 \QuoteCL없애기 위해 의 정의를 단순화했습니다 .)spacing

이런 방식으로 걱정 없이 인수를 직접 입력할 수도 있습니다. 예를 들어

\QuoteCL{Niccolò Perotti}{Rudimenta Grammatices}{§ 1119}{...}

동일하게 작동합니다.

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

답변2

처음 두 개의 인수를 텍스트 문자열로 변경하고 해당 \csname \endcsname구성을 사용하여 원하는 것을 달성하십시오. (참고: 어떤 패키지가 있는지 모르기 때문에 간격 환경을 껐습니다.)

\documentclass{article}
\usepackage[utf8]{inputenc}

\newcommand{\citeCL}[3]{\csname#1\endcsname, \emph{\csname#2\endcsname}, \textbf{#3}}
% Original command now used for footnotes

\newcommand{\citeCLLong}[3]{\csname#1Long\endcsname,
\emph{\csname#2Long\endcsname}, \textbf{#3}}
% New command to be called by the \quoteCL command.

\newcommand{\Per}{N. Per.}
\newcommand{\PerLong}{Niccolò Perotti}
\newcommand{\PerRud}{Rud. gram.}
\newcommand{\PerRudLong}{Rudimenta grammatices}
% Duplicating the list of names and titles, adding a long version to be called by the \citeCLLong:

\newcommand{\QuoteCL}[4]{
\vspace{5pt}
\begin{quote}\itemsep1pt\parskip0pt\parsep0pt%
%\begin{spacing}{1}%
#4 \par\hspace*{\fill}\footnotesize{\citeCLLong{#1}{#2}{#3}}
%\end{spacing}
\end{quote}
\vspace{-20pt}
}
% The command is changed to call the new \citeCLLong

\begin{document}
\QuoteCL{Per}{PerRud}{§ 1119}{Quis maxime proponendus est quem studeant adolescentes imitari? Marcus Cicero.}

\vspace{6em}
\citeCL{Per}{PerRud}{§ 1119}
\end{document}

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

관련 정보