1

I have this code:

\documentclass[11pt]{article}
\usepackage{amsthm}
\usepackage[margin=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{setspace}

\theoremstyle{definition}
\newtheorem{definition}{Definition}

\newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}\\}

\onehalfspacing

\begin{document}

\paragraph{(1) Paragraph without mbox (for normal text)}
\noindent{}Some text

\paragraph{(2) Paragraph with mbox  (for normal text)}\mbox{}\\
\noindent{}Some text

\paragraph{(3) Paragraph without mbox  (for definitions)}
\begin{definition}{\textsc{Some definition}}
    is something that\ldots{}
\end{definition}

\paragraph{(4) Paragraph with mbox (for definitions)}\mbox{}\\
\begin{definition}{\textsc{Some definition}}
    is something that\ldots{}
\end{definition}

\end{document}

which produces this output

enter image description here

I am currently writing a set of notes on a subject, which means that immediately after a paragraph, I might be writing some text [as shown in (1) and (2)] or a definition [as shown in (3) and (4)]. I have read this, which helped forcing the text to start at the beginning og the next line, but my issue is that the spacing is different depending on whether I start a paragraph with some text or a definition.

Is there a way to (globally) set the same amount of space regardless of how I start my paragraph [basically so that I end up with (2) and (3) without having to manually insert/remove the \mbox{} command]

  • 1
    \paragraph is a level 4 section heading intended to be used in teh sequence section.subsection,subsubsection,paragraph it also (by default) numbers automatically like \section so it is not intended to be used in this way (`article' sets secnumdepth so that these low level sections are not numbered but if you increase the secnumdepth counter it will) – David Carlisle Dec 17 '18 at 8:00
  • 1
    it os always wrong to use \\ at the end of a paragraph, that does not make vertical space but a spurious blank extra underfull line of the paragraph. – David Carlisle Dec 17 '18 at 8:01
4

The spacing is the same in each case, but in some cases the last line of the paragraph following the heading is completely empty, LaTeX warns you about this

Underfull \hbox (badness 10000) in paragraph at lines 27--28

Never avoid that warning, which is telling yo that the output has maximum badness according to the rules TeX uses to achieve good line breaking.

Note that in

    \mbox{}\\
\noindent{}Some text

the \noindent does nothing as it only has any effect at the start of a paragraph, the \\ does not start a paragraph, it forces a new line. If you have "some text" in that line, that will appear. If you have no text then the new line is still forced but if(as in case 4) there is no text there you still get "a line of text" but it is all white and you get the above warning. Note that even though it looks a bit like a vertical space, it is not, it is an hbox the width of a page corresponding to a line of a paragraph, and it is not dropped at a page break for example.

You should remove the \\ but also you are using a run-in heading,but apparently want a display heading, the solution there is not to add a blank paragraph to every section, but to redefine the heading to be display. You could redefine \paragraph but it seems that a 4th level heading is not needed here, so I would use \section.

enter image description here

\documentclass[11pt]{article}
\usepackage{amsthm}
\usepackage[margin=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{setspace}

\theoremstyle{definition}
\newtheorem{definition}{Definition}

\newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}\\}

\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-1.5ex \@plus -1ex \@minus -.2ex}%
                                   {1sp}%
                                   {\normalfont\bfseries}}
\makeatother
\onehalfspacing

\begin{document}

\section{Paragraph without mbox (for normal text)}
Some text

\section{Paragraph with mbox  (for normal text)}
Some text

\section{Paragraph without mbox  (for definitions)}
\begin{definition}{\textsc{Some definition}}
    is something that\ldots{}
\end{definition}

\section{Paragraph with mbox (for definitions)}
\begin{definition}{\textsc{Some definition}}
    is something that\ldots{}
\end{definition}

\end{document}
  • Thank your for your answer, Mr. @David Carlisle. Then I would in this case much rather follow the TeX rules and use the section headings as intended. I still do not know the finer details of TeX yet, but from your answer, I can see why `\mbox{}\` is not a preferable solution. – Andreas Dec 18 '18 at 7:43

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.