Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm writing a thesis and sections are required to have roman numerals in both the toc and the document itself. The pertinent document code looks like this:

\documentclass[twoside,12pt]{report}
%%%%%%%%%%%%%%%%%%%Preamble%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%PACKAGES TO USE IN THE DOCUMENT:
\usepackage[indentfirst]{titlesec} %To allow for formatting section titles
\usepackage{ragged2e} %To allow for indentation with the raggedright command

%%%%%%%SET SECTION HEADING FORMATTING
\titleformat*{\section}{\Centering\normalsize\bfseries\uppercase}{\renewcommand\thesection{\Roman{section}.}
\titleformat*{\subsection}{\RaggedRight\normalsize\bfseries\uppercase}
\titleformat*{\subsubsection}{\RaggedRight\normalsize\bfseries}
\renewcommand\thesection{\Roman{section}.}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\SweaveOpts{concordance=TRUE}
\section{First Section}
\section{Second Section}
\subsection*{First Subsection}
\end{document}

This code gives me titles formatted according to my specifications, but the \renewcommand\thesection{\Roman{section}.} code only seems to affect the toc, not the actual section titles. As you can see, I have the command both on its own and with the \titleformat command, but neither one produces results. How can I get the number to show up in the actual section title?

share|improve this question

1 Answer 1

According to the manual of titlesec the command \titleformat* takes two arguments the section type/level and the format of the section. For the label you have to use \titleformat{command}[shape]{format}{label}{sep}{before code}[after code].

So you have to use something like the following

\renewcommand{\thesection}{\Roman{section}}
\titleformat{\section}
  {\Centering\normalsize\bfseries\uppercase}
  {\thesection. }
  {12pt}
  {}

to achieve the desired outcome.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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