3

I am working on my thesis in the book class, I work in Kile under Linux. So this is an overview of my latex code:

\documentclass[a4paper,10pt]{book}
\usepackage[utf8]{inputenc}

% ### Chapter title style ###
\makeatletter
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        %\huge\bfseries \@chapapp\space \thechapter
        \Huge\bfseries \thechapter.\space%
        %\par\nobreak
        %\vskip 20\p@
      \fi
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}
\makeatother

% put section numbers in white marigin
\makeatletter 
\def\@seccntformat#1{\llap{\csname the#1\endcsname\quad}} 
\makeatother 


\begin{document}

 \chapter{Introduction}

 \section{First section}

 \section{Second section}


\end{document}

The code for suppressing the word chapter is from this topic on stachexchange.

This is what the document looks like:

enter image description here

So to be clear, I would like the number 1. to be in the white margins as well.

Koen
  • 149
  • 1
    Welcome to TeX.SX! \@seccntformat is responsible for \section etc., but not for chapters. Please provide a compilable document, not just fragments –  Mar 15 '16 at 10:50
  • I am not that familiar with latex code, do you know what I should use for chapters?

    Edit: Thanks for the welcome btw! I am working on a compilable document now.

    – Koen Mar 15 '16 at 10:51
  • I edited my question, there is a compilable document now. It doesn't change much, but I assume the question is clear. – Koen Mar 15 '16 at 11:07

1 Answers1

2

The code for (anything) outside is basically the same for \@seccntformat as for \chapter, however, there's a vertical skip normally and this has to be unskipped back to the old position.

Remove the showframe package later on -- it's only there to show that the number is now outside of the regular text body.

\documentclass[a4paper,10pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{showframe}

\makeatletter
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@\normalfont\raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne%
    \if@mainmatter%
    \Huge\bfseries\llap{\thechapter.\hfill\space}%
    \vskip-\baselineskip
    \fi%
    \fi%
    \interlinepenalty\@M
    \nobreak\Huge\bfseries #1\nobreak%%
    \vskip 40\p@
  }
}

\def\@seccntformat#1{\llap{\csname the#1\endcsname\quad}} 
\makeatother

\usepackage{blindtext}

\begin{document}
\chapter{First longer chapter title}
\section{First section}
\chapter{Second}

\blinddocument
\end{document}

enter image description here

Update

\documentclass[a4paper,10pt]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{showframe}

\newcommand{\INSANELYHUGE}{\fontsize{100}{120}\selectfont}

\makeatletter
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@\normalfont\raggedright \normalfont%
    \ifnum \c@secnumdepth >\m@ne%
    \if@mainmatter%
    \INSANELYHUGE\bfseries\llap{\thechapter.\hfill\space}%
    \vskip-\baselineskip
    \fi%
    \fi%
    \interlinepenalty\@M
    \nobreak\INSANELYHUGE\bfseries #1\nobreak%%
    \vskip 40\p@
  }
}

\def\@seccntformat#1{\llap{\csname the#1\endcsname\quad}} 
\makeatother



\usepackage{blindtext}

\begin{document}
\chapter{First longer chapter title}
\section{First section}
\chapter{Second}

\blinddocument
\end{document}
  • Perhaps, one should remove the . after the chapter number –  Mar 15 '16 at 11:19
  • Thank you Christian, this does the job for me! I don't mind the ., I actually prefer it that way. – Koen Mar 15 '16 at 11:51
  • @Koen: Alright then -- happy TeXing! ;-) –  Mar 15 '16 at 12:00
  • One more question though; Do you know an easy way to make the font for the chapter title even bigger? I know \Huge is the largest font available, but I would like to make the chapter title appear more prominent. – Koen Mar 15 '16 at 12:19
  • 1
    @KOEN: \fontsize{size}{skip}\selectfont is the command to switch to another size, but this depends on the scalings provided by the font (otherwise, you get warnings). Using lmodern fonts however you can use larger fontsizes. See the \INSANELYHUGE command in the update. –  Mar 15 '16 at 13:05
  • Thank you once again Christian! I was already looking for something like this and now I actually got it working by using the lmodern package. – Koen Mar 15 '16 at 13:08
  • @Koen: Yes ;-) But please don't update this question again ;-) –  Mar 15 '16 at 13:09
  • Haha sorry, this was the last time :) – Koen Mar 15 '16 at 13:12