Text FormattingCitations in \subsection{}

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
mornington
Posts: 4
Joined: Thu Apr 16, 2009 9:45 pm

Citations in \subsection{}

Post by mornington »

Hi,

I am using texniccenter and miktex. When trying something like
\subsection{sectionheading \cite{andrews2007}}
I get a fatal error and the document does not compile. Is this to be expected?

Thanks,

M

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Re: Citations in \subsection{}

Post by kaiserkarl13 »

The \cite command is robust, so you shouldn't have any problems. Which packages and document class are you using? A minimum working example would help us to solve this for you.
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Citations in \subsection{}

Post by localghost »

kaiserkarl13 wrote:The \cite command is robust, so you shouldn't have any problems. [...]
It's not about the \cite command but more about the moving argument of the \subsection command.
mornington wrote:[...] When trying something like
\subsection{sectionheading \cite{andrews2007}}
I get a fatal error and the document does not compile. [...]
The reason is the argument as described above. Use the short form to avoid difficulties.

Code: Select all

\subsection[subsection heading]{subsection heading \cite{andrews2007}}

Best regards
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Citations in \subsection{}

Post by kaiserkarl13 »

The reason is the argument as described above. Use the short form to avoid difficulties.
The short form will work (and it's what I'd do here, too, since citations in the ToC look tacky), but the \cite command should work in a floating argument too (that's what I meant by robust). Try the following example:

Code: Select all

\documentclass{article}
\begin{document}
\tableofcontents
\section{First section}
Here's an early citation:  \cite{anyone}.
\subsection{Howdy~\cite{someone}}

\begin{thebibliography}{2}
\bibitem{anyone}
Anyone else
\bibitem{someone}
Someone, I. M.
\end{thebibliography}
\end{document}
One caveat: BibTeX will detect the \cite command in the table of contents, so that citation will be [1] instead of [2] or whatever number it's supposed to be. If you want to avoid this, then you DO have to use the optional argument to the sectioning command to eliminate the citation in the table of contents. Or simply avoid citing something in a section heading (which is preferable).

However, your first post indicated that TeX was crashing because of this---that shouldn't be happening, and probably means \cite has been redefined in some (non-robust) way. Some package you're using this could do that, but I don't know of any off the top of my head that redefine \cite to be non-robust.
mornington
Posts: 4
Joined: Thu Apr 16, 2009 9:45 pm

Citations in \subsection{}

Post by mornington »

Thank you to both of you for very informative reply. I have a feeling that one of the packages I am using might be leading to a non-robust modification of \cite, but I can't be sure. The packages I generally use are below.

I usually use a preamble file to keep my most used declarations, so the \usepackage are in two batches with (possible) duplicate inclusions:
1. from preamble.tex

Code: Select all

\usepackage{amsmath,amsfonts,amssymb,mathrsfs,theorem}
\usepackage{multicol,multirow,calc,achicago,graphicx,color,colortab,rotating,enumerate}
\usepackage{pstricks,psfrag,tabularx,comment,hyperref}
\usepackage{boxedminipage}
\usepackage{bbm}
\usepackage{hyperref}
2. from main document

Code: Select all

\documentclass[a4paper]{article}
\input{preamble.tex}
% Graphics
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{pstricks}
%Tables
\usepackage{booktabs}
\usepackage{lscape}
\usepackage{bbold}
\usepackage{natbib}
\def\newblock{\hskip .11em plus .33em minus .07em}
\usepackage{url}
\usepackage{citeref}
\citestyle{authoryear}
Thank you again for your help,

M
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Citations in \subsection{}

Post by localghost »

At first do a thorough clean up of your source. You are loading several packages twice. The hyperref package should be loaded as the very last package (with only a few exceptional cases). Use only the graphicx package for graphics inclusions. The next step is to build a minimal working example (MWE) with a reduced list of packages.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Post Reply