6

Changing the style of my sections using the package titlesec works fine with these lines

\usepackage{titlesec}
\titleformat{\section}[block]{\large\scshape\centering{\Roman{section}.}}{}{1em}{}

but after adding my literature to the end of the file...

\bibliographystyle{plain}
\bibliography{literature}

...the counter doesn't increase and the spacing is not entirely correct for the references section. However, the heading has the defined section style. Do you have a solution for having a consistent counter?

1
  • 1
    Hi lukas Welcome to TeX.SE! It's hard to tell what's causing your problem at the moment- could you make your snippets into a complete MWE that illustrates the problem? It will help both you and anyone that might be able to help. Welcome :)
    – cmhughes
    Commented Oct 14, 2012 at 23:23

1 Answer 1

10

It's not convenient to include the counter in the second argument of \titleformat; this will cause starred sections to be numbered in an "unorthodox" way, as the following simple example shows:

\documentclass{article}
\usepackage{titlesec}
\titleformat{\section}[block]{\large\scshape\centering{\Roman{section}.}}{}{1em}{}

\begin{document}

\section{Test Section}
\subsection{Test Subsection}
\section*{Test Section}
\subsection{Test Subsection}

\end{document}

This produces the following wrong result (the numbering is wrong, the spacing between the number and the title is wrong and the counter for subordinate sectional units isn't reset appropriately):

enter image description here

The right way to proceed here is to redefine \thesection previously to use Roman numerals, as the following example illustrates:

\documentclass{article}
\usepackage{titlesec}
\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@article{test,
  author= "The Author",
  journal = "The Journal",
  pages= "1-2",
  year="2012"
}
\end{filecontents*}

\renewcommand\thesection{\Roman{section}}

\titleformat{\section}[block]
  {\large\scshape\filcenter}{\thesection.}{1em}{}

\begin{document}

\section{test}
\cite{test}
\bibliographystyle{plain}
\bibliography{\jobname}

\end{document}

enter image description here

If you want to number the bibliography section, you can use the etoolbox package to patch the \thebibliography command to use \section instead of the default \section*:

\documentclass{article}
\usepackage{titlesec}
\usepackage{etoolbox}
\usepackage{filecontents}

\patchcmd{\thebibliography}{\section*}{\section}{}{}

\begin{filecontents*}{\jobname.bib}
@article{test,
  author= "The Author",
  journal = "The Journal",
  pages= "1-2",
  year="2012"
}
\end{filecontents*}

\renewcommand\thesection{\Roman{section}}

\titleformat{\section}[block]
  {\large\scshape\filcenter}{\thesection.}{1em}{}

\begin{document}

\section{test}
\cite{test}
\bibliographystyle{plain}
\bibliography{\jobname}

\end{document}

enter image description here

Not related to the original problem but \centering doesn't have arguments, so instead of \centering{text} one should use something like {\centering text\par} (the braces are only required if it is necessary to explicitly group to keep the effect local).

You must log in to answer this question.

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