TransWikia.com

Alignment of appendix tables in list of tables (lot)

TeX - LaTeX Asked by Easystyle on July 30, 2021

For my dissertation, I need to create a list of tables containing both tables from the main chapters and the corresponding appendices to each chapter. For each appendix table, a capital A is set before the chapter and section number to distinguish them from the tables in the main body. Unfortunately, this setup results in a misalignment of the table numbers in the list of tables, in addition to overlapping with the table titles for appendix tables 10+ (as shown below).

enter image description here

Ideally, I would have all the tables align along the dot within the list of tables. I have looked at the tocloft package, but have not been able to figure out how to reduce the left indentation for the appendix tables only. I have also tried to follow an approach similar to this allowing the A to have zero width in the list of tables, but I could never successfully get it to run.

Any help would be much appreciated. Below is the code to generate the above image.

documentclass[11pt,oneside,english,doublespacing,liststotoc,toctotoc]{MastersDoctoralThesis}%
begin{document}

listoftables

chapter{1}

section{1}

begin{table}
caption{Table}%
label{table1}
end{table}

section*{Appendix}
setcounter{table}{0}
renewcommand{thetable}{Athechapter.arabic{table}}

begin{table}
caption{Table in appendix}%
label{tablea1}
end{table}

setcounter{table}{9}

begin{table}
caption{Another table in appendix}%
label{tablea10}
end{table}

end{document} 

Update:

Ok, I was able to repurpose the above mentioned approach for table number alignment within a list of tables (see image and code below).

enter image description here

documentclass[11pt,oneside,english,doublespacing,liststotoc,toctotoc]{MastersDoctoralThesis}%
usepackage{xparse}
usepackage{kantlipsum}

NewDocumentCommand{optionaltable}{O{#3}om}{%
  renewcommand{thetable}{optastandardthetable}%
  optzerotrue
  IfNoValueTF{#2}{table[#1]{#3}}{table[#1][#2]{#3}}%
  optzerofalse
  renewcommand{thetable}{standardthetable}%
}
AtBeginDocument{letstandardthetablethetable}

NewDocumentCommand{opta}{}{%
  ifoptzeromakebox[0pt][r]{A}else Afi
}
newififoptzero

begin{document}

optzerotrue
listoftables
optzerofalse

chapter{1}

section{1}

begin{table}
caption{Table}%
label{table1}
end{table}

section*{Appendix}
setcounter{table}{0}
renewcommand{thetable}{optastandardthetable}

begin{table}
caption{Table in appendix}%
label{tablea1}
end{table}

setcounter{table}{9}

begin{table}
caption{Another table in appendix}%
label{tablea10}
end{table}

end{document} 

I am still not too sure what the code is exactly doing, especially the following part:

NewDocumentCommand{optionaltable}{O{#3}om}{%
  renewcommand{thetable}{optastandardthetable}%
  optzerotrue
  IfNoValueTF{#2}{table[#1]{#3}}{table[#1][#2]{#3}}%
  optzerofalse
  renewcommand{thetable}{standardthetable}%
}

Nevertheless, this will do for my purpose now.

One Answer

I don't think that tocloft will help with your alignment problem but try the MWE below (changed the documentclass to book because the class you used I didn't have access to).

% apptocprob.tex SE 546892

%documentclass[11pt,oneside,english,doublespacing,liststotoc,toctotoc]{MastersDoctoralThesis}%
documentclass{book}
usepackage{tocloft}
setlength{cfttabnumwidth}{3em} % choose this to suit

begin{document}

listoftables

renewcommand{thetable}{phantom{A}thechapter.arabic{table}}
chapter{1}

section{1}

begin{table}
caption{Table}%
label{table1}
end{table}

section*{Appendix}
setcounter{table}{0}
renewcommand{thetable}{Athechapter.arabic{table}}

begin{table}
caption{Table in appendix}%
label{tablea1}
end{table}

setcounter{table}{9}

begin{table}
caption{Another table in appendix}%
label{tablea10}
end{table}

end{document} 

I have used tocloft to make extra space for long table numbers. In the body of the document I have changed the regular table numbering to include a space equivalent to A before the number. This all works, at least in the LoT.

Answered by Peter Wilson on July 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP