
\cite{}
私は、複数のピンポイント引用をサポートするために拡張する関数を構築しようとしています(まだパッケージを使用しています)。私は、ShareLaTexで整然としたPDFをレンダリングでき、ドキュメント内のコマンドapacite
の絡み合いなしに解析できるLaTeXマークダウンドキュメントを作成しようとしています。\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 で filecontents を使用する方法がわかりませんでした):
@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"
}