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.

Im working with an existing template and I need to make my sections bold and my subsections indented. I use the titlesec package.

My Section style is this

\titleformat{\section}[block]{\Roman{section}.}{}{1em}{} 

Which I need to be bold

And my subsection style is this

\titleformat{\subsection}[block]{\Roman{section}.\Roman{subsection}}{}{2em}{} 

Which I need to indent (the roman numeral and the "title") 2em from the left margin

I have tried various different solutions for over an hour now but none of them seem to work... Could anyone help me out?

share|improve this question
    
Welcome to TeX.sx! It's not necessary to sign your questions (as there is already a box with your username below it). Also, we usually don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  Corentin Oct 23 '12 at 11:42

1 Answer 1

up vote 5 down vote accepted

If I have correctly understood what you are trying to do (by the way, it would be good to include a compilable minimal working example (MWE) to your questions so that it is easier to help you), the following code should work:

\documentclass{article}
\usepackage{titlesec}

\renewcommand\thesection{\Roman{section}} 
\renewcommand\thesubsection{\thesection.\Roman{subsection}} 
\titleformat{\section}[block]{\bfseries}{\thesection.}{1em}{} 
\titleformat{\subsection}[block]{\hspace{2em}}{\thesubsection}{1em}{}

\begin{document}

\section{A section}

\subsection{A subsection}\label{subsection1}

\subsection{Another subsection}
cf \ref{subsection1}

\end{document}

Here is the ouput:

enter image description here

Note that the \titleformat command is documented on page 4 of the titlesec manual (the texdoc titlesec command should open the documentation). The syntax is as follows:

\titleformat{⟨command⟩}[⟨shape⟩]{⟨format⟩}{⟨label⟩}{⟨sep⟩}{⟨before-code⟩}[⟨after-code⟩]

where <command> is the name of the sectioning command you need to customiz. <sep> is the separation between the label (in your case the roman numeral) and title, not between the left margin and the label. The <format> code allows you to specify the style applied to the whole heading (label+title). This is were you should put commands like \bfseries.

Edit: following @GonzaloMedina's comment, I have redefined the commands \thesection and \thesubsection to make sure that any \ref will produce the reference label in roman and not arabic numerals.

share|improve this answer
    
You are a LEGEND –  Chris Headleand Oct 23 '12 at 13:28
    
Perhaps it would be better to use \renewcommand\thesection{\Roman{section}} \renewcommand\thesubsection{\thesection.\Roman{subsection}} \titleformat{\section}[block]{\bfseries}{\thesection.}{1em}{} \titleformat{\subsection}[block]{\hspace{2em}}{\thesubsection}{1em}{} . Otherwise, cross-references will still produce arabic numerals. –  Gonzalo Medina Oct 23 '12 at 16:15
    
@GonzaloMedina You are right, I have updated my answer to include your improvement. –  Corentin Oct 23 '12 at 21:07

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.