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
Text Formatting ⇒ Citations in \subsection{}
-
- Posts: 707
- Joined: Tue Mar 25, 2008 5:02 pm
Re: Citations in \subsection{}
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.
- localghost
- Site Moderator
- Posts: 9201
- Joined: Fri Feb 02, 2007 12:06 pm
Citations in \subsection{}
It's not about the \cite command but more about the moving argument of the \subsection command.kaiserkarl13 wrote:The \cite command is robust, so you shouldn't have any problems. [...]
The reason is the argument as described above. Use the short form to avoid difficulties.mornington wrote:[...] When trying something like
\subsection{sectionheading \cite{andrews2007}}
I get a fatal error and the document does not compile. [...]
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
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
-
- Posts: 707
- Joined: Tue Mar 25, 2008 5:02 pm
Citations in \subsection{}
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:The reason is the argument as described above. Use the short form to avoid difficulties.
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}
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.
-
- Posts: 4
- Joined: Thu Apr 16, 2009 9:45 pm
Citations in \subsection{}
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
2. from main document
Thank you again for your help,
M
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}
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}
M
- localghost
- Site Moderator
- Posts: 9201
- Joined: Fri Feb 02, 2007 12:06 pm
Citations in \subsection{}
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
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1