0

I am new to LaTeX.

Using: \usepackage[title,toc,titletoc,page]{appendix}

My LaTeX:

\documentclass[a4paper,svgnames,11pt]{article}

\usepackage[title,toc,titletoc,page]{appendix} \usepackage{listings}

\begin{document} \tableofcontents \addtocontents{toc}{\protect\thispagestyle{empty}} \glsaddall

\newpage \appendix \renewcommand{\thesubsection}{\appendixname}{\Alph{subsection}} \setcounter{section}{0}

\begin{appendices}

\subsection{Projects} \subsection{Interview} \subsection{Data} \subsection{Samples} \end{appendices} \end{document}

Results in: enter image description here

Not sure how this can be resolved and fixed with formatting.

EDIT: Followed the following sample, https://gist.github.com/X4/7759575

  • 1
    Welcome to TEX.SE! Please provide a full minimal working example which reproduces the issue, possibly starting with \documentclass{...} and ending with \end{document}. This being said, what are you trying to do with \renewcommand{\thesubsection}{\appendixname}{\Alph{subsection}}? \renewcommand takes only two arguments. – campa Nov 02 '21 at 12:11
  • 1
    Please double check the {}'s in that sample with the number you use. The sample you refer to is correct, yours is not. – daleif Nov 02 '21 at 12:54
  • @daleif, I tried this. \renewcommand{\thesubsection}{\appendixname~\Alph{subsection}} – John Smith Nov 02 '21 at 12:56
  • 1
    the second problem is that there is not enough room for \thesubsection inside \numberline. There should be a way to adjust \numberline using titletoc. I know it can be changed by NOT using titletoc. – John Kormylo Nov 02 '21 at 13:02
  • @JohnKormylo, how exactly?? – John Smith Nov 02 '21 at 13:03

2 Answers2

0

Found this:

\makeatletter
\newrobustcmd{\fixappendix}{%
  \patchcmd{\l@subsection}{2.3em}{5.6em}{}{}%
}

Source: LaTeX: iopart and overlapping appendices

  • Welcome to TeX.SX! In order to make this a proper answer, please consinder adding a comment on how to use the above code snippet. – Jasper Habicht Nov 02 '21 at 15:44
  • @JasperHabicht, I marked the other dude's response as an answer. As that also works. – John Smith Nov 03 '21 at 12:04
  • No idea what that does or how to use it until I looked at your referenced source which was clear unlike your suggestion above. You only took code from one of the answers which seems a bit unfair. If you want to provide an answer please provide a complete one not an unusable snippet. – Peter Wilson Nov 03 '21 at 18:36
0

The width for \numberline is normally passed using \@tempdima which is set locally. To change the width in the middle of the toc requires the use of \addtocontents.

\documentclass[a4paper,svgnames,11pt]{article}

\usepackage[title,toc,titletoc,page]{appendix} \usepackage{listings}

\newlength{\appwidth} \settowidth{\appwidth}{\appendixname} \makeatletter \newcommand{\resetnumberline}{\def\numberline##1{% \advance@tempdima by \appwidth \hb@xt@@tempdima{##1\hfil}}} \makeatother

\begin{document} \tableofcontents \addtocontents{toc}{\protect\thispagestyle{empty}} %\glsaddall

\newpage \subsection{test} \appendix \renewcommand{\thesubsection}{\appendixname~\Alph{subsection}}% \setcounter{section}{0}% \addtocontents{toc}{\string\resetnumberline}%

\begin{appendices}

\subsection{Projects} \subsection{Interview} \subsection{Data} \subsection{Samples} \end{appendices} \end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120