General ⇒ How do I suppress newline after a subsection heading?
How do I suppress newline after a subsection heading?
Hi, I would like to do this
2.3 Explanation of...
2.3.1 Motivation. Having seen that...
i.e. the subsection 2.3.1 Motivation does not have a newline following it (but is only bold), unlike the section heading "Explanation of...". I've seen this done before. How do I do this with the article document type? Thank you.
2.3 Explanation of...
2.3.1 Motivation. Having seen that...
i.e. the subsection 2.3.1 Motivation does not have a newline following it (but is only bold), unlike the section heading "Explanation of...". I've seen this done before. How do I do this with the article document type? Thank you.
NEW: TikZ book now 40% off at Amazon.com for a short time.

How do I suppress newline after a subsection heading?
You can do that sort of thing with the titlesec package. You should probably read its documentation.
I'm a bit confused by your sample text, though, since in the article class there are no chapters, so a subsection would typically just be "2.3" and not "2.3.1" -- what is the extra number there? But maybe this example here will give you the basic idea.
result:
Again, it would be a good idea to read the package documentation.
I'm a bit confused by your sample text, though, since in the article class there are no chapters, so a subsection would typically just be "2.3" and not "2.3.1" -- what is the extra number there? But maybe this example here will give you the basic idea.
Code: Select all
\documentclass{article}
\usepackage{lipsum} % for generating filler text
\usepackage{titlesec}
\titleformat{\subsection}[runin]% runin puts it in the same paragraph
{\normalfont\bfseries}% formatting commands to apply to the whole heading
{\thesubsection}% the label and number
{0.5em}% space between label/number and subsection title
{}% formatting commands applied just to subsection title
[.]% punctuation or other commands following subsection title
\begin{document}
\section{This is a section}
\subsection{This is a subsection}
\lipsum[1]% (filler text)
\end{document}
Again, it would be a good idea to read the package documentation.
Re: How do I suppress newline after a subsection heading?
thanks, I might get back with more questions but this is basically working. (you're right, I messed up my numbering in my example).
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
How do I suppress newline after a subsection heading?
If this problem is solved now, please be so kind and mark the topic accordingly as clearly written in Section 3 of the Board Rules (to be read before posting). Otherwise please tell us what is missing. Please keep that in mind for the future so that further reminders will not be necessary.
Best regards and welcome to the board
Thorsten
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
How do I suppress newline after a subsection heading?
Hi,
I said it was basically working. It is not quite what I wanted, as it has an extra newline that I would like to eliminate.
Here is example of how I would like it to look and how it looks following your suggestion
And this is how I would like it to look:
Obviously I don't really want to hand-number the subsections!! This is just how I want it to look... I've seen this done so I still think it's possible, just having some trouble achieving it... Thank you.
p.s. am I using bold correctly? It has the effect I want (the output looks like I want it to) and I'm sure I saw this somewhere, but I wonder if my usage is "correct". Maybe it just "happens to work"
I said it was basically working. It is not quite what I wanted, as it has an extra newline that I would like to eliminate.
Here is example of how I would like it to look and how it looks following your suggestion
Code: Select all
\documentclass{article}
\usepackage{titlesec}
\titleformat{\subsection}[runin]% runin puts it in the same paragraph
{\normalfont\bfseries}% formatting commands to apply to the whole heading
{\thesubsection}% the label and number
{0.5em}% space between label/number and subsection title
{}% formatting commands applied just to subsection title
[.]% punctuation or other commands following subsection title
\begin{document}
\section{Permutations}
\subsection{Original version}
``The quick brown fox jumps over the lazy dog.'' This version ...
\subsection{Modern version}
``Over the lazy fox jumps the quick brown dog.'' While in some ways...
\subsection{Proposed version}
``Over the brown, quick, lazy jumps the fox dog.'' The advantages...
\end{document}
Code: Select all
\documentclass{article}
\begin{document}
\section{Permutations}
{\bf 1.1. Original version.} ``The quick brown fox jumps over the lazy dog.'' This version ...\\
{\bf 1.2. Modern version.} ``Over the lazy fox jumps the quick brown dog.'' While in some ways...\\
{\bf 1.3. Proposed version.} ``Over the brown, quick, lazy jumps the fox dog.'' The advantages...\\
\end{document}
p.s. am I using bold correctly? It has the effect I want (the output looks like I want it to) and I'm sure I saw this somewhere, but I wonder if my usage is "correct". Maybe it just "happens to work"
How do I suppress newline after a subsection heading?
Hi quickq,
you can use \titlespacing* to control the spacing before and after the title:
you can use \titlespacing* to control the spacing before and after the title:
Code: Select all
\documentclass{article}
\usepackage{titlesec}
\titleformat{\subsection}[runin]% runin puts it in the same paragraph
{\normalfont\bfseries}% formatting commands to apply to the whole heading
{\thesubsection}% the label and number
{0.5em}% space between label/number and subsection title
{}% formatting commands applied just to subsection title
[.]% punctuation or other commands following subsection title
\titlespacing*{\subsection}{0pt}{0pt}{0pt}
\begin{document}
\section{Permutations}
\subsection{Original version}
``The quick brown fox jumps over the lazy dog.'' This version ...
\subsection{Modern version}
``Over the lazy fox jumps the quick brown dog.'' While in some ways...
\subsection{Proposed version}
``Over the brown, quick, lazy jumps the fox dog.'' The advantages...
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
How do I suppress newline after a subsection heading?
Thank you. Almost there...
Now I get:
1.1 Original version.In the beginning... ----- But I still want:
1.1. Original version. In the beginning...
(period after numbering / space after name of subsection)
Sorry I'm being so detail-oriented, I just want a pop-in replacement for the formatting I'm doing by hand (including hand-numbering).
I'm trying to figure out how to add these last two things, but I'm having trouble...

1.1 Original version.In the beginning... ----- But I still want:
1.1. Original version. In the beginning...
(period after numbering / space after name of subsection)
Sorry I'm being so detail-oriented, I just want a pop-in replacement for the formatting I'm doing by hand (including hand-numbering).
I'm trying to figure out how to add these last two things, but I'm having trouble...
How do I suppress newline after a subsection heading?
The last argument to titlespacing sets the horizontal spacing after the title:
(If 0.5em is too wide or too narrow, change it to whatever you might want instead.)
To add a period at the end of the number change the line that reads:
to
Please read the package documentation, as I have already suggested. Then you could answer these questions for yourself.
Code: Select all
\titlespacing*{\subsection}{0pt}{0pt}{0.5em}
To add a period at the end of the number change the line that reads:
Code: Select all
{\thesubsection}% the label and number
Code: Select all
{\thesubsection.}% the label and number
Please read the package documentation, as I have already suggested. Then you could answer these questions for yourself.
How do I suppress newline after a subsection heading?
I'm sorry I haven't been reading all the documentation. I just learned latex three and a half days ago, and for the past three days have been doing nothing but formatting my article, without any regard for the content. It is really hard for me to understand documentation because I don't have my head around all of the standard vocabulary of latex. I just want to do it right and finally get started on working on the content.
On the point you just helped me with, there is one thing that I had in my original, which I did not mention. In certain places I had a "quote" environment (if I'm even using the word environment right) around my paragraphs, but wanted to continue having them numbered. Now that I've followed your advice,
I'm sorry, I can't understand http://tug.ctan.org/tex-archive/macros/ ... tlesec.pdf yet.
Everything here is really, really hard for me and I am just a beginner. Thank you for your patience.
On the point you just helped me with, there is one thing that I had in my original, which I did not mention. In certain places I had a "quote" environment (if I'm even using the word environment right) around my paragraphs, but wanted to continue having them numbered. Now that I've followed your advice,
doesn't work the way\begin{quote}
\subsection{whatever}
blah blah
\end{quote}
had. I don't want to change the whole style of the title (if I'm even using the vocabulary right in this sentence) throughout the document, i just want it inside a quote environment in one place. Is this possible or should I just give up?\begin{quote}
{\bf 1.2. whatever.} blah blah\\
\end{quote}
I'm sorry, I can't understand http://tug.ctan.org/tex-archive/macros/ ... tlesec.pdf yet.
Everything here is really, really hard for me and I am just a beginner. Thank you for your patience.
How do I suppress newline after a subsection heading?
Well, this seems, empirically, to have the same effect as "quote":
(except it actually works for what I'm doing) so I guess it'll have to do...
Code: Select all
\begin{center}
\begin{minipage}[]{0.85\linewidth}
...
\end{center}
\end{minipage}