2

I have added a colon to Appendix in the toc using the following command.

\apptocmd{\appendices}{\apptocmd{\thesection}{:}{}{}}{}{}

Due to this, in the list of figures section, I am getting something like the following

Figure B:.1 

when it should have been just

Figure B.1

Here is the image of my list of figures, showing images from appendices. I want the ":" removed from there, since the format looks funky.

Here is my MWE but more like my whole document.

  • Can you explain what's your intent? – egreg Nov 2 '14 at 15:57
  • I want the colons on the appendices as they appear in the table of contents, but the colon is appearing in the list of figures when the images in the appendices are referenced there. – tilaprimera Nov 2 '14 at 16:10
  • Normally there are no colons in the for appendices. If you change the definition of \thesection, it's quite natural to get : everywhere where \thesection is used, i.e. in the output of \listoffigures too. – user31729 Nov 2 '14 at 16:15
  • I have edited the question and added an image. – tilaprimera Nov 2 '14 at 16:15
  • Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Nov 2 '14 at 16:17
1

A 'quick' solution could be, to store the definition of \thesection right after \appendices start, then use the old definition in the figure environment, since this is a group and append the : to the `\thesection. Since the figure environment is a group, the old definition will only be used for figure references/captions.

Basically the same has to be done for tables, but I omitted this here.

\documentclass[12pt, a4paper]{article}

\title{\textbf{Laser Pointer Based Human-Computer-Interaction using Computer-Vision}}
\usepackage{times}
\usepackage[top=3.5cm, bottom=2cm, left=3.5cm, right=2cm]{geometry}
\usepackage{sectsty}
\sectionfont{\fontsize{14}{12}\selectfont}
\usepackage{float}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{listings}
\usepackage{hyperref}
\usepackage{mathtools}
\usepackage{pgfgantt}
\usepackage{tocloft}
\usepackage{tocbibind}
\usepackage{indentfirst}
\usepackage{mathtools}
\usepackage{acronym}
\usepackage[acronym]{glossaries}
\usepackage[utf8x]{inputenc}
\usepackage{subcaption}
\usepackage{chngcntr}
\usepackage[titletoc,title]{appendix}
\counterwithin{table}{section}
\counterwithin{figure}{section}
\counterwithin{equation}{section}
\renewcommand{\cftfigfont}{\text{Figure} }
\renewcommand{\appendixname}{APPENDIX}
\renewcommand{\contentsname}{TABLE OF CONTENTS}
\renewcommand{\listfigurename}{LIST OF FIGURES}
\renewcommand{\listtablename}{LIST OF TABLES}
\renewcommand\cftsecleader{\cftdotfill{\cftdotsep}}
\usepackage{etoolbox}


\apptocmd{\appendices}{\let\LaTeXStandardTheSection\thesection%
\apptocmd{\figure}{\let\thesection\LaTeXStandardTheSection}{}{}
\apptocmd{\thesection}{:}{}{}}{}{}




\begin{document}

\listoffigures

\section{First section}
\begin{figure}
\caption{First}
\end{figure}



\begin{appendices}



\section{First appendix}

\begin{figure}
\caption{First of Appendix}
\end{figure}

\subsection{First appendix subsection}

\begin{figure}
\caption{First of Appendix subsection}
\end{figure}



\end{appendices}



\end{document}

enter image description here

  • I used your way, It works neatly! – tilaprimera Nov 2 '14 at 16:56
  • @tilaprimera: Thanks, but look for A:.1 First appendix subsection... The A:.1 does not look nice -- it's a consequence of redefining the \thesection – user31729 Nov 2 '14 at 16:57
  • I do not have a subsection under a section. This crazy university format is driving me nuts, I would prefer a toc without colons, life would be pretty simpler without the colons. Thanks again! I hope I do not have to put the colons! : ) – tilaprimera Nov 2 '14 at 17:07
1

If your intent is that subsections are typeset like

A: Title

you should use a different approach.

\documentclass{article}
\usepackage{appendix}
\usepackage{chngcntr}
\usepackage{etoolbox}

\makeatletter
\newcommand\colon@seccntformat[1]{\csname the#1\endcsname: }
\apptocmd{\appendices}{\let\@seccntformat\colon@seccntformat}{}{}
\makeatother

\counterwithin{figure}{section}

\begin{document}
\tableofcontents
\listoffigures
\section{A title}

some words

\begin{figure}[htp]
OK
\caption{A}
\end{figure}

\begin{appendices}
\section{Something as appendix}

\begin{figure}[htp]
OK
\caption{B}
\end{figure}

some text
\end{appendices}

\end{document}

enter image description here

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.