Page Layoutmoving chapter title with \titleformat

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
snowfrog
Posts: 38
Joined: Wed Jan 06, 2010 8:11 pm

moving chapter title with \titleformat

Post by snowfrog »

Hi,

I'm writing the title of each chapter in my thesis with this code

Code: Select all

\titleformat{\chapter}[display]
	    {\normalfont\Large\color{black}\sffamily}
	    {\vspace{1pt}%
	      \LARGE\MakeUppercase{\chaptertitlename} \thechapter}
	    {1pc}
	    { \vspace{1pc}%
	     \Huge}
I have an image at the background and so sometimes it would be better if I could move the title a bit to make it more readable against the background. I understand I can move the title itself by adding \vspace in the {format} section of \titleformat. Problem is that this doesn't move the number of the chapter.

All my chapter headers are at the top left of the page, I believe because of this code in the *cls file

Code: Select all

\DeclareOption{leftchapter}
   {\renewcommand{\@chapteralignment}{\raggedright}}
and a bit later in the code

Code: Select all

\ExecuteOptions{phd,leftchapter}
\ProcessOptions
In an ideal world, I would like a couple of chapter headers in the bottom left of the page.

Could anybody advise?
Thanks for your help!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

moving chapter title with \titleformat

Post by frabjous »

The \titleformat command is provided by the titlesec package. You might want to look at its documentation.

It's a bit hard to tell, since you didn't say what document class you are using, nor did you provide a MWE per board rules, but using titlesec it's usually possible to prevent chapters from beginning on new pages (and override this setting in the documentclass) by its \titleclass command, and then defining the \chapterbreak to be empty:

Code: Select all

\documentclass{book}
\usepackage{titlesec,xcolor,lipsum}
\titleclass{\chapter}{top}
\newcommand{\chapterbreak}{}
\titleformat{\chapter}[display]
       {\normalfont\Large\color{black}\sffamily}
       {\vspace{1pt}%
         \LARGE\MakeUppercase{\chaptertitlename} \thechapter}
       {1pc}
       { \vspace{1pc}%
        \Huge}
\begin{document}
\chapter{First Chapter}
\lipsum[1-15]
\chapter{Second Chapter}
\lipsum[16-30]
\end{document}
It also provides a \titlespacing command you can use to customize various aspects of the spacing of the titles. Without more information about what you want to do, I can't really help with that. However, maybe the documentation I linked above would provide some guidance.

However, if this is your thesis, if I were you, I'd find out from your University what kind of formatting is allowed. Most university have very narrow guidelines about how theses are formatted, and deviating from them is not allowed.
snowfrog
Posts: 38
Joined: Wed Jan 06, 2010 8:11 pm

moving chapter title with \titleformat

Post by snowfrog »

The \titleformat command is provided by the titlesec package. You might want to look at its documentation.
Thanks, I always look at the documentation before posting a message but in this case couldn't see anything I could apply to my problem.

My thesis is split into different *tex files, one for each chapter, all called from a "main" file. Here's a mwe of the main document

Code: Select all

\documentclass{thesis}

\usepackage{color}
\usepackage{titlesec}  
\usepackage{graphicx}
\usepackage{eso-pic}     

\begin{document}

\include{Chapter1}
\include{Chapter2}
\end{document}
The "thesis" style is from a template made by the School at the University although it's not set in stone. As I said in my first post
All my chapter headers are at the top left of the page, I believe because of this code in the *cls file

Code: Select all

\DeclareOption{leftchapter}
   {\renewcommand{\@chapteralignment}{\raggedright}}
and a bit later in the code

Code: Select all

\ExecuteOptions{phd,leftchapter}
\ProcessOptions
At least I'm guessing, the *cls is a bit of a beast if one is not too comfortable with LaTeX.

Here's a mwe of the chapters called in \include

Code: Select all

\titleformat{\chapter}[display]
       {\normalfont\Large\color{black}\sffamily}
       {\vspace{1pt}%
         \LARGE\MakeUppercase{\chaptertitlename} \thechapter}
       {1pc}
       { \vspace{1pc}%
        \Huge}

\chapter{TITLE}

\AddToShipoutPicture*{\put(130,0)%
{\includegraphics[width=17cm,height=25cm]{title.jpg}%
}}

\chapter{TITLE}

\pagebreak[4] 

\section{Intro}
etc...
I did try your mwe above with a couple of my chapters but got an error related to the \lipsum command, certainly because I don't know how to adapt it to my thesis but I couldn't find any documentation to make me understand what it actually does. Besides, I don't know if I can use it with my chapters being split between different documents.
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

moving chapter title with \titleformat

Post by frabjous »

The \include command is defined as:

Code: Select all

\clearpage \input{file} \clearpage 
Obviously that causes chapters to begin on new pages.

Change \include to \input in your main document.

I believe the other changes I described above should then allow chapters to begin mid-page.

Nevermind the \lipsum commands. They are used to autogenerate text I was using as filler. You can take them out.

If that doesn't work, is the document class for your thesis publicly available? It's hard to give advice when we can't test for ourselves.
snowfrog
Posts: 38
Joined: Wed Jan 06, 2010 8:11 pm

Re: moving chapter title with \titleformat

Post by snowfrog »

I couldn't get the chapter title to move down the page and I don't think the document class is publicly available.

So as a compromise I just moved the title of the chapter on the left of the page rather than at the bottom by using \raggedleft.
Post Reply