1

This question is an extension of the one posed in How to Produce These Old-Style Text Dividers with PDFLATEX

Consider the following code:

\documentclass{article}
\usepackage{tikz}

\newcommand{\oldsep}
{%
  \begin{center}\begin{tikzpicture}[thick]
  \draw[-latex] (-1,0) -- (-0.025,0);
  \draw[-latex] ( 1,0) -- ( 0.025,0);
  \draw[fill=white] (0,0) circle (0.075);
  \end{tikzpicture}\end{center}
}

\begin{document}
\oldsep
\tableofcontents
%\addtocontents{toc}{ $\oldsep$}
\end{document}

which produces the following Tikz-produced text divider:

enter image description here

I would like to be able to call it into the TOC to be used as a text separator; however, the line that I have commented out in the code, for some reason, is not correct.

Question: Can someone suggest how I may modify the code so that I may call the said picture into the TOC when I want to? Thank you.

2
  • If you are going to be using this a lot, you should put it into a savebox instead of a macro. Jul 24 at 6:54
  • @John Kormylo Thank you for pointing that out. Jul 24 at 14:30
2

You just need to protect it.

\documentclass{article}
\usepackage{tikz}

\newcommand{\oldsep}
{%
  \begin{center}\begin{tikzpicture}[thick]
  \draw[-latex] (-1,0) -- (-0.025,0);
  \draw[-latex] ( 1,0) -- ( 0.025,0);
  \draw[fill=white] (0,0) circle (0.075);
  \end{tikzpicture}\end{center}
}

\begin{document}
\oldsep
\tableofcontents
\addtocontents{toc}{\protect\oldsep}
\end{document}

enter image description here

1
  • Thank you for pointing this out. I've also taken this opportunity to learn a little about the \protect command. Thanks again. Jul 23 at 19:41

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.