6

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...

2
  • 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). Commented Oct 9, 2013 at 22:19
  • @Werner: Thanks for the comment. I will take a look at this. Commented Oct 9, 2013 at 22:21

1 Answer 1

8

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.

1
  • Thanks for this solution! I first had some problems to get this working in combination with Springer llcns style. I also found this post: tex.stackexchange.com/questions/103020/… The combination of both solutions solved my problem. Commented Jun 28, 2019 at 21:35

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.