Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

My biggest enemy is the page limit. I use short versions of my BibTeX entries in order to keep the list of references short. I now have a situation where I include the file in the journal article and also in a book. I want to use the long reference in the book and the short in the journal. I defined a boolean that is set to true if we are in the journal tex files and then defined a command that is supposed to return the short or long key depending on the value of the boolean. But somehow this does not work. Is there a way to reach my goals?

\documentclass{article}

\usepackage{natbib}

\usepackage{ifthen}
\provideboolean{jl}
\setboolean{jl}{true}


% cite alternate between the long and short citation key
\newcommand{\citekeyshortlong}[2]{\ifthenelse{\boolean{jl}}{#1}{#2}}


\begin{document}

\citet[\page 48]{\citekeyshortlong{XY-short}{XY-long}}

\end{document}
share|improve this question
    
If you use etoolbox (which I prefer as its syntax seems simpler to me) you should use a toggle: \newtoggle{jl}\toggletrue{jl}, and then \newcommand{\citekeyshortlong}[2]{\iftoggle{jl}{#1}{#2}}. –  Peter Grill Nov 14 '12 at 8:42
    
\ifthenelse is not expandable, whereas \iftoggle from etoolbox is, hence why Peter's suggestion works and yours does not. See eg Why is the ifthen package obsolete? –  cyberSingularity Nov 14 '12 at 9:19
add comment

1 Answer 1

I recommend putting the conditional outermost, so defining the \citekeyshortlong conditionally:

\usepackage{etoolbox}
\newtoggle{jl}
\toggletrue{jl} %% Use short refs

\iftoggle{jl}{%
     \newcommand{\citekeyshortlong}[2]{#1}}{%
     \newcommand{\citekeyshortlong}[2]{#2}}

(substituting etoolbox for ifthenelse as recommended by Peter Grill - though this will work with ifthenelse).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.