0

enter image description here

I have been using LaTeX for years now and I am usually able to answer my own questions myself or thanks to stack exchange. Until now. I have this strange vertical space appearing after the title of the section (see picture). It actually doesn't happen when I don't use my custom command \fillspace. But in a later subsection (not shown here), it doesn't happen even though I use the same command \fillspace, so it doesn't seem to be a regular problem. Strangely enough, it doesn't happen in the minimal sample code I give you with this question (the original code is for a 25-pages-long course...). The other command I created and used is \slv (which does the same as \\ but prevents the recurrent "no line to end here" error). I suspect that there is a subtle bug with my new commands but I just can't figure it out.

Do you know how I could remove this useless blank space? I can share the whole code with you, if needed.

Thanks in advance for any answer,

Bests,

Henri

\documentclass[a4paper, 12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} % load a font with all the characters
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{graphicx}
\usepackage{float}
\usepackage{stmaryrd}
\usepackage[margin=0.8in]{geometry}
\usepackage{amsfonts}
\usepackage{appendix}
\usepackage{wasysym}
\usepackage{pifont}
\newcommand{\slv}{\leavevmode\\}
\newcommand{\exo}{\vspace{0.1cm}\slv \ding{46}\textbf{\underline{Exercises}}: \\ \vspace{0.1cm}\slv }
\newcommand{\exm}{\vspace{0.1cm}\slv $\triangleright$ \textit{\underline{Examples}}: \\ \vspace{0.1cm}\slv }
\newcommand{\rem}{ \vspace{0.1cm}\slv $\bell$ \textbf{\underline{Remarks:}} }
\newcommand{\fillspace}[1]{\vspace{#1cm}\slv \checkmark\slv \vspace{#1cm}\slv}
\begin{document}

blablabla

\section{Second degree equations}
Among the equations that are still easily solvable are the second degree equations, which contain at least one second degree term and can generally be written\slv 
\fillspace{0.5}
These equations have between zero and two real solutions, as we will see later.\\
\exm 
1) Let us start from the equation $5x^2+3x-8=0$. We have\\
\vspace{1cm}\\
2) For the equation $2y^2+9=0$, we have\\
\vspace{1cm}\\
3) If we have something like $z^2-7z-3=5z^2-12$, we can transform the equation into\\
\vspace{1cm}\\
and thus we have\\blablabla...

\end{document}

enter image description here

1
  • 1
    all the \\ in this example are wrong, you should never have \\ at the end of a paragraph and certainly never after \vspace Feb 16 '17 at 11:19
1

I removed all the \\ from your example apart from the one case at the end where it was being used to mark a line break mid-paragraph (which is the only time it should be used) and the spacing is then more reasonable. It would be better to use the facilities for defining headings rather than just using underlined text and spacing as then latex will take care of page breaks around headings, but here I just concentrated on the spacing.

\documentclass[a4paper, 12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} % load a font with all the characters
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{graphicx}
\usepackage{float}
\usepackage{stmaryrd}
\usepackage[margin=0.8in]{geometry}
\usepackage{amsfonts}
\usepackage{appendix}
\usepackage{wasysym}
\usepackage{pifont}
%no!!! \newcommand{\slv}{\leavevmode\\}
\newcommand{\exo}{%
\par\vspace{0.1cm}%
\ding{46}\textbf{\underline{Exercises}}:\par\vspace{0.1cm}}
\newcommand{\exm}{%
\par\vspace{0.1cm}
$\triangleright$ \textit{\underline{Examples}}:\par
\vspace{0.1cm}}
\newcommand{\rem}{\par\vspace{0.1}$\bell$ \textbf{\underline{Remarks:}} }
\newcommand{\fillspace}[1]{\par\vspace{#1cm}\checkmark\par\vspace{#1cm}}
\begin{document}

blablabla

\section{Second degree equations}
Among the equations that are still easily solvable are the second degree equations, which contain at least one second degree term and can generally be written
\fillspace{0.5}
These equations have between zero and two real solutions, as we will see later.

\exm 
1) Let us start from the equation $5x^2+3x-8=0$. We have

\vspace{1cm}
2) For the equation $2y^2+9=0$, we have

\vspace{1cm}
3) If we have something like $z^2-7z-3=5z^2-12$, we can transform the equation into

\vspace{1cm}
and thus we have\\blablabla...

\end{document}
3
  • Ok, thanks for the help. I have to admit that I never used the command \par before, which is weird considering how useful it seems to be. I always overused the double backslash , apparently. I also modified my custom commands using the \paragraph structure, which is probably better. In my own answer that I will write below is my new code. It appears there are still places where I need to use the double backslash, such as in the tabular environment. What do you think? Feb 16 '17 at 13:49
  • @HenriDegueldre yes \\ ends tabular and math alignment rows, but that's really a different command altogether, but it should almost never be used in running text. \par is just the same as a blank line (a blank line generates a \par token which is why it ends a paragraph, but in macros it is sometimes easier to write \par than use a blank line) Feb 16 '17 at 14:07
  • Ok thanks a lot! This will definitely improve my TeX coding. Feb 16 '17 at 16:24
0

After some modifications according to @David Carlisle, I wrote the code in the following way, adding some other tests of my custom structures. I need a command to leave some blank spaces sometimes, such that my students can fill in the formula by hand (this is the role of the command \sv). Do you have a better suggestion for this?

\documentclass[a4paper, 12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} % load a font with all the characters
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{graphicx}
\usepackage{float}
\usepackage{stmaryrd}
\usepackage[margin=0.8in]{geometry}
\usepackage{amsfonts}
\usepackage{appendix}
\usepackage{wasysym}
\usepackage{pifont}
\newcommand{\sv}[1]{\par \vspace{#1cm}}
\newcommand{\exo}{%
\par\vspace{0.1cm}%
\paragraph{\ding{46} Exercises}:\par\vspace{0.1cm}}
\newcommand{\exm}{%
\par\vspace{0.1cm}
\paragraph{$\triangleright$ Examples}:\par
\vspace{0.1cm}}
\newcommand{\rem}{\par\vspace{0.1}\paragraph{$\bell$ Remarks}:}
\newcommand{\fillspace}[1]{\par\vspace{#1cm}\par\checkmark \par\vspace{#1cm}}
\begin{document}

blablabla

\section{Second degree equations}
Among the equations that are still easily solvable are the second degree equations, which contain at least one second degree term and can generally be written
\fillspace{0.5}
\par These equations have between zero and two real solutions, as we will see later.

\exm 
\par 1) Let us start from the equation $5x^2+3x-8=0$. We have

\sv{1}
\par 2) For the equation $2y^2+9=0$, we have

\sv{1}
\par 3) If we have something like $z^2-7z-3=5z^2-12$, we can transform the equation into

\sv{1}
\par and thus we have \sv{1}
\exo
Find the coefficients $a$, $b$ and $c$ in the following equations:\\
\sv{0.1}
\begin{tabular}{ll}
a) $2x^2-5x+11=0$ \hspace{4cm} & b) $3t^2-14=0$\\
\sv{0.1}\\
c) $-3w^2+11=8w$ & d) $-2x^2+4x-13=3x^2+9x$\\   
\end{tabular}\\
\end{document}

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.