1

I'ld like to do get an alternative of the following code, working with thmtools:

\begin{theorem}[Theorem X.X of \cite{foo}] bar \end{theorem}

When I do the following:

\begin{theorem}[name={Theorem X.X of \cite{foo}}] bar \end{theorem}

if theorem is an environment created in my header using

\usepackage{amsthm}
\usepackage{thmtools}
\declaretheorem[style=plain,    name=Theorem,       numberwithin=section]{theorem}

I'm getting errors. Am I doing something wrong?

Update

I managed to isolate the issue. It is related with some modifications of the cite command by the ijcai17 package (which I am obliged to use).

So: minimal failing example:

\documentclass{article}
\usepackage{ijcai17}

\usepackage{amsthm}
\usepackage{thmtools}
\declaretheorem[style=plain, name=Theorem, numberwithin=section]{theorem}
\begin{document}
 \begin{theorem}[name={Theorem X.X of \cite{icdt/Abiteboul88}}] 
bar
\end{theorem}
\begin{thebibliography}{}

\bibitem[Abiteboul, 1988]{icdt/Abiteboul88}
Abiteboul, S. (1988).
\newblock Updates, a new frontier.
\newblock pages 1--18.

\end{thebibliography}
\end{document}

using the ijcai17.sty from http://ijcai-17.org/FormattingGuidelinesIJCAI-17.zip

4

2 Answers 2

2

As suggested by samcarter, using \protect does the trick.

Here is my minimal example updated, giving me the desired result:

\documentclass{article}
\usepackage{ijcai17}

\usepackage{amsthm}
\usepackage{thmtools}
\declaretheorem[style=plain, name=Theorem, numberwithin=section]{theorem}
\begin{document}
 \begin{theorem}[name={Theorem X.X of \protect\cite{icdt/Abiteboul88}}] 
bar
\end{theorem}
\begin{thebibliography}{}

\bibitem[Abiteboul, 1988]{icdt/Abiteboul88}
Abiteboul, S. (1988).
\newblock Updates, a new frontier.
\newblock pages 1--18.

\end{thebibliography}
\end{document}

enter image description here

still using the ijcai17.sty from http://ijcai-17.org/FormattingGuidelinesIJCAI-17.zip

2

The package you are forced to use file makes a few basic errors, that can be readily fixed.

\documentclass{article}
\usepackage{ijcai17}
\usepackage{amsthm}
\usepackage{thmtools}

\declaretheorem[style=plain, name=Theorem, numberwithin=section]{theorem}

% fix the stupid mistakes in ijcai17
\makeatletter
\DeclareRobustCommand\cite{%
  \def\citeauthoryear##1##2{\def\@thisauthor{##1}%
  \ifx \@lastauthor \@thisauthor \relax \else##1, \fi ##2}%        
  \@icite 
}
\DeclareRobustCommand\shortcite{\def\citeauthoryear##1##2{##2}\@icite}
\DeclareRobustCommand\citeauthor{\def\citeauthoryear##1##2{##1}\@nbcite}
\DeclareRobustCommand\citeyear{\def\citeauthoryear##1##2{##2}\@nbcite}
\makeatother


\begin{document}

\begin{theorem}[Theorem X.X of \cite{icdt/Abiteboul88}]
bar
\end{theorem}

\begin{thebibliography}{}

\bibitem[Abiteboul, 1988]{icdt/Abiteboul88}
Abiteboul, S. (1988).
\newblock Updates, a new frontier.
\newblock pages 1--18.

\end{thebibliography}
\end{document}

Note that

\begin{theorem}[name=Theorem X.X of \cite{icdt/Abiteboul88}]

would work in the same way; I see no need for using the key-value syntax.

Original answer, due to the OP not really showing the problem

It will be at least confusing, I'm afraid. Anyway, you can't use the name key in the optional argument to theorem: it's a key for \declaretheorem only.

\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}
\declaretheorem[
  style=plain,
  name=\protect\namedtheoremname,
  numberwithin=section
]{namedtheoreminner}
\newcommand{\namedtheoremname}{}
\newenvironment{namedtheorem}[1]
 {\renewcommand\namedtheoremname{#1}%
  \namedtheoreminner}
 {\endnamedtheoreminner}

\begin{document}

\section{A theorem}

\begin{namedtheorem}{Theorem X.X of \cite{foo}}
Some theorem in another paper
\end{namedtheorem}

\begin{thebibliography}{1}

\bibitem{foo} Foo

\end{thebibliography}

\end{document}

enter image description here

7
  • you can use name in the theorem environment. See page 8 of ctan.mackichan.com/macros/latex/exptl/thmtools/thmtools.pdf
    – BartBog
    Nov 23, 2016 at 11:18
  • @BartBog Yes, but not with the result you ask for. Anyway, I get no error.
    – egreg
    Nov 23, 2016 at 11:24
  • Well, it is with the result I want at least. The result can look like <b>Theorem X (Theorem X.X of Y)</b>
    – BartBog
    Nov 23, 2016 at 11:30
  • There is no error, in that case. Maybe you have \cite[p. 13]{foo}? Please, add a minimal example showing the issue.
    – egreg
    Nov 23, 2016 at 11:33
  • I updated with a minimal failing example
    – BartBog
    Nov 23, 2016 at 11:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .