How to remove unwanted spaces above and below equations in classicthesis in LyX

2,207

What you see in LyX is just a preview that can change. If you want to reduce your space above and behind equation in the pdf version (that is the final version of your document)

Expected result for equation n°(1)

you have to put these lines before the environment equation as show here.

\documentclass[a4paper]{article}
\begin{document}
There are differences in the space above equation.
\[
    W = a + b+ c
\]
There are differences in the space below equation.

\setlength{\belowdisplayskip}{0pt} \setlength{\belowdisplayshortskip}{0pt}
\setlength{\abovedisplayskip}{0pt} \setlength{\abovedisplayshortskip}{0pt}
There are differences in the space above equation.
\begin{equation}
    W = a + b+ c
\end{equation}
There are differences in the space below equation.
\end{document}

You should use equation for equations instead of \[ and \]

Edit

In LyX, press Ctrl+L (or Insertion then Code TeX) and in the blank paste

\setlength{\belowdisplayskip}{0pt}
\setlength{\belowdisplayshortskip}{0pt}
\setlength{\abovedisplayskip}{0pt}
\setlength{\abovedisplayshortskip}{0pt}

This is an example with LyX LyX example

The LaTeX Code generated by LyX is

\setlength{\belowdisplayskip}{0pt} \setlength{\belowdisplayshortskip}{0pt} \setlength{\abovedisplayskip}{0pt} \setlength{\abovedisplayshortskip}{0pt}

There are differences in the space above equation. 

\[
W=a+b+c
\]


There are differences in the space below equation. 

There are differences in the space above equation. 
\begin{equation}
W=a+b+c
\end{equation}
\begin{equation}
T=est
\end{equation}


There are differences in the space below equation. 
Share:
2,207
Wendy
Author by

Wendy

Updated on August 01, 2022

Comments

  • Wendy
    Wendy over 1 year

    I am using latest LyX version of classicthesis template.

    When I import the latex code converted by word-to-latex into LyX, there are unwanted space above and below each equation (usually two extra lines above and one extra line below) in the PDF generated, but not in LyX itself (spaces are invisible, looks normal).

    How to avoid or remove those spaces?

    Update: I found a comment in the template:"You might get unexpected results using math in chapter or section heads. Consider the pdfspacing option."

    How do I use the "pdfspacing" option in LyX?

    Update: the source code and the unwanted PDF layout are

    enter image description here

    \begin{document}
    There are differences in the space above equation.
    \[
        W = a + b+ c
    \]
    There are differences in the space below equation.
    
    There are differences in the space above equation.
    \begin{equation}
        W = a + b+ c
    \end{equation}
    There are differences in the space below equation.
    \end{document}
    

    enter image description here

    • Torbjørn T.
      Torbjørn T. over 7 years
      Any answer would be a wild guess I fear, we need more information. Can you make the smallest document possible that shows this problem, and add the .lyx file to your question? It is a plain text file, so you can open it in any text editor (Notepad, Notepad++, Textedit, Gedit, Kate, etc.) and copy the entire content of the file.
    • Wendy
      Wendy over 7 years
      I tried in normal LyX with the same imported codes, there is no such problem. So I presume it is caused by the latest LyX version of classicthesis template I am using. Then I finally found a comment in the template:"You might get unexpected results using math in chapter or section heads. Consider the pdfspacing option." How do I use the pdfspacing option in LyX?
    • PhilipPirrip
      PhilipPirrip over 7 years
      Open your document, select View>Source Pane in LyX, change "Current Paragraph" to "Complete Source" in the drop-down menu on the right, move the cursor close to one of the equations so that its source shows in the source pane, copy a few lines before and after the equations here for us to see. pdfspacing deals with character spacing, it has nothing to do with this.
    • Wendy
      Wendy over 7 years
      As requested, I have updated my question to show the source code and unwanted space in PDF.
  • Wendy
    Wendy over 7 years
    Thank you for your help. I saw that in the template, it also uses \[ and \] for equations in display mode. Since I have so many equations imported from latex code, is it possible to adjust for all equations, instead of for each single equation?
  • Martin Rosalie
    Martin Rosalie over 7 years
    If you put these two lines after the \begin{document} it works for all equations
  • Wendy
    Wendy over 7 years
    0pt may be too crowded, what is the usual setting for thesis?
  • Martin Rosalie
    Martin Rosalie over 7 years
    1pt maybe. Frankly, default parameters are good for thesis also. Do not forget to validate the answer if it works for you :)
  • Wendy
    Wendy over 7 years
    But where to put the two lines in the Lyx version of Classicthesis template then?
  • Martin Rosalie
    Martin Rosalie over 7 years
    Press Ctrl+L (or Insertion then Code TeX) and in the blank paste \setlength{\belowdisplayskip}{0pt} \setlength{\belowdisplayshortskip}{0pt} \setlength{\abovedisplayskip}{0pt} \setlength{\abovedisplayshortskip}{0pt}
  • Wendy
    Wendy over 7 years
    I am familiar with this trick, so I inserted before the first displayed equation in the LyX text. It works for those modifed by copy the initial code->insert-> math-> display->paste the initial code, but does not work for those that I have not modified in this way.
  • Martin Rosalie
    Martin Rosalie over 7 years