1

I am using a custom calss called ufpethesis, based on the book class, to format my masters thesis.

My aim is to insert the chapter numbering to the left of the chapter title, have it aligned to the left margin and preserve the custom headerline.

I have attempted to change the \@makechapterhead and \@makeschapterhead as well as subsections definitions, as pointed out in a related post How to format the chapter heading?. Here follows my attempt's output (to the left) and the original output (to the right).

make

As you can see, I have introduced some space when I tried to insert the chapter numbering, shifting both the headerline and chapter title to the right. The same happens in the starred version of the command:

makes

Any ideas on how to fix this?

Here's my MWE:

\documentclass[oneside,msc]{ufpethesis}

\usepackage{lipsum}

\makeatletter
\def\thickhrule{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\position{\centering}

\renewcommand{\@makechapterhead}[1]{
\global\topskip 1.5pc
  \relax
  \begingroup
  \ignorespaces
  \LARGE\bfseries \thechapter\enspace 
    \ifnum\c@secnumdepth>\m@ne
      \leavevmode \hskip-\leftskip 
      \rlap{\vbox to\z@{\vss
          \centering\large\sc{\chaptername}\enspace\thechapter
          \vskip2.5pc}}\hskip\leftskip\fi
     #1\par \endgroup
  \skip@4pc \advance\skip@-\normalbaselineskip
  \vskip\skip@ }  


\def\@makeschapterhead#1{
\global\topskip 1.5pc\relax
  \begingroup
  \LARGE\bfseries %\centering
   #1\par \endgroup
  \skip@4pc \advance\skip@-\normalbaselineskip
  \vskip\skip@ }

\def\section{%
  \@startsection{section}{1}{0mm}{1.5\baselineskip}
    {\baselineskip}{\large\bfseries}}

\def\subsection{%
  \@startsection{subsection}{2}{0mm}{1.2\baselineskip}
    {.6\baselineskip}{\bfseries}}

\def\subsubsection{%
  \@startsection{subsubsection}{3}{0mm}{\baselineskip}
   {.6\baselineskip}{\normalfont}}

\def\paragraph{%
  \@startsection{paragraph}{4}{0mm}{\baselineskip}
   {-1em}{\itshape}}

\def\colophon{%
  \if@openright\cleardoublepage\else\clearpage\fi
  \thispagestyle{empty}
  \null\vfill
  \small\noindent
  \@colophontext    
}


\def\abstract{%
  \gdef\@keywordsname{\keywordsnameEN}
  \chapter*{\centerline\abstrname}}

%% Inicio do documento
\begin{document}

\chapter{Capitulo segundo}
\section{Trial}
\section{Seção especial}
Teste

\end{document}

Here's also a version hosted on sharelatex.

gpedrosa
  • 143
  • It would be simpler with titlesed, which is done for that. – Bernard Sep 22 '15 at 21:26
  • Thank you for your input @Bernard. I could not find reference to titlesed, did you mean titlesec? If so, I have taken a look, but could not figure out how to distinguish the starred version from non starred which ruins documents sections which rely on the non starred version such as abstract, summary, etc. – gpedrosa Sep 22 '15 at 21:38
  • Yes, it was a typo. To format a starred section, say, you have the key numberless. Thus you can write \titleformat{name=\section{…} for numbered sections and \titleformat{name=\section,numberless}{…} for unnumbered sections, and similarly for \titlespacing if necessary. It is documented in §3.8, Extended Settings, of the doc. – Bernard Sep 22 '15 at 21:50
  • Thanks for pointing me out in the right direction Bernard! I had a chance to play arround and using titlesec the way you mentioned did the trick. Just missing some fine tuning to my taste. I was also looking at section 4.2 in the manual, no wonder I did not find anything conclusive. – gpedrosa Sep 23 '15 at 09:59
  • @Bernard Do you want to write up an answer? – Johannes_B Dec 25 '15 at 09:52
  • @Johannes_B I have added an answer based on Bernard's comments using titlesec. I still need a better understanding of TeX to spot where the mysterious spacing is coming from and how to fix it without the extra package – gpedrosa Dec 28 '15 at 01:54

1 Answers1

2

Without the proper knowledge of basic TeX the answer I came up with involves the package titlesec, thanks to @Bernard's suggestion. I managed to adjust the output to my taste. A mwe with these adjustments and the outcome can be found below:

\documentclass[oneside,msc]{ufpethesis}

%% Preamble
\usepackage{lipsum}   % Cria texto "miolo de pote"
\usepackage{titlesec} % Modifica títulos

% Title adjustments (appearance and spacking)
\titleformat{\chapter}[hang]
{\LARGE\normalfont\bfseries}
{\thechapter}{0.5em}{}
\titleformat{name=\chapter,numberless}[hang]
  {\normalfont\LARGE\bfseries\filcenter}{}{1ex}{}{}
\titleformat{\section}[hang]{\normalfont\bfseries}{\thesection}{0.5em}{}
\titleformat{\subsection}[hang]{\normalfont\bfseries}{\thesubsection}{0.5em}{}
\titleformat{\subsubsection}[hang]{\normalfont\bfseries}{\thesubsubsection}{0.5em}{}
\titleformat{\paragraph}[hang]{\normalfont\bfseries}{\theparagraph}{0.5em}{}
\titlespacing{\chapter}{0pt}{0pt}{40pt}
\titlespacing{\section}{0pt}{\baselineskip}{0.625\baselineskip}
\titlespacing{\subsection}{0pt}{\baselineskip}{0.6\baselineskip}
\titlespacing{\subsubsection}{0pt}{\baselineskip}{\baselineskip}
\titlespacing{\paragraph}{0pt}{\baselineskip}{\baselineskip}

\begin{document}

\chapter{Capitulo segundo}
\section{Trial}
\section{AnotherTrial}
\subsection{Seção especial}
\subsubsection{Meu teste}
\paragraph{Paragrafo teste}

\end{document}

Outcome:

enter image description here

gpedrosa
  • 143