5

My question is very similar to the one @leandriis asked here. I want to cite one of my references in the title of a subsection. Since I am using hyperref and the \cite-command causes trouble because such a tex-statement cannot be tranlated into a pdf-bookmark, I was using \texorpdfstring and put the \cite-command into the first argument. But what can I put into the second argument such that basically the same output appears in the resulting bookmark, just without hyperref in pdf-bookmark of course. I was thinking similar to @leandriis to somehow extract the number of the reference from the citation and write something like [\getnumberfromcitation{nameofbibtexentry}, Theorem A] into the second command. Yet, this seems impossible.

Then I found the question above. And there is a solution presented for biblatex which probably works. The problem is just that I am using bibtex, because I want to use the bibliographystyle amsplain which is apparently only available in bibtex (cf. this question).

The question is: What can I do? How can I adapt the solution of @Ulrike Fischer in the question above to the case of bibtex instead of biblatex? I am not enough of a tex-expert to answer this on my own. Thank you very much in advance for your help!

Example of my tex-file.

\documentclass[12pt]{amsart}

\usepackage{amssymb,amscd,amsthm, verbatim,amsmath,color,fancyhdr,mathrsfs}
\usepackage{graphicx}
\usepackage{turnstile} 
\usepackage{todonotes}
\usepackage[bookmarks=true]{hyperref}
\usepackage{csquotes}
\usepackage[mathscr]{euscript}

\def\tequiv{\ensuremath\sdststile{}{}}

\usepackage[letterpaper,left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm,dvips]{geometry}
\begin{document}
\section{Section}
\subsection{Subsection \texorpdfstring{{\normalfont(\cite[Subsection~x.y]{author})}}{What to write here?}}

\bibliographystyle{amsplain}
\bibliography{lib}
%lib.bib has an entry with key author
\end{document}
6
+50

There are a couple of issues here. The first is solved in the linked post by Ulrike Fischer but using biblatex by patching the \bibitem commands to produce a \label that can be referenced. This can also be done with standard bibtex as follows:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@bibitem}{\ignorespaces}{\label{bib-#1}\ignorespaces}{}{}
\makeatother

(\bibitem calls \@bibitem if there is no optional argument, which is the case in your example, and the final macro executed by \@bibitem is \ignorespaces, we put our label just before that.)

You can then use \ref{bib-author} to the section title instead of \cite{author}. You probably want to package this into a command \mycite to add square brackets.

\newcommand{\mycite}[1]{[\ref{bib-#1}]}

The second problem is that you cannot use optional arguments in the pdf part of \texorpdfstring. One thus needs to define a version of the citing command the takes required rather than optional arguments.

\newcommand{\myqcite}[2]{[\ref{bib-#2}, #1]}

Both these definitions assume you are citing only one item. Now for use in titles you may as well hide away the \texorpdfstring in some helper commands so you can just write \mytcite{author} or \mytqcite{Section X.Y}{author}.

\newcommand{\mytcite}[1]{\texorpdfstring{\cite{#1}}{\mycite{#1}}}
\newcommand{\mytqcite}[2]{\texorpdfstring{\cite[#1]{#2}}{\myqcite{#1}{#2}}}

The image is a screenshot showing both the tex output and the bookmarks.

Sample output

\documentclass[12pt]{amsart}

\usepackage{etoolbox}
\usepackage[bookmarks=true]{hyperref}

\makeatletter
\patchcmd{\@bibitem}{\ignorespaces}{\label{bib-#1}\ignorespaces}{}{}
\makeatother

\newcommand{\mycite}[1]{[\ref{bib-#1}]}
\newcommand{\myqcite}[2]{[\ref{bib-#2}, #1]}
\newcommand{\mytcite}[1]{\texorpdfstring{\cite{#1}}{\mycite{#1}}}
\newcommand{\mytqcite}[2]{\texorpdfstring{\cite[#1]{#2}}{\myqcite{#1}{#2}}}

\begin{document}

\section{Section (\mytcite{author})}

\section{Section (\mytqcite{Section~2.1}{author})}

\bibliographystyle{amsplain}
\bibliography{lib}

\end{document}

with lib.bib

@Article{author,
  author =   {Author, A. N.},
  title =    {Title},
  journal =  {J. Jour.},
  year =     2000,
  volume =   756,
  pages =    {1--77}
}

If your bibitems also have option arguments, the you will need to patch \@lbibitem in the same way as above.

|improve this answer|||||
  • Thank you!!! I use now this command \subsection{Title \texorpdfstring{{\normalfont(\cite[Subsection~x.y]{author})}}{([\ref{bib-author}, Subsection~x.y])}} with the first displayed code you gave in the preamble. This works perfectly fine for me. I don't have problems with optional arguments in the pdfstring. With your solution, it even gives the right color for the hyperref, namely that of \cite and not that of \ref. Much better this way, than filling in the numbers manually when the document is finished. – user66288 Jan 13 '18 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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