General\citet does not accept \substr as parameter

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
mi.te
Posts: 2
Joined: Thu Jul 17, 2008 11:45 pm

\citet does not accept \substr as parameter

Post by mi.te »

Dear all,

While trying to define a macro that "enhances" \citet (i.e. enables me to produce references looking the way I want them to look), a bunch of errors are generated which do not make any sense to me.

Code: Select all

\newcommand{\helperListCfCitet}[3]{
h1:(#2)\\
\whereischar[q]{#2}{,}
\newcounter{myc}
\setcounter{myc}{\theresult}
h2:(\themyc)\\
\addtocounter{myc}{-1}
h3:(\substr{#2}{1}{\themyc})\\
\citet{\substr{#2}{1}{\themyc}}
}

Gives the following errors:
! Undefined control sequence.
<argument> \equal
{tyrvinencharacterizingevolving2006,q45}{}
l.52 ...et{tyrvinencharacterizingevolving2006,q45}

?
! Argument of \@tempc has an extra }.
<inserted text>
\par
l.52 ...et{tyrvinencharacterizingevolving2006,q45}

?
Runaway argument?
{\TE@neg }\def \@tempb {\@tempc }\ifx \@tempa \@tempb \toks@ \expandafter \ETC.
! Paragraph ended before \@tempc was complete.
<to be read again>
\par
l.52 ...et{tyrvinencharacterizingevolving2006,q45}

?
! Missing \endcsname inserted.
<to be read again>
\toks@
l.52 ...et{tyrvinencharacterizingevolving2006,q45}

?
! Missing \endcsname inserted.
<to be read again>
\toks@
l.52 ...et{tyrvinencharacterizingevolving2006,q45}
etc. etc.

I get the idea that I need to tell Latex to first evaluate the \substr expression and only pass on the result to \citet. But I have no idea what command to use.

A minimal examples is attached. Since I couldn't upload the bib-file, here it comes (test.bib)

Code: Select all

@article{tyrvinencharacterizingevolving2006,
	title = {Characterizing the evolving research on enterprise content management},
	volume = {15},
	url = {http://www.ingentaconnect.com/content/pal/0960085x/2006/00000015/00000006/art00009},
	doi = {10.1057/palgrave.ejis.3000648},
	number = {6},
	journal = {European Journal of Information Systems},
	author = {Pasi Tyrväinen and Tero Päivärinta and Airi Salminen and Juhani Iivari},
	month = dec,
	year = {2006},
	keywords = {1,2,3,4},
	pages = {627--634},
	comment = {general model of ECM research issues},
	comment = {include content perspective}
}

Any would be greatly appreciated. Thanks a bunch in advance,

Michael
Attachments
LaTeX2.tex
(1.55 KiB) Downloaded 235 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: \citet does not accept \substr as parameter

Post by josephwright »

I think a demo of what you'd like to achieve would be handy, to explain the logic required. I'm a bit stuck trying to work out what your LaTeX is supposed to achieve.

Joseph Wright
Joseph Wright
mi.te
Posts: 2
Joined: Thu Jul 17, 2008 11:45 pm

\citet does not accept \substr as parameter

Post by mi.te »

Hi,

Sorry, you're right. The code provided doesn't do a lot of formatting. This is done by a macro (cfcitet) which I didn't post in order to keep the example more compact.

The general idea is that I can call listcfcitet like this

Code: Select all

\listcfcitet{reference1,pagenumber;reference2,pagenumber;reference3,pagenumber}
reference1,2,3=entries in bib-file

listcfcitet and helperListCfCitet are supposed to split this string; \listcfcitet splits at the ; and calls \helperCfCitet with the first part of the string up until the first ;. \helperCfCitet splits this string at the , and when it's working, it would call \cfcitet with the reference and the pagenumber instead of the \citet in the example. cfcitet would do the formatting and as part of that, also call \citet.

But as mentioned in my initial post, \citet does not accept the \substring{...} as a parameter.

Does that make it clearer?

Thanks for your help,

Michael
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: \citet does not accept \substr as parameter

Post by josephwright »

A quick hack answer is to use the plain TeX \def as follows:

\documentclass{article}
\makeatletter
\newcommand*{\listcfcitet}[1]{%
\ifx\@empty#1\@empty\else
\expandafter\listcf@citet#1;;\@empty
\fi}
\def\listcf@citet#1;#2;#3\@empty{%
\ifx\@empty#1\@empty\else
\expandafter\list@cf@citet#1,,\@empty
\ifx\@empty#2\@empty\else
\expandafter\listcf@citet#2;#3;;\@empty
\fi
\fi}
\def\list@cf@citet#1,#2,#3\@empty{%
You said citation `#1' and page ref.~`#2' \\
% In the real version, this macro should probably
% contain \citet ...
}
\makeatother
\begin{document}
\listcfcitet{First,Page1;Second,Page2}
\listcfcitet{Third,Page3}
\end{document}

Joseph Wright
Joseph Wright
Post Reply