4

So here's the format I'm using for my sections (I have an article document):

\titleformat{\section}{\sffamily\Large\bfseries\filcenter}{\vskip 1em}{CHAPTER \thesection}{\break}{}
\newcommand{\sectionbreak}{\clearpage}

So every title looks like this, but centered and located one break from the top of the page:

CHAPTER 1

SECTION TITLE GOES RIGHT HERE

However,the code won't compile this way, and I have an error warning at every single \section{title} line. But the above is what it looks like in the live preview (I use Latexian). If I remove the {\vskip 1em}, then the error is gone, however, it the titles now look like this:

___CHAPTER 1

SECTION TITLE GOES

______RIGHT HERE

Where the _ are spaces. The "CHAPTER 1" is centered, and everything else is kinda stylishly shifted to the right. But, the code compiles.

There could be a much better way to do this too... my goal is for each section to say CHAPTER # on one line, then say the section title on the line below, all centered, 1em from the top of the page.

Also, while reproducing this to type this question up, I get mixed results. Sometimes the addition of the vskip causes a "1em" to appear in between the "1" and the "SECTION". Other times, after removal of the vskip, I still have a compile error and error warnings. Sometimes the text just completely flattens out into one line when I remove the vskip. Basically nothing is consistent and I'm really confused.

7

First:

\titleformat{\section}[display]%
{\clearpage\sffamily\Large\bfseries\filcenter}{CHAPTER \thesection}{1em}{}[]

so don't use \vskip and remember the order of arguments.

Here 1em is vertical space between CHAPTER \thesection and title of section.

Second:

\titlespacing*{\section} {0pt}{1em}{2cm}

1em is what you need 2cm is vertical space. after title you can change it.

\documentclass{article}
\usepackage{titlesec}
\titleformat{\section}[display]%
{\clearpage\sffamily\Large\bfseries\filcenter}{CHAPTER \thesection}{1em}{}[]
\titlespacing*{\section}{0pt}{1em}{2cm}

\begin{document}
\section{SECTION TITLE GOES RIGHT HERE}
bla bla
\section{SECTION TITLE GOES RIGHT HERE}
bla bla

\end{document}
|improve this answer|||||
  • Thank you so much! Although, I need the 1em spacing (what you have set as 2cm) to be above the title, not below it. AKA I need the start of the title to be 1em below the top margin. I don't need the start of the text to be 1em below the title. I don't think I would use \titlespacing for that, would I? – Conor Sep 5 '15 at 18:50
  • Oops, I totally can change the pre-spacing with \titlespacing. Thanks again! – Conor Sep 5 '15 at 18:59
  • Ok, maybe I can't... Whenever I change the {1em} (the vertical spacing before the title argument), nothing happens, whether I do 1em, 0cm, 5in, 10 em, etc. Nothing changes... the {2 cm} argument does work if I change the value, however. – Conor Sep 5 '15 at 19:03
  • your right I'll see the titlesec's doc. For now try \titleformat{\section}[display]% {\clearpage\null\vskip1em\sffamily\Large\bfseries\filcenter}{CHAPTER \thesection}{1em}{}[] – touhami Sep 5 '15 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.