
身為 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 選擇,例如,而不是僅僅從我的作者列表中選擇,即使我使用參數呼叫命令。在決定是否讀取或之前添加該部分。但它寫的是“N. Per.Long”,而不是選擇=“Niccolò Perotti”。\citeCLLong
#1Long, \emph{#2Long}
\PerLong
\Per
\quoteCL
\Per
Long
\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}