
我正在嘗試建立一個擴展函數\cite{}
以支援多點引用(仍在使用該apacite
包)。我正在嘗試創建一個 LaTeX 標記文檔,它可以在 ShareLaTex 中呈現整潔的 PDF,也可以\citeNP
在文檔內沒有混亂的命令的情況下進行解析
標準語法\cite{}
是:
\cite<preliminarytext>[pinpoint]{bibtexref1,bibtexref2,...}
我正在嘗試創建這個命令:
\myapacite[pinpoint1,pinpoint2,...][additionaloptions]{bibtexref1,bibtexref2,...}
在哪裡:
如果逗號分隔的「pinpoint」參數的數量
\myapacite
不等於逗號分隔的「bibtexref」參數的數量,則忽略這些參數並插入常規\cite{}
命令如果逗號分隔的「pinpoint」和「bibtexref」參數的數量相同,則循環並將它們插入為:
(\citeNP[pinpoint1]{bibtexref1}; \citeNP[pinpoint2]{bibtexref2}; ...)
這是我想要實現的基本佈局,儘管會有多個 TeX 問題(像許多問題一樣,我來自程式設計背景,只是慢慢學習 TeX/LaTeX)。任何建議將不勝感激。
\documentclass[apacite]{apa6}
\usepackage{xparse,expl3}
\NewDocumentCommand\myapacite{O{}O{}m}{%
\if\equals{\clist_count:n {#1}}{\clist_count:n {#3}}%
\cite[#1]{#3}%
\else%
\if\equals{1}{\clist_count:n {#3}}%
\cite[#1]{#3}%
\else%
\if\equals{2}{\clist_count:n {#3}}%
(\citeNP[\clist_item:Nn {1} {#2}]{\clist_item:Nn {1} {#3}}; \citeNP[\clist_item:Nn {2} {#2}]{\clist_item:Nn {2} {#3}})\fi\fi\fi%
}
\begin{document}
Single cite with no pinpoints: \myapacite{goossens93}
\\
\\
Double cite with both pinpoints: \myapacite[p.123,p.456]{greenwade93,goossens93}
\\
\\
Double cite with no pinpoints: \myapacite{greenwade93,goossens93}
\\
\\
\bibliography{ testbib }
\end{document}
這是testbib.bib
文件(我無法弄清楚如何在 ShareLaTeX 中使用文件內容):
@article{greenwade93,
author = "George D. Greenwade",
title = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year = "1993",
journal = "TUGBoat",
volume = "14",
number = "3",
pages = "342--351"
}
@book{goossens93,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}