ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Andreas Schneider <aksdb@gmx.de>
To: ntg-context@ntg.nl
Subject: Re: Conditional commands
Date: Tue, 30 Jun 2009 18:14:28 +0200	[thread overview]
Message-ID: <20090630181428.206747f7@netmaster> (raw)
In-Reply-To: <20090629214149.2a3c2739@netmaster>


[-- Attachment #1.1: Type: text/plain, Size: 3736 bytes --]

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 <aksdb@gmx.de> wrote:

> 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.
> 

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 1948 bytes --]

[-- Attachment #2: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

      reply	other threads:[~2009-06-30 16:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-29 19:41 Andreas Schneider
2009-06-30 16:14 ` Andreas Schneider [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090630181428.206747f7@netmaster \
    --to=aksdb@gmx.de \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).