1

Related to my previous question, which could be solved with a change in the TeXStudio configuration

bibtex.exe -- ?*.aux

I am still having trouble with the natbib and multiref combination.

My example

\documentclass[a4paper]{article}
\usepackage{filecontents}

\begin{filecontents}{bib.bib} @book{tolkien_93, title={The Lord of the Rings: Part 1: The Fellowship of the Ring}, author={Tolkien, John Ronald Reuel}, year={1993}, publisher={Christian Blind Mission International} }

@book{tolkien_66,
    title={The Lord of the Rings. Part 2: The Two Towers},
    author={Tolkien, John Ronald Reuel},
    year={1966},
    publisher={Allen and Unwin}
}

@book{tolkien_55,
    title={The Lord of the Rings. Part 3: The Return of the King},
    author={Tolkien, John Ronald Reuel},
    year={1955},
    publisher={Allen \& Unwin}
}

@book{tolkien_79,
    title={The silmarillion},
    author={Tolkien, JR John Ronald Reuel},
    year={1979},
    publisher={Random House LLC}
}

\end{filecontents}

\usepackage[ colorlinks=true, linkcolor=black, pagecolor=black, citecolor=black, filecolor=black, urlcolor=black, menucolor=black, ]{hyperref}

\usepackage[numbers, super, sort&compress, square]{natbib}

\makeatletter \def@mb@citenamelist{cite,citep,citet,citealp,citealt,citepalias,citetalias} \makeatother

\usepackage[resetlabels]{multibib} \newcites{pub}{Publications}

\usepackage{lipsum} \usepackage{booktabs}

\defcitealias{tolkien_93}{HDR-1} \defcitealias{tolkien_66}{HDR-2} \defcitealias{tolkien_55}{HDR-3} \defcitealias{tolkien_79}{silmarillion}

\begin{document}

\section{Lipsum \protect \citepaliaspub{tolkien_93}}

\lipsum[2][1]\cite{tolkien_66} \lipsum[5][7]\citepub{tolkien_93} \\ 
\lipsum[1][2]\citepaliaspub{tolkien_79} \lipsum[25][13]\citepalias{tolkien_55}.

\begin{table}[htb!]
    \centering
    \caption[short caption \protect \citepaliaspub{tolkien_93}]{caption. \protect \citepaliaspub{tolkien_93}}
    \begin{tabular}{lcc}
        \toprule
        lipsum & lipsum & lipsum \\ \midrule
        lipsum & lipsum & lipsum \\
        lipsum & lipsum & lipsum \\
        \bottomrule
    \end{tabular}
\end{table}

\bibliographystyle{angew}
\bibliography{bib}

\let\noopsort\undefined
\let\printfirst\undefined
\let\singleletter\undefined
\let\switchargs\undefined   

\bibliographystylepub{angew}
\bibliographypub{bib}

\end{document}

did produce the error Use of \mb@@citex doesn't match its definition. ...ipsum \protect \citepaliaspub{tolkien_93}}

Is there some way to tackle this problem? The problem results from the caption environment, since everything works fine without it.

EDIT 1

As soon as I posted the question, I already found the solution here. When using \protect it works fine for the caption, so I also tried it in the section, and there the error stays the same even after adding \protect.

EDIT 2

Also, I did some research and found this answer, where using \cite<seq> in the \section shows no errors using \protect, but for me the error Use of \mb@@citex doesn't match its definition. ...ipsum \protect \citepaliaspub{tolkien_93}} remains. Any suggestions, what I did wrong?

EDIT 3

When I uncomment \usepackage{hyperref}, \protect is working like it should, and, according to this answer, the order of the packages plays an additional role. So as soon as I find a part of the answer, another problem occurs.

Excelsior
  • 2,322
  • @moewe Thanks, I also found this and tried it for the section environment, but this doesn't work. I changed my question according to your and my findings. – Excelsior Apr 05 '21 at 21:27
  • Curse you, bookmarks! Close vote retracted... – moewe Apr 05 '21 at 21:30

1 Answers1

2

hyperref has no idea what to do with \citepaliaspub in the bookmarks, you need to provide a sensible definition, or use

 \section{Lipsum \texorpdfstring{\protect\citepaliaspub{tolkien_93}}{bookmark text}} 

A possible definition could be

\pdfstringdefDisableCommands{%
 \def\citepaliaspub#1{\csname al@#1\@extra@b@citeb\endcsname}}

This would then give this in the bookmarks:

enter image description here

Ulrike Fischer
  • 327,261
  • Thanks for the answer. I didn't think this would be that tricky, I have a lot more to learn. Next time maybe I will stick to biblatex ... – Excelsior Apr 09 '21 at 19:01