0

I am creating a document displaying rules. I have managed to change the name of "Chapter" to "Article" and only have one more wish, which is to change the way the table of contents displays the different "articles" (chapters).

Instead of writing

1 NAME OF ARTICLE 1

A NAME OF APPENDIX 1

and so on, I want it to display

ARTICLE 1 "NAME OF ARTICLE 1"

APPENDIX 1 "NAME OF APPENDIX 1"

Here is the relevant code so far:

\documentclass[a4paper,11pt]{report}
%%% Packages %%%
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{appendix}   % Adds appendix. 

%%% New commands %%%
\addto\captionsenglish{%
 \renewcommand\chaptername{Article}}
\renewcommand{\rmdefault}{cmr}  % Changes the font. 

\begin{document}

\tableofcontents
\newpage
\input{article-A.tex}
\input{article-B.tex}
\input{article-C.tex}
\input{article-D.tex}
\input{article-E.tex}
\input{article-F.tex}
\input{article-G.tex}
\input{article-H.tex}
\input{article-I.tex}
\input{article-J.tex}
\input{article-K.tex}
\input{article-L.tex}
\input{article-M.tex}
\input{article-N.tex}

\appendix
\input{appendix1.tex}
\input{appendix2.tex}
\input{appendix3.tex}

I hope everything is explained clearly, otherwise please ask and I'll be more specific.

Any suggestions are greatly appreciated.

EDIT: Solved with the help of the comment. I used the link providing a similar solution.

I inserted this in my preamble:

\usepackage{tocloft}
\usepackage{etoolbox}
\apptocmd{\appendix}
  {\addtocontents{toc}{%  
   \protect\addtolength\protect\cftchapnumwidth{-\mylength}%
   \protect\renewcommand{\protect\cftchappresnum}{Appendix~}%
   \protect\settowidth\mylength{\bfseries\protect\cftchappresnum\protect\cftchapaftersnum}%
   \protect\addtolength\protect\cftchapnumwidth{\mylength}}%
  }{}{}

\newlength\mylength

\renewcommand\cftchappresnum{Article~}
\settowidth\mylength{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylength}

And it worked perfectly :)

user38934
  • 636

0 Answers0