* [NTG-context] Why is this code not creating "Ibid" style entries?
[not found] <1809399126.1699877.1744937575442.ref@mail.yahoo.com>
@ 2025-04-18 0:52 ` Joel via ntg-context
2025-04-18 7:43 ` [NTG-context] " Hans Hagen via ntg-context
0 siblings, 1 reply; 2+ messages in thread
From: Joel via ntg-context @ 2025-04-18 0:52 UTC (permalink / raw)
To: Mailing List for ConTeXt Users; +Cc: Joel
[-- Attachment #1.1: Type: text/plain, Size: 1425 bytes --]
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}%
}%
[-- Attachment #1.2: Type: text/html, Size: 3118 bytes --]
[-- Attachment #2: Type: text/plain, Size: 511 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* [NTG-context] Re: Why is this code not creating "Ibid" style entries?
2025-04-18 0:52 ` [NTG-context] Why is this code not creating "Ibid" style entries? Joel via ntg-context
@ 2025-04-18 7:43 ` Hans Hagen via ntg-context
0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen via ntg-context @ 2025-04-18 7:43 UTC (permalink / raw)
To: ntg-context; +Cc: Hans Hagen
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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-18 7:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1809399126.1699877.1744937575442.ref@mail.yahoo.com>
2025-04-18 0:52 ` [NTG-context] Why is this code not creating "Ibid" style entries? Joel via ntg-context
2025-04-18 7:43 ` [NTG-context] " Hans Hagen via ntg-context
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).