1

This question already has an answer here:

I am writing my PhD thesis and I am using an adapted version of the memoir-class + IEEEtran.bst for the bibliography style.

The idea is to create a specific List of Publications exclusively with the papers of the PhD canditate. This List of Publications is divided in two sections:'pub' denoting peer-reviewed papers, and 'pubOther' for other publications. Inside the document, the command \selfcite{} is used for citations in aforementioned List of Publications.

I get errors if I use \selfcite{} INSIDE a caption, while everything works fine if it is used elsewhere.

Here I copy the error I get:

! Undefined control sequence.
<argument> ...@tempc }\fi \fi \def \@tempa {\@nil
}\ifx \@tempa \@nnil \else...
l.96 ...ncies. (Source: \selfcite{JS2009})}
?

While here I copy the piece of code describing the List of Publications and the command \selfcite

\RequirePackage[resetlabels]{multibib}  % Used for multiple bibliographies, as this class enables the use of a separate List of Publications    

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We define two 'sections' in our own List of Publications, but it can be     %
% expanded as desired. Here, 'pub' denotes peer-reviewed papers (journals,    %
% conferences), and 'pubOther' denote other publications (popular article,    %
% invited talk, workshop, ...). Use \selfcite{<key>} to cite these            %
% These two lists need to be separately compiled: 'bibtex pub'                %
%                                                 'bibtex pubOther'           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\newcites{pub}{Peer-reviewed}
\newcites{pubOther}{Other}
\newcommand\biblabelprefix{}
\newdimen\b@belwidth
\newdimen\b@b@lwidth
\newcommand\setbabelwidth[1]{{%
    \newbox\tmp
    \setbox\tmp=\hbox{#1}%
    \global\b@belwidth=\wd\tmp
}}
\renewcommand\@biblabel[1]{{%
    \newbox\tmp
    \setbox\tmp=\hbox{#1}%
    \@tempdima=\wd\tmp%
    \@tempdimb=\m@ne\@tempdima
    \advance\@tempdimb by \b@belwidth
    \rule{\@tempdimb}{0pt}[\biblabelprefix#1]%
}}
\def\@bibitem#1{%
    \item\if@filesw
        \immediate\write\@auxout{\string\bibcite{#1}{\biblabelprefix\the\value{\@listctr}}}%
    \fi\ignorespaces}
\renewcommand{\@fnsymbol}[1]{%
    \ensuremath{%
        \ifcase#1\or \dagger\or \ddagger\or
        \mathsection\or \|\or \mathparagraph\or **\or \dagger\dagger
        \or \ddagger\ddagger \else\@ctrerr\fi
    }
}
\newcommand\blfootnote[1]{% Enable a footnote at begin of chapter to say e.g. parts of this chapter were published in ... 
    \xdef\@thefnmark{\null}
    \@footnotetext{%
    \hspace{-1.8em}
    #1
    }
}
\@ifundefined{@mb@citenamelist}{\def\@mb@citenamelist{cite,citep,citet,citealp,citealt}}{\relax}
\def\selfcite#1{\setcitestyle{open={[\initials}}\citepub{#1}\setcitestyle{open={[}}}

\newcommand\listofpublications{{%
    \small
    \setbabelwidth{10}
    \microtypesetup{protrusion=false}%  
    \renewcommand{\bibsection}{%no chapter but simply section
        \section{\bibname}
        \prebibhook
    }   
    \renewcommand{\biblabelprefix}{\initials}% Add prefix to biblabel for publications
    \continuouslabelstrue
    \bibliographystylepub{IEEEtran2}%
    \bibliographystylepubOther{IEEEtran2}%
    \chapter{List of publications}
    \scriptsize 
    \bibliographypub{IEEEabrv,\bibfile}
    \bibliographypubOther{IEEEabrv,\bibfile}%   
    \microtypesetup{protrusion=true}%
}}
\makeatother

Can you please help me to find the problem? Thanks!

marked as duplicate by koleygr, Community Oct 20 '18 at 11:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Welcome to TeX.SE! Sometimes inside a caption you have to add the command with \protect before it. – koleygr Oct 20 '18 at 11:14
  • Welcome @clidrevandijk... I made it an answer since it works for you, but possibly it is a duplicate too. – koleygr Oct 20 '18 at 11:33
  • Also, next time try to give a MWE (tex.meta.stackexchange.com/q/228/120578) because it is easier to get an answer that works for you... and you have much more possibilities to get help. – koleygr Oct 20 '18 at 11:38
0

There are some commands that we have to protect their content in LaTeX in several cases (of a command that will be expanded later etc).

\caption is one of them in many cases.

So, add a \protect command before your \selfcite command like:

\caption{Your text here\ldots (Source: \protect\selfcite{JS2009})}

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