General ⇒ How do I suppress newline after a subsection heading?
How do I suppress newline after a subsection heading?
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.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
How do I suppress newline after a subsection heading?
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?
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
How do I suppress newline after a subsection heading?
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
How do I suppress newline after a subsection heading?
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?
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}
How do I suppress newline after a subsection heading?

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?
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?
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?
Code: Select all
\begin{center}
\begin{minipage}[]{0.85\linewidth}
...
\end{center}
\end{minipage}