5

As for my thesis, I asked today here but I still cannot use it because there are other packages and commands I need to modify the tables of contents. So here is the full minimum working template. I just want to make the chapter title in tocs to be All capital letters like "IV. TEST". Sorry for the long one.

 %!TEX TS-program = pdflatex
 \documentclass[fontsize=12pt]{report}
 \usepackage{mathptmx}
\usepackage{graphicx}
\usepackage[svgnames]{xcolor}
\usepackage{amssymb}
\usepackage{tocloft}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{indentfirst}
\usepackage[showframe,paperwidth=8.5in,paperheight=11in,top=1in,textwidth=5.8in,bottom=1in,left=1.25in,right=1.25in,footskip=0.3in]{geometry}% This is the page layout.
\usepackage{titling}
\usepackage{setspace}
\usepackage{afterpage}

\newif\ifintoc

\newcommand*{\PrintChapterTocHeadline}
{\hbox to \linewidth{\textbf{Chapter}\hfill\textbf{Page}}\bigskip
        \SetupNextPageOne}

\newcommand*{\SetupNextPageOne}
{\afterpage {\ifintoc\PrintChapterTocHeadline\fi}}

\addtocontents{toc}{\protect\PrintChapterTocHeadline}

\newif\ifinlof

\newcommand*{\PrintChapterLofHeadline}
    {\hbox to \linewidth{\textbf{Figure}\hfill\textbf{Page}}\bigskip
     \SetupNextPage}

\newcommand*{\SetupNextPage}
    {\afterpage {\ifinlof\PrintChapterLofHeadline\fi}}

\addtocontents{lof}{\protect\PrintChapterLofHeadline}


