# “Undefined control sequence” heisenbug

I'm editing the file below and I started getting an "Undefined control sequence" error. The thing is, I don't think there is an error with the code. In fact, in item 6, the second math display is copied from the first, but I get the error when I have the second line but not if I delete the second line and just have the first. Similarly, if I delete other random parts of the file, the file compiles fine. I think this may be a bug in the software somewhere but I'm not sure how to handle that. I am using Texmaker 4.5. If anybody can tell me how to fix this or to which group I can report a bug, that would be great. The error and code are below.

! Undefined control sequence.
\f@ncyorh ->\myauthor
\strut
l.120 \end{document}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., \hobx'), type I' and the correct
spelling (e.g., I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
[2] (./PainRankinErrata.aux) )
Here is how much of TeX's memory you used:
13472 strings out of 493089
262778 string characters out of 6134842
311803 words of memory out of 5000000
16685 multiletter control sequences out of 15000+600000
6590 words of font info for 26 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
55i,12n,67p,425b,262s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/local/texlive/2015/texmf-dist/fonts/type1/p
ublic/amsfonts/cm/cmmi10.pfb></usr/local/texlive/2015/texmf-dist/fonts/type1/pu
blic/amsfonts/cm/cmmi7.pfb></usr/local/texlive/2015/texmf-dist/fonts/type1/publ
ic/amsfonts/cm/cmr10.pfb></usr/local/texlive/2015/texmf-dist/fonts/type1/public
/amsfonts/cm/cmr5.pfb></usr/local/texlive/2015/texmf-dist/fonts/type1/public/am
sfonts/cm/cmr7.pfb></usr/local/texlive/2015/texmf-dist/fonts/type1/public/amsfo
nts/cm/cmss10.pfb></usr/local/texlive/2015/texmf-dist/fonts/type1/public/amsfon
ts/cm/cmsy10.pfb></usr/local/texlive/2015/texmf-dist/fonts/type1/public/amsfont
s/cm/cmsy7.pfb></usr/local/texlive/2015/texmf-dist/fonts/type1/public/amsfonts/
cm/cmti10.pfb>
Output written on PainRankinErrata.pdf (2 pages, 86516 bytes).
PDF statistics:
50 PDF objects out of 1000 (max. 8388607)
36 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 500000)
13 words of extra memory for PDF output out of 10000 (max. 10000000)


And the code

\documentclass[10pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{comment}
\usepackage{fancyhdr}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{calc}
\pagestyle{fancy}
\usepackage{enumerate}

\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\erfc}{erfc}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\I}{\mathbb{I}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\lb}{\lbrace}
\newcommand{\rb}{\rbrace}
\newcommand{\exist}{\exists}
\newcommand{\abs}[1]{\lvert#1\rvert}
\newcommand{\norm}[1]{\lVert#1\rVert}
\newcommand{\seq}[1]{\left\lb#1\right\rb}

\theoremstyle{definition}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}

\newcommand{\mytitle}{Errata for Introduction to Vibrations and Waves by H. J. Pain and Patricia Rankin}
\newcommand{\mydate}{February 11, 2018}

\newcommand{\mymaketitle}{
\centering{\mytitle\\
\mydate\\
}
}

\begin{document}\thispagestyle{empty}

\mymaketitle
\bigskip
\begin{enumerate}
\item Page 9, Worked Example. The following text\\
\bigskip
\fbox{\begin{minipage}{4 in}
In Figure 1.1(g) the energy equation is
\begin{gather*}
E = \frac{1}{2}m\dot x^2 + A\rho gx^2\\
\frac{\mathrm{d}E}{\mathrm{d}t} = (m\ddot x + 2A\rho gx)\dot x = 0\\
m\ddot x + sx = 0
\end{gather*}
with
\begin{gather*}
s=2A\rho g\\
\omega^2 = \frac{2A\rho g}{m} = \frac{2g}{l}
\end{gather*}
\end{minipage}}\\
\bigskip
should be replaced with\\
\bigskip
\fbox{\begin{minipage}{4 in}
In Figure 1.1(g) the energy equation is
\begin{gather*}
E = \frac{1}{2}m\dot x^2 + \frac{1}{2}A\rho gx^2\\
\frac{\mathrm{d}E}{\mathrm{d}t} = (m\ddot x + A\rho gx)\dot x = 0\\
m\ddot x + sx = 0
\end{gather*}
with
\begin{gather*}
s=A\rho g\\
\omega^2 = \frac{A\rho g}{m} = \frac{g}{l}
\end{gather*}
\end{minipage}}\\
\bigskip
This makes the formula for $\omega^2$ match that in Figure 1.1(g).

\item Page 12, Figure 1.5. Change the label

\begin{equation*}
\mathsf{L\dot q + \frac{q}{c} = 0}
\end{equation*}
to
\begin{equation*}
\mathsf{L\ddot q + \frac{q}{c} = 0}
\end{equation*}
\item Page 14, Figure 1.6. Change the angle for $\phi_2$ to indicate the angle between the x-axis and the vector with length $a_2$.
\item Page 18, Problem 1.10. Change a spring of length \textit{1}'' to a spring of length $l$''.
\item Page 35, last line. Change
\begin{equation*}
A^2 = A_0^2 e^{(-rt/2m)^2}
\end{equation*}
to
\begin{equation*}
A^2 = A_0^2 (e^{-rt/2m})^2
\end{equation*}

\item Page 37, first equation. Change
\begin{equation*}
-\Delta E = \frac{\mathrm{d}E}{\mathrm{d}t} \Delta t = \frac{-r}{m} E \frac{1}{\nu'}
\end{equation*}
to
\begin{equation*}
-\Delta E = \frac{\mathrm{d}E}{\mathrm{d}t} \Delta t = \frac{-r}{m} E \frac{1}{\nu'}
\end{equation*}

\item Page 39, Worked Example solution, first line. Change Critical dumping:'' to Critical damping:''.
\end{enumerate}

\begin{flushleft}

\end{flushleft}

\end{document}

• You probable forgot to define \myauthor. After inserting \newcommand{\myauthor}{A marmot} above \rhead the code runs through on my machine. – user121799 Feb 11 '18 at 16:54
• \newcommand{\myauthor}{I should look what I have defined} should work ;-) Not everything is a bug -- most of the stuff is user errors, either by typos or wrong usage of macros. TeXmaker is also complete irrelevant here – user31729 Feb 11 '18 at 16:54
• Yep. And it is an Heisenbug because it is triggered if you have more than one page (being the first one \thispagestyle{empty}) – Rmano Feb 11 '18 at 16:56
• @marmot: Either you or Rmano (can ping only one of you both) should provide an answer.... – user31729 Feb 11 '18 at 17:04
• @Rmano Do you want to ping an answer? (I doubt the user is a marmot ;-) – user121799 Feb 11 '18 at 17:06

If you look at the error message,

! Undefined control sequence.
\f@ncyorh ->\myauthor
\strut


it is saying to you that the command \myauthor (control sequence in TeX jargon) is not defined. And if you look at your document, you define \mytitle and \mydate but not \myauthor.

The bug seems a Heisenbug because it is triggered only when you build a "fancy" header; the first page has no headers or footers (\thispagestyle{empty}) and so it will happen only if the document is long enough to generate another page.

You could suspect that because \f@ncyorh reminds "fancy" (in effect internal "variables" and "functions" of the package fancyhdr are stored with that prefix to avoid clashes with other packages).

So

\newcommand{\myauthor}{user109923}


will fix it.

• The uncertainty in this Heisenbug is remarkably small ;-) – user31729 Feb 11 '18 at 17:24
• +1, I've fixed the indentation in the question and this answer. Note that TeX shows each level of its input stack as a pair of lines, the first line showing everything that it has read so far, and the second whatever is still remaining to read. So the error message here shows that TeX read the token \myauthor when it got the error, and \strut was still to come. This lets you know that the undefined control sequence is precisely \myauthor`, rather than any other. – ShreevatsaR Feb 11 '18 at 18:12