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 have

\usepackage{titlesec}
\titleformat{\section}[runin]
{\normalfont\Large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}[runin]
{\normalfont\large\bfseries}{\thesubsection}{1em}{}

which moves the text up after the section (and subsection). How can I add a period after the section title so that I get:

2.3 Section title. Text of paragraph...

share|improve this question
1  
This is covered in the titlesec documentation using two different approaches. See section 4.4. Putting a Dot after the Section Title (p 12) with \periodafter and a similar approach using the explicit package option (section 3.7. Other Package Options, p 8). –  Werner Oct 9 '13 at 22:19
    
@Werner: Thanks for the comment. I will take a look at this. –  Thomas Oct 9 '13 at 22:21
add comment

1 Answer

up vote 3 down vote accepted

Two ways.

The last argument of \titleformat can contain a macro that takes the title as its argument. So

\usepackage{titlesec}
\titleformat{\section}[runin]
  {\normalfont\Large\bfseries}
  {\thesection}
  {1em}
  {\addperiod}
\titleformat{\subsection}[runin]
  {\normalfont\large\bfseries}
  {\thesubsection}
  {1em}
  {\addperiod}
\newcommand{\addperiod}[1]{#1.}

Alternatively, use the explicit option; in this case you have to use #1 in the last argument to \titleformat to stand for the title.

\usepackage[explicit]{titlesec}
\titleformat{\section}[runin]
  {\normalfont\Large\bfseries}
  {\thesection}
  {1em}
  {#1.}
\titleformat{\subsection}[runin]
  {\normalfont\large\bfseries}
  {\thesubsection}
  {1em}
  {#1.}

The first way is more customizable.

share|improve this answer
    
Thanks. That seems to work. –  Thomas Oct 9 '13 at 22:20
add comment

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.