Conditional commands
Hi, I'm currently trying to make a command that outputs different text depending on the situation it has been called, but I'm absolutely stuck there (I'm not very familiar with TeX, so it's probably obvious to most of you :-/). It currently looks like this: \doassign[mycite][last=] \def\mycite[#1]{% \footnote{% \doifelse{\mycitelast}{#1}{Ebenda}{\cite[alternative=data][#1]}% } \doassign[mycite][last=#1] } The idea is as follow: if I cite the same citation two or more times in a row (e.g. Some text\mycite[chan_genetic_2005] ... more text\mycite[chan_genetic_2005]) it should only output the whole quotation the first time, and "Ebenda" all the other times. But as it seems, the \doifelse always evaluates to false and therefore outputs the whole citation every time. Does someone see what I might be doing wrong? Or is there even a better way to do this? Thanks, Andreas.
Hello again,
after fiddling around some more, I stumbled across \getvalue which
seems to solve my problems - for whatever reason ... I guess it does
some preprocessing.
I now got my bibliography enhancements (I needed so far) running. If
someone else needs it, here it is:
\def\mycite{\dodoubleempty\domycite}
\def\defaultciterepeat{Ebenda}
\def\defaultciteprefix{Vgl. }
\def\defaultcitepage{S. }
\def\defaultcitechapter{Kap. }
\def\domycite[#1][#2]{%
\ifsecondargument
\getparameters[MCP][prefix=\defaultciteprefix,page=,chapter=,suffix=,#1]
\doinsertmycite[#2]{\MCPprefix}{%
\expandoneargafter\doifnotempty{\MCPpage}{\
\defaultcitepage\MCPpage.}%
\expandoneargafter\doifnotempty{\MCPchapter}{\
\defaultcitechapter\MCPchapter.}%
\expandoneargafter\doifnotempty{\MCPsuffix}{\ \MCPsuffix}% } \else
\doinsertmycite[#1]{\defaultciteprefix}{}
\fi
}
\def\doinsertmycite[#1]#2#3{%
\footnote{%
#2%prefix
\doifelse{\getvalue{mycitelast}}{#1}%
{\defaultciterepeat\doifempty{#3}{.}}%
{\doifelse{\getvalue{mycitepast #1}}{used}%
{\bgroup%
\getcitedata[arttitle][#1] to \bibtitle
\cite[alternative=authoryear][#1]. \bibtitle.%
\egroup}%
{\cite[alternative=data][#1]}}%
#3%suffix
}
\setvalue{mycitelast}{#1}
\setvalue{mycitepast #1}{used}
}
Essentially all it does is: wrap \mycite around \cite to process the
output depending on the circumstances:
* if the citation is the first of this bib-entry, it is places
completely into the footnote (alternative=data)
* if the citation was used before, in the document, it is only
referenced rather short (author, year, title)
* if the citation was used _directly_ before, it is not repeated but
only referenced with the word "Ebenda" (meaning more or less "see
above")
It is also able to prepend text (like "Vgl. " [="Compare"]) and append
text (like page or chapter number, or a custom string).
Examples:
\mycite[some_bib_entry]
\mycite[prefix={Vgl. }, page=123, chapter={Introduction},
suffix={some more text.}][some_bib_entry]
The only thing it doesn't handle (yet) is, if a citation was
directly used before on a previous page. Then mycitelast should be
reset so that at least the short citation is used. But I wasn't able to
find a safe way to do this. I fiddled around with
\insertpagebreakhandler for a while, but apart from not yielding any
result, I don't believe, that it is intended for stuff like this.
So if someone knows a way to handle that last case (page break) too, I
would be glad to hear about it.
Regards,
Andreas.
On Mon, 29 Jun 2009 21:41:49 +0200
Andreas Schneider
Hi,
I'm currently trying to make a command that outputs different text depending on the situation it has been called, but I'm absolutely stuck there (I'm not very familiar with TeX, so it's probably obvious to most of you :-/). It currently looks like this:
\doassign[mycite][last=] \def\mycite[#1]{% \footnote{% \doifelse{\mycitelast}{#1}{Ebenda}{\cite[alternative=data][#1]}% } \doassign[mycite][last=#1] }
The idea is as follow: if I cite the same citation two or more times in a row (e.g. Some text\mycite[chan_genetic_2005] ... more text\mycite[chan_genetic_2005]) it should only output the whole quotation the first time, and "Ebenda" all the other times. But as it seems, the \doifelse always evaluates to false and therefore outputs the whole citation every time.
Does someone see what I might be doing wrong? Or is there even a better way to do this?
Thanks, Andreas.
participants (1)
-
Andreas Schneider