TransWikia.com

How can I fix iupac related alignment issues in TOC?

TeX - LaTeX Asked by wewa on March 15, 2021

Please have a look at the following picture of my TOC. You can see that there is an alignment issue with subsubsection 1.1.1 and subsubsection 1.1.2. The corresponding page number of subsubsection 1.1.1 is exceeding the right text limits and also the text right of 1.1.2 is exceeding the page limits.

enter image description here

I have to mention, that IPAC nomenclature iupac{TEXT-HERE} is used here (also for the subsubsection heading of 1.1.1 and 1.1.2), to support correct hyphenation. Here is the minimal code sample which can be used to reconstruct this issue.

% Preview source code

%% LyX 2.3.6 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
documentclass[12pt,english]{article}
renewcommand{familydefault}{sfdefault}
usepackage[T1]{fontenc}
usepackage[latin9]{inputenc}
usepackage{geometry}
geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=3cm,rmargin=2.5cm}
setlength{parskip}{medskipamount}
setlength{parindent}{0pt}
usepackage{setspace}
onehalfspacing

makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
% --------- use tocloft package to format listings --------
usepackage{tocloft}
renewcommand{@cftmaketoctitle}{} % remove automatically generated toc heading
% ---------------------------------------------------------

usepackage{chemmacros} % e.g. to support hyphenation for chemical names

makeatother

usepackage{babel}
begin{document}

section*{Table of Contents}

addcontentsline{toc}{section}{Table of Contents}

tableofcontents{}

section{Section 1}

subsection{Subsection 1}

subsubsection{iupac{0,0'-((0-Loremipsumdol)Loremipsu)lor(0-(lore-lorem)-0-loremipsumdo)}
(00)}

subsubsection{iupac{0,0-Lo-lore-lorem-0-loremip-00-(0-loremipsumdol)-0,00-loremips-00L-loremmm[a,a][0,0,0]loremipsumloremi 0-lorem}
(00)}

subsection{Subsection 2}

subsubsection{Subsubsection}
end{document}

What can I do, so that 1.1.1 and 1.1.2 comply with the text limits in my TOC?

One Answer

You could set the toc headings ragged

enter image description here

I just added one line to add fill glue as marked

% Preview source code

%% LyX 2.3.6 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
documentclass[12pt,english]{article}
renewcommand{familydefault}{sfdefault}
usepackage[T1]{fontenc}
usepackage[latin9]{inputenc}
usepackage{geometry}
geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=3cm,rmargin=2.5cm}
setlength{parskip}{medskipamount}
setlength{parindent}{0pt}
usepackage{setspace}
onehalfspacing

makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
% --------- use tocloft package to format listings --------
usepackage{tocloft}
renewcommand{@cftmaketoctitle}{} % remove automatically generated toc heading
% ---------------------------------------------------------

usepackage{chemmacros} % e.g. to support hyphenation for chemical names

edef@tocrmarg{@tocrmarg plus 2 cm}%<<<<<<<<<<<<<<<<<<<<<<
makeatother

usepackage{babel}
begin{document}

section*{Table of Contents}

addcontentsline{toc}{section}{Table of Contents}

tableofcontents{}

section{Section 1}

subsection{Subsection 1}

subsubsection{iupac{0,0'-((0-Loremipsumdol)Loremipsu)lor(0-(lore-lorem)-0-loremipsumdo)}
(00)}

subsubsection{iupac{0,0-Lo-lore-lorem-0-loremip-00-(0-loremipsumdol)-0,00-loremips-00L-loremmm[a,a][0,0,0]loremipsumloremi 0-lorem}
(00)}

subsection{Subsection 2}

subsubsection{Subsubsection}
end{document}

Correct answer by David Carlisle on March 15, 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