
On 4/18/2025 2:52 AM, Joel via ntg-context wrote:
I created this simple macro, for citing papers. Basically just use this format:
\turabian{bibtextkey}{page range}
or
\turabian{smith1980}{10-23}
...and it places a citation.
Now, one feature I needed was if the bibtextkey ever repeated, it should instead display "Ibid. p. 10-23"
So if I have text like this...
This is a passage about some trees. The trees were tall. \turabian{smith1980}{2-30} The trees were also really green. \turabian{smith1980}{40-44}
...the second citation just displays the "Ibid., p. 40-44".
I did this by at the end of the macro, setting \setvalue{previousmymacro}{#1}, then checking if that value is the same the next time hte macro is called. So its just checking, if #1 is same as last time the macro was called, then use Ibid.
Something though isn't working as expected. Why isn't this displaying Ibid. when it should for repeated bibtextkeys?
--Joel
Code:
\let\previousmymacro\empty \define[2]\turabian{% \iftok{#1}{\getvalue{previousmymacro}}% \doifemptyelse{#2}{% \footnote{Ibid.}\nocite[#1]% }{% \footnote{Ibid., #2.}\nocite[#1]% }% \else% \doifemptyelse{#2}{% \cite[#1]% }{% \cite[loctext={#2}][#1]% }% \fi% \setvalue{previousmymacro}{#1}% }%
A bit more hip: \starttexdefinition protected turabian #1#2 \ifcsname MyCite::#1\endcsname % variant 1: check parameter \ifparameter#2\or \footnote{Ibid., #2.} \else \footnote{Ibid.} \fi \nocite[#1] \else % variant 2: check for empty \ifempty{#2} \cite[#1] \else \cite[loctext={#2}][#1] \fi \gletcsname MyCite::#1\endcsname\relax \fi \stoptexdefinition anyway, you need to store per cite as well as do that global to be sure it is seen when used grouped as you didn't provide a MWE there is little to test Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------