2

Instead of hardcoding theorem in citations such as \cite[theorem xyz]{reference}, I would like to insert the cleveref theorem format, for consistency with references to theorems in the current document. I suppose this would require retrieving the (possibly default) value of \crefname. Is this possible?

5

It seems that the name is stored in \cref@<type>@name etc.

\documentclass{article}

\usepackage{cleveref}

\makeatletter
\newcommand{\theoname}{\cref@theorem@name}
\newcommand{\Theoname}{\Cref@theorem@name}
\newcommand{\theonames}{\cref@theorem@name@plural}
\newcommand{\Theonames}{\Cref@theorem@name@plural}
\makeatother

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{knuth,
  author       = {Knuth, Donald E.},
  title        = {The {\TeX} book},
  date         = 1984,
  maintitle    = {Computers \& Typesetting},
  volume       = {A},
  publisher    = {Addison-Wesley},
  location     = {Reading, Mass.},
  langid       = {english},
  langidopts   = {variant=american},
  sortyear     = {1984-1},
  sorttitle    = {Computers & Typesetting A},
  indexsorttitle= {The TeXbook},
  indextitle   = {\protect\TeX book, The},
  shorttitle   = {\TeX book}
}
\end{filecontents*}

\begin{document}

\makeatletter
\cref@theorem@name

\Cref@theorem@name

\cref@theorem@name@plural

\Cref@theorem@name@plural
\makeatother

\cite[\theoname{} xyz]{knuth}

\bibliographystyle{plain}
\bibliography{\jobname}

\end{document}

enter image description here

  • samcarter, reversed roles today! tex.stackexchange.com/q/414281/105447 :-) – gusbrs Dec 17 '18 at 23:17
  • @gusbrs Oh, nice coincidence! :) Always fun to see the different approaches answers can use! – user36296 Dec 17 '18 at 23:25
  • This is exactly what I was looking for and more, thank you! – Rastapopoulos Dec 18 '18 at 9:16
  • @Rastapopoulos You're welcome! – user36296 Dec 18 '18 at 9:27

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.