1

I need to add a dash after appendix item's letter. It does need to appear on summary. I've tried to adding on the section title but the dash appear too far apart from the appendix letter. Below follows the code:

\documentclass{article}
\usepackage[titletoc,toc,title]{appendix}
\usepackage{newtxtext,newtxmath} % Times New Roman with serif

\begin{document}
\tableofcontents

\section{Dolor sit amet}
Have a look at \ref{app:foobar}

\begin{appendices}
  \renewcommand\thetable{\thesection\arabic{table}}
  \renewcommand\thefigure{\thesection\arabic{figure}}
  \section{-- Consectetur adipiscing elit} \label{app:foobar}
    \begin{table}[h]
    \caption{foo}
    \begin{tabular}{cc}
    \textbf{ a } & \textbf{ b }\\
    1 & 3 \\
    2 & 4\\
    \end{tabular}
    \end{table}
  \section{Mauris euismod}
\end{appendices}
\end{document}
2
  • Shall this dash appear in any appendix section? – user31729 Jan 18 '18 at 8:25
  • The easiest way would be \renewcommand{\thesection}{\Alph{section}\ -- \ } for most of appendix parts, but this would leave a trailing -- in the cross-references, which is ugly and most certainly not wanted – user31729 Jan 18 '18 at 8:51
2

Like this?

\@seccntformat is responsible for the typesetting of the section etc title numbers, it adds a \quad space after the number, as such \section{-- foo} places the dash too far to the right.

Redefinition of \@seccntformat with a wrapper macro \mydash replaces the \quad by \csname the#1\endcsname\ \mydash\ }, where #1 is replaced by the relevant counter name, i.e. section, subsection, this means that all section levels will get this dash now.

The addition to the ToC either requires patching \@sect or using tocloft and writting the dash to the number box with \cftsecaftersnumb.

\documentclass{article}
\usepackage[titletoc,toc,title]{appendix}
\usepackage{tocloft}
\usepackage{newtxtext,newtxmath} % Times New Roman with serif
\newcommand{\mydash}{--}


\begin{document}
\tableofcontents

\section{Dolor sit amet}
Have a look at \ref{app:foobar}

\begin{appendices}
  \makeatletter
     % Changing the width of `Appendix A` in the ToC
    \addtocontents{toc}{\protect\setlength{\protect\cftsecnumwidth}{10pt}}
   % Adding the `-` before the sectiont title in the ToC
   \addtocontents{toc}{\protect\renewcommand{\protect\cftsecaftersnumb}{\protect\mydash\ }}
  %\addtocontents{toc}{\protect\renewcommand{\protect\cftsubsecaftersnumb}{\protect\mydash\ }} % If needed
  \renewcommand{\@seccntformat}[1]{\csname the#1\endcsname\ \mydash\ }
  \renewcommand\thetable{\thesection\arabic{table}}
  \renewcommand\thefigure{\thesection\arabic{figure}}
  \section{Consectetur adipiscing elit}  \label{app:foobar}
  \makeatother

    \begin{table}[h]
    \caption{foo}
    \begin{tabular}{cc}
    \textbf{ a } & \textbf{ b }\\
    1 & 3 \\
    2 & 4\\
    \end{tabular}
    \end{table}
  \section{Mauris euismod}
\end{appendices}
\end{document}

enter image description here

2
  • Yes, but it must appear on summary or list of contents as well. Thank you Christian for the quick reply. – Rinaldi Segecin Jan 18 '18 at 8:34
  • @RinaldiSegecin: See the update, please. Choose the spacings as you like, i.e. other than the 10pt I have applied in there – user31729 Jan 18 '18 at 8:48

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.