2

I would like to have the sections of my document to just be separated by a vertical space, with no visible section header. Furthermore, I would like the first paragraph of each section start without an indent.

I tried the following minimal working example for an \invisiblesection command, taken from this question. Unfortunately, any text that follows this \invisiblesection command gets indented:

\documentclass{article}

\newcommand\invisiblesection[1]{%
  \refstepcounter{section}%
  \addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}%
  \sectionmark{#1}}


\begin{document}

\invisiblesection{First Section}
The section header is invisible :) but the paragraph starts with an indent :(

\section{Second Section}
The section header is visible :( but the paragraph starts with no indent :)

\end{document}

Adding \noindent to the end of \invisiblesection doesn't fix this. Adding \noindent to the beginning of each new section does fix it, but I would like this to happen automatically, as it does when I use the normal section environment.

  • 3
    A blank lines indicates a new paragraph. How do you make a new paragraph? – Marco Daniel May 9 '13 at 19:44
  • 3
    Can you clarify? I think of a blank line as what defines an end of paragraph, unless I insert a \par. So how do you mean a difference between "follows the previous paragraph" and "follows a blank line"? – Steven B. Segletes May 9 '13 at 19:46
  • 1
    Have you any serious reasons for breaking a five century old tradition in typography? – egreg May 9 '13 at 20:13
  • Sorry, that was very unclear of me. I have fixed the question. Egreg: a 40-century tradition of ignoring schoolmarms? – SuperElectric May 9 '13 at 20:19
  • Add \@afterheading to your definition of \invisiblesection – Marco Daniel May 9 '13 at 20:26
1

[EDITED to respond to user request]

\documentclass{article}
\renewcommand\thesection{\noindent}
\let\svsection\section
\renewcommand\section{\vspace*{-3.5\baselineskip}\svsection}
\begin{document}

\section{}

This follows a section

Second paragraph

Third paragraph

\section{}

Paragraph after new section

second paragraph

third paragraph

\end{document}

enter image description here

  • Almost! Is there a way to set the vertical spacing between paragraphs? I'm getting rid of section titles to save space, so I'd like to reduce it to around 1 line. – SuperElectric May 9 '13 at 20:39
  • I changed -3.5 to -2.5, and this worked perfectly (i.e. left 1 line of spacing between each section). Thank you! – SuperElectric May 9 '13 at 21:34
2

You can use titlesec to suppress the title; here's an example where I used fancyhdr to show that the \leftmark is correctly set.

The spacing can be adjusted with \titlespacing*{\section}... (note the asterisk).

\documentclass{article}
\usepackage{titlesec}
\makeatletter
\titleformat{\section}[block]{}{}{0pt}{\@gobble}
\makeatother

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markboth{#1}{#1}}
\fancyhf{}
\fancyhead[C]{\leftmark}
\fancyfoot[C]{\thepage}

\usepackage{lipsum}

\begin{document}

\lipsum[1]

\section{First section}

\lipsum

\section{Second section}

\lipsum

\end{document}

enter image description here

  • Hmm, when I try adjusting the vertical spacing, it seems to undo the \noindent of the first paragraph in each section. I'm using the following: \titlespacing\section{0pt}{0pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt} \renewcommand\thesection{\noindent} – SuperElectric May 9 '13 at 20:59
  • @SuperElectric Sorry, you have to use \titlespacing* which is the version that suppresses indentation on the next paragraph. – egreg May 9 '13 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.