a question about formatting section titles. In the article class, I want to format my section titles as follows:
- Hide the section number in the title.
- Use upper case.
- Add a dashed title rule below the title (I have custom dashed lines defined elsewhere).
I have tried out a lot with the titlesec package already, but I don't get even near a solution.
\titleformat{\section}{\centering\large\titlerule}{\thesection}{0.5em}{}
This produces a titlerule above my title, but not below. I have tried various places for \titlerule, but I cannot find the correct one^^. Also, \MakeUppercase does not work on the titlename. The section numbers are visible. Can anyone help?
Best,
a
Best Answer
Like so?
(Some hints were found in inline uppercase chapter title)
The general syntax of
\titleformat
is<command>
is the sectioning command you want to modify, here\section
.<shape>
determines the general placement of the heading, see page 3 in the manual for a list of options. This is an optional argument.<format>
holds general format switches for the text of the heading, here\centering\large
.<label>
: This is where you place code that prints the number of the section (\thesection
), and other related things, e.g. the word Chapter for chapters.<sep>
is the distance from the number to the title (I just changed this to 0em)<before-code>
is just that, code placed before the text of the title.\MakeUppercase
takes an argument (i.e.\MakeUppercase{text}
), but as I understand ittitlesec
is constructed so that the last macro used in<before-code>
can take an argument, and you can use it as I have.<after-code>
as expected is placed after the title text. You wanted the rule after, so I added it here. This is also an optional argument, brackets ([]
) typically denote optional arguments in LaTeX, while braces ({}
) denote mandatory arguments. For that reason you cannot leave out the empty pair of braces.