\renewcommand{\contentsname}{\fontsize{16pt}{18pt}\selectfont {\centerline{TABLE OF CONTENTS}}}
\renewcommand{\listfigurename}{\fontsize{16pt}{18pt}\selectfont {\centerline{LIST OF FIGURES}}}
\renewcommand{\cftchapfont}{\bfseries\MakeUppercase}
\makeatletter
\renewcommand*\l@chapter{\@dottedtocline{0}{1em}{2.3em}}
\renewcommand*\l@section{\@dottedtocline{1}{3.3em}{2.3em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{5.6em}{2.3em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}}
\makeatother     \usepackage[pdftex,colorlinks,bookmarksnumbered,citecolor=blue,linkcolor=magenta,menucolor=black,pdftoolbar=false,urlcolor=DeepSkyBlue,pdftitle={Comprehensive Exam},pdfauthor={Thein Htay Oo},pdfsubject={Physics},pdfstartview=Fit,pdfdisplaydoctitle=true,pdfpagelayout=SinglePage]{hyperref}


\usepackage{titlesec}
\makeatletter
\def\ttl@mkchap@i#1#2#3#4#5#6#7{%
      \ttl@assign\@tempskipa#3\relax\beforetitleunit
      \vspace{-\@tempskipa}%<<<<<< REMOVE THE * AFTER \vspace
      \global\@afterindenttrue
      \ifcase#5 \global\@afterindentfalse\fi
      \ttl@assign\@tempskipb#4\relax\aftertitleunit
      \ttl@topmode{\@tempskipb}{%
          \ttl@select{#6}{#1}{#2}{#7}}%
      \ttl@finmarks  % Outside the box!
      \@ifundefined{ttlp@#6}{}{\ttlp@write{#6}}}
\makeatother
   \usepackage{etoolbox}

\makeatletter
\pretocmd{\@sect}{\singlespacing}{}{}
\pretocmd{\@ssect}{\singlespacing}{}{}
\apptocmd{\@sect}{\doublespacing}{}{}
\apptocmd{\@ssect}{\doublespacing}{}{}
\makeatother


\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand \thesection{\arabic{chapter}.\arabic{section}}
\renewcommand \thesubsection{\arabic{chapter}.\arabic{section}.\arabic{subsection}}


   \renewcommand{\familydefault}{\rmdefault}
 \titleformat*{\section}{\singlespacing\fontsize{14}{18}\bfseries\rmfamily} 
 \titleformat*{\subsection}{\singlespacing\fontsize{12}{14}\bfseries\rmfamily}


 \titleformat{\chapter}[display] {\singlespacing\rmfamily\fontsize{16pt}{19pt}\bfseries}
    {\MakeUppercase{\chaptertitlename\ \thechapter}\filcenter}{10pt}{\centering\uppercase}
    {\fontsize{14pt}{16pt}\filcenter}   

 \titlespacing*{\chapter}{0pt}{0pt}{30pt}



\doublespacing


\renewcommand\thefigure{\arabic{chapter}.\arabic{figure}}


\begin{document}
\pagenumbering{Roman}
\begin{center}
\topskip0pt
\vspace*{\fill}
   ype dedication here, if any. Otherwise, delete this page.
\vspace*{\fill}
\end{center}
\pagebreak
\restoregeometry


\begingroup\intoctrue
\setlength{\cftbeforetoctitleskip}{-2.5em}
\tableofcontents
\endgroup

\begingroup\inloftrue
\newpage
\setlength{\cftbeforeloftitleskip}{-2.5em}
\listoffigures
\endgroup

\restoregeometry
\newpage

\setcounter{page}{1}
\pagenumbering{arabic}

\chapter{test}
\section{Test}
\section{Test}
\chapter{Test}
\section{Test}
\begin{figure}
\caption{ms expected.}
\end{figure}
\begin{figure}
\caption{ms expected.}
\end{figure}
\begin{figure}
\caption{ms expected.}
\end{figure}
\chapter{Test}
\section{Test}
\section{Test}
\section{Test}
\chapter{test}
\section{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\end{document}
6
  • Please check your code compiles before posting. Yours will not! You don't need graphicx twice. You probably should not use geometry with scrreport. (In addition to the comments on the other post re. incompatibilities.) Could you explain why you can't use that solution? What happens?
    – cfr
    Commented Feb 18, 2014 at 2:57
  • Also titlesec is incompatible with hyperref according to hyperref. Could you simplify your configuration by using koma-script packages and config where possible? For example, could you use tocstyle to format the list of figures? And similarly to replace geometry etc.? I suggest this because I think it is going to be hard to keep control of things with so many incompatible packages flying around. I guess the main issue is hyperref. But things like titlesec sit badly with several other things you are using.
    – cfr
    Commented Feb 18, 2014 at 3:24
  • @cfr Sorry about that. I re-edited it. Now I am only using report. I am a beginner in latex. So I don't know how to edit scrreport. I still use titlesec because my thesis format needs every chapter title to be 1.5 inches from the edge of the page. If I don't use titlesec, it still leave some space above the chapter title.
    – Aung
    Commented Feb 18, 2014 at 4:45
  • titlesec should be fine with report though hyperref says it is incompatible. Also, report will be fine with geometry etc. I think report is probably a better choice here as it will be less likely to compete with your customisation.
    – cfr
    Commented Feb 18, 2014 at 15:07
  • @cfr: geometry can be used with KOMA-Script. One should leave out DIV option and other typearea things then.
    – Speravir
    Commented Feb 19, 2014 at 17:53

1 Answer 1

7

You need to redefine the macro \@chapter in this way (since you're loading hyperref)

\makeatletter      
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}\texorpdfstring{\uppercase{#1}}{#1}}%
                    \else
                      \addcontentsline{toc}{chapter}{\texorpdfstring{\uppercase{#1}}{#1}}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
\makeatother

(Not so) minimal example:

 %!TEX TS-program = pdflatex
 \documentclass[12pt]{report}
 \usepackage{mathptmx}
\usepackage{graphicx}
\usepackage[svgnames]{xcolor}
\usepackage{amssymb}
\usepackage{tocloft}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{indentfirst}
\usepackage[showframe,paperwidth=8.5in,paperheight=11in,top=1in,textwidth=5.8in,bottom=1in,left=1.25in,right=1.25in,footskip=0.3in]{geometry}% This is the page layout.
\usepackage{titling}
\usepackage{setspace}
\usepackage{afterpage}

\newif\ifintoc

\newcommand*{\PrintChapterTocHeadline}
{\hbox to \linewidth{\textbf{Chapter}\hfill\textbf{Page}}\bigskip
        \SetupNextPageOne}

\newcommand*{\SetupNextPageOne}
{\afterpage {\ifintoc\PrintChapterTocHeadline\fi}}

\addtocontents{toc}{\protect\PrintChapterTocHeadline}

\newif\ifinlof

\newcommand*{\PrintChapterLofHeadline}
    {\hbox to \linewidth{\textbf{Figure}\hfill\textbf{Page}}\bigskip
     \SetupNextPage}

\newcommand*{\SetupNextPage}
    {\afterpage {\ifinlof\PrintChapterLofHeadline\fi}}

\addtocontents{lof}{\protect\PrintChapterLofHeadline}


\renewcommand{\contentsname}{\fontsize{16pt}{18pt}\selectfont {\centerline{TABLE OF CONTENTS}}}
\renewcommand{\listfigurename}{\fontsize{16pt}{18pt}\selectfont {\centerline{LIST OF FIGURES}}}
\renewcommand{\cftchapfont}{\bfseries\MakeUppercase}
\makeatletter
\renewcommand*\l@chapter{\@dottedtocline{0}{1em}{2.3em}}
\renewcommand*\l@section{\@dottedtocline{1}{3.3em}{2.3em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{5.6em}{2.3em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}}
\makeatother     \usepackage[pdftex,colorlinks,bookmarksnumbered,citecolor=blue,linkcolor=magenta,menucolor=black,pdftoolbar=false,urlcolor=DeepSkyBlue,pdftitle={Comprehensive Exam},pdfauthor={Thein Htay Oo},pdfsubject={Physics},pdfstartview=Fit,pdfdisplaydoctitle=true,pdfpagelayout=SinglePage]{hyperref}


\usepackage{titlesec}
\makeatletter
\def\ttl@mkchap@i#1#2#3#4#5#6#7{%
      \ttl@assign\@tempskipa#3\relax\beforetitleunit
      \vspace{-\@tempskipa}%<<<<<< REMOVE THE * AFTER \vspace
      \global\@afterindenttrue
      \ifcase#5 \global\@afterindentfalse\fi
      \ttl@assign\@tempskipb#4\relax\aftertitleunit
      \ttl@topmode{\@tempskipb}{%
          \ttl@select{#6}{#1}{#2}{#7}}%
      \ttl@finmarks  % Outside the box!
      \@ifundefined{ttlp@#6}{}{\ttlp@write{#6}}}
\makeatother
   \usepackage{etoolbox}

\makeatletter
\pretocmd{\@sect}{\singlespacing}{}{}
\pretocmd{\@ssect}{\singlespacing}{}{}
\apptocmd{\@sect}{\doublespacing}{}{}
\apptocmd{\@ssect}{\doublespacing}{}{}
\makeatother


\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand \thesection{\arabic{chapter}.\arabic{section}}
\renewcommand \thesubsection{\arabic{chapter}.\arabic{section}.\arabic{subsection}}


   \renewcommand{\familydefault}{\rmdefault}
 \titleformat*{\section}{\singlespacing\fontsize{14}{18}\bfseries\rmfamily}
 \titleformat*{\subsection}{\singlespacing\fontsize{12}{14}\bfseries\rmfamily}


 \titleformat{\chapter}[display] {\singlespacing\rmfamily\fontsize{16pt}{19pt}\bfseries}
    {\MakeUppercase{\chaptertitlename\ \thechapter}\filcenter}{10pt}{\centering\uppercase}
    {\fontsize{14pt}{16pt}\filcenter}

 \titlespacing*{\chapter}{0pt}{0pt}{30pt}



\doublespacing


\renewcommand\thefigure{\arabic{chapter}.\arabic{figure}}

\makeatletter
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}\texorpdfstring{\uppercase{#1}}{#1}}%
                    \else
                      \addcontentsline{toc}{chapter}{\texorpdfstring{\uppercase{#1}}{#1}}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
\makeatother

\begin{document}
\pagenumbering{Roman}
\begin{center}
\topskip0pt
\vspace*{\fill}
   ype dedication here, if any. Otherwise, delete this page.
\vspace*{\fill}
\end{center}
\pagebreak
\restoregeometry


\begingroup\intoctrue
\setlength{\cftbeforetoctitleskip}{-2.5em}
\tableofcontents
\endgroup

\begingroup\inloftrue
\newpage
\setlength{\cftbeforeloftitleskip}{-2.5em}
\listoffigures
\endgroup

\restoregeometry
\newpage

\setcounter{page}{1}
\pagenumbering{arabic}

\chapter{test}
\section{Test}
\section{Test}
\chapter{Test}
\section{Test}
\begin{figure}
\caption{ms expected.}
\end{figure}
\begin{figure}
\caption{ms expected.}
\end{figure}
\begin{figure}
\caption{ms expected.}
\end{figure}
\chapter{Test}
\section{Test}
\section{Test}
\section{Test}
\chapter{test}
\section{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\chapter{Test}
\section{Test}
\end{document} 

Output (ToC):

enter image description here

3
  • @ karlkoeller. Thanks . This is really helpful. Hope I am almost done with my thesis template. Can I pass this command \renewcommand\cftchapaftersnum{.} or any thing equivalent to it so that it is "II." instead of "II"? Thanks,
    – Aung
    Commented Feb 18, 2014 at 7:20
  • @Aung No, you have a little mess in your settings. To achieve this, change \protect\numberline{\thechapter} to \protect\numberline{\thechapter.} Commented Feb 18, 2014 at 8:07
  • 1
    if there's any math in any of the chapter titles, \uppercase may not give you what you want or expect. Commented Feb 18, 2014 at 14:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .