0

NOTE: this question was answered below by Jhor, and the class file that I link to below has now been fixed, so the problem is no longer reproducible.

I am using a class that was created for my university's dissertation requirements, which is freely available at https://github.com/lotten/uci-thesis-latex/blob/master/ucithesis.cls

My problem is with chapter titles that are too long to fit on a single line in the table of contents. The TOC entry for such titles ends up aligned ragged left, which looks strange, so I would like them to be ragged right instead. You can see this clearly in the minimum working example I included below, but it requires having the ucithesis.cls from the link above.

% Minimum working example
\documentclass{ucithesis}
\begin{document}
\tableofcontents
\chapter{This chapter title fits on one line and is aligned to the left, as I want it}
\chapter{This chapter title is too long to fit on one line in the table of contents, and 
requires multiple lines, so the text gets aligned to the right, and the ragged left looks 
very strange. I would like for this text to be left aligned and ragged right instead. The 
last line appears centered, which I don't necessarily mind, as long as all of the other 
lines are aligned to the left.}
\end{document}

Note: the example contains a very long title which I used to clarify what is going on. In actuality, my longest chapter title is less than 1.5 lines. But it still looks weird to have the TOC entries not start all the way on the left.

Ideally, I am hoping to find a solution that does not involve any additional packages. I was able to get the results I wanted with

\usepackage{tocstyle}
\usetocstyle{standard}

but it came along with some very verbose warnings about the tocstyle package being an alpha version, including the admonition

Maybe it would be better, not to load this package.

Thanks in advance for any help or suggestions!

  • 2
    Personally I don't think a chapter title should be more than one line long. – user156344 Apr 11 at 5:14
  • Most of the chapters are already published papers, and I need to keep the same titles. The lengths of the titles are within the normal range for the journals they are published in. – alkalifly Apr 11 at 5:18
  • Yeah, that is only my suggestion. It is not usual to see a chapter title as long as a paragraph. – user156344 Apr 11 at 5:19
  • The super long title in my example was just to illustrate what's happening. My actual titles are only a little longer than a single line. – alkalifly Apr 11 at 5:21
  • Maybe with titeltoc? Add e.g. \usepackage{titletoc} \titlecontents{chapter} [3.8em] {} {\contentslabel{2.3em}} {\hspace*{-2.3em}} {\titlerule*[1pc]{.}\contentspage} to the preamble of your document. – user121799 Apr 11 at 5:21
0

Your problem comes from the following lines in the class:

\addtocontents{toc}{\protect\raggedleft Page\\}
\addtocontents{lof}{\protect\raggedleft Page\\}
\addtocontents{lot}{\protect\raggedleft Page\\}
\addtocontents{loa}{\protect\raggedleft Page\\}

Which is bad coded. To fix this you could either suppress these lines, or if you should keep the "Page" caption replace on each line the problematic

{\protect\raggedleft Page\\}

by

{{\protect\flushright Page\par}}

I'm not sure that the \protect is needed here.

Another option is to replace {\protect\raggedleft Page\\} by {\hfill Page\\}

  • Thank you very much! That is exactly the solution I was hoping for. Apparently, I don't have enough reputation to vote your answer up, but I am very appreciative of your help. – alkalifly Apr 11 at 7:36

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.