9

I have my document like this (in main.tex):

% Document type: report (master/bachelor thesis)
\documentclass[a4paper,12pt,appendix]{report}

\input{template/FormatsAndDefs.tex} % here I have specified various format settings

\begin{document}
  \input{thesis.tex}
\end{document}

In FormatsAndDefs.tex I have specified format for chapter titles like this:

\usepackage[T1]{fontenc}
\usepackage{titlesec}
% various other packages

\titleformat{\chapter}
  {\normalfont\Large\bfseries}{\thechapter}{.5em}{\vspace{.5ex}}[\titlerule]
\titlespacing*{\chapter}      
    {0pt}{0pt}{15pt}

So my title chapters are formatted like this: enter image description here

How can I make this chapter title "Introducion" in ALL UPPERCASE while keeping it bold and underlined?

I have tried to use \MakeUppercase :

\titleformat{\chapter}
  {\normalfont\LARGE\bfseries}{\MakeUppercase{\thechapter}}{.5em}{\vspace{.5ex}}[\titlerule]

but chapter remained still the same as shown in the picture.

5
  • Welcome to TeX.SX! I think you may in part be looking for the \MakeUppercase command. Does the second piece of code in Gonzalo Medina's answer to Formatting section titles help you?
    – Dai Bowen
    Commented Nov 17, 2016 at 0:28
  • Thank you. Yes I have tried those solutions, but it gave me errors, because I am not sure where to add \MakeUppercase command in my \titleformat code.
    – PeterB
    Commented Nov 17, 2016 at 0:39
  • Ok, if you can add a minimal working example (MWE) that would help us figure out what is wrong.
    – Dai Bowen
    Commented Nov 17, 2016 at 0:42
  • Try loading titlesec using the explicit option as \usepackage[explicit]{titlesec} and then \titleformat{\chapter} {\normalfont\LARGE\bfseries}{\thechapter}{.5em}{\MakeUppercase{#1}\vspace{.5ex}}[\titlerule].
    – Dai Bowen
    Commented Nov 17, 2016 at 1:02
  • @DaiBowen thanks, this works similary to Werner's answer.
    – PeterB
    Commented Nov 17, 2016 at 1:40

2 Answers 2

9

You need to have a handle on the chapter title, and the only way to do this is to use the explicit option with titlesec:

enter image description here

\documentclass{report}

\usepackage[explicit]{titlesec}
\usepackage{lipsum}

\titleformat{\chapter}
  {\normalfont\Large\bfseries}{\thechapter \quad \MakeUppercase{#1}}{.5em}{\vspace{.5ex}}[\titlerule]
\titlespacing*{\chapter}
  {0pt}{0pt}{15pt}

\begin{document}

\chapter{Introduction}

\lipsum

\end{document}

This option allows you to explicitly state the sectional title as #1, where you can now wrap it within \MakeUppercase.

6
  • Ok, now my \chapter titles are uppercase and as I wanted them BUT my \section titles are underlined AS WELL... and I dont want them underlined. There is code right under the chapter title format : \titleformat{\section} {\normalfont\large\bfseries}{\thesection}{1em}{} As you can see there is no [\titlerule] specified. What is this strange behaviour?
    – PeterB
    Commented Nov 17, 2016 at 1:14
  • @PeterB.: I don't get that in my output when I use \titleformat{\section}{\normalfont\large\bfseries}{\thesection \quad #1}{1em}{}...
    – Werner
    Commented Nov 17, 2016 at 1:17
  • It was my mistake, because I deleted and replaced \usepackage[sf,sl,outermarks]{titlesec} but I just needed to add explicit to square brackets. Now it works like a charm, thank you sir.
    – PeterB
    Commented Nov 17, 2016 at 1:33
  • 1
    Would you please try \chapter*{whatever}?
    – egreg
    Commented Nov 17, 2016 at 8:03
  • @egreg: You'll have to read the titlesec documentation to see the author discourages this.
    – Werner
    Commented Nov 17, 2016 at 8:17
12

Use the correct places for the various parts: the spacing before the rule should go in the last argument (the optional one), so you can finish the title argument with a one parameter macro such as \MakeUppercase.

\documentclass{report}

\usepackage{titlesec}
\usepackage{lipsum}

\titleformat{\chapter}
  {\normalfont\Large\bfseries}
  {\thechapter}
  {.5em}
  {\MakeUppercase}
  [\vspace{.5ex}\titlerule]

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

\begin{document}

\chapter{Introduction}

\lipsum

\end{document}

enter image description here

2
  • How to set the thickness of the line with your code?
    – Ommo
    Commented Mar 7 at 11:21
  • I guess I found the way to set the line thickness: [\vspace{0ex}{\titlerule[2pt]}]
    – Ommo
    Commented Mar 7 at 11:45

You must log in to answer this question.

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