2

I use the beamer class. If display math followed by some enumerate environment, beamer will insert an extra blank line between them.

The following is the codes.

\documentclass{beamer}
\begin{document}
\begin{frame}
  \begin{columns}[t]
    \begin{column}{.5\linewidth}
      Assume
      \[
        f+g=h
      \]
      \begin{enumerate}
        \item item 1;
        \item item 2.
      \end{enumerate}
    \end{column}
    \begin{column}{.5\linewidth}
      Assume
      \[
        f+g=h
      \]
      then
      \begin{enumerate}
        \item item 1;
        \item item 2.
      \end{enumerate}
    \end{column}
  \end{columns}
\end{frame}
\end{document}

The pdf file looks like the picture. enter image description here

I split the frame into two columns. In the left column, there is no texts between display math and the enumerate environment. But there is an extra blank line, as if there are some ghost texts between them.

Question: How to remove the extra blank line?

jiaopjie
  • 447
  • 1
    Related: https://tex.stackexchange.com/q/615437/263192 –  Apr 23 '22 at 05:41
  • 1
    If you are interested in a quick fix: adding a blank line between the end of the equation and \begin{enumerate} reduces the space. Alternatively, you could use a negative \vspace. –  Apr 23 '22 at 08:15

3 Answers3

2

Placing a negative \vspace works.

\documentclass{beamer}
\begin{document}
\begin{frame}
  \begin{columns}[t]
    \begin{column}{.5\linewidth}
      Assume
      \[
        f+g=h
      \]
      \vspace{-1.5em} %Placing a negative \vspace works. Adjust it according to your need.
      \begin{enumerate}
        \item item 1;
        \item item 2.
      \end{enumerate}
    \end{column}
    \begin{column}{.5\linewidth}
      Assume
      \[
        f+g=h
      \]
      then
      \begin{enumerate}
        \item item 1;
        \item item 2.
      \end{enumerate}
    \end{column}
  \end{columns}
\end{frame}
\end{document}

Output:

enter image description here

Rahman
  • 189
-1

I think the solution in this case will be the Tikz library usage to draw your algorithm or just making the table where you can put your info:

begin{table}{c|c|c}
Assume & & Assume \\
\[f+g=h\] & & \[f+g=h\] \\
 & then & \\
1. item 1; & & 1. item 1;\\
2. item 1; & & 2. item 1;\\

end{table}

-1

This code will give you a table withour additional spaces:

\documentclass{beamer}
\usepackage{graphicx} % Required for inserting images
\usepackage{tabularx}
\usepackage{amsmath}

\begin{document} \begin{tabular}{c c c} Assume & & Assume \ (f+g=h) & & (f+g=h) \

& then & \

  1. item 1; & & 1. item 1;\
  2. item 1; & & 2. item 1;\

\end{tabular}

\section{Introduction}

\end{document}

enter image description here

  • Neither or the loaded packages is necessary and you really should not place any test outside of frames in beamer. What's the purpose of the section? – samcarter_is_at_topanswers.xyz May 18 '23 at 13:51
  • Do you mean that amsmath package is not required? How do you suggest to write formulas? – Programmer1988 May 18 '23 at 13:53
  • Your formula does not use any special macros which would require amsmath. However beamer automatically loads it anyway, so even if you were to use something from amsmath, you wouldn't have to load it. – samcarter_is_at_topanswers.xyz May 18 '23 at 13:54
  • Yeah, now I see that beamer class has already have it and code works without additional tabularx and amsmath libraries – Programmer1988 May 18 '23 at 14:03
  • 1
    Thank you for your answer. But the desired result is the picture given in Rahman's answer. A negative \vspace is acceptable if there is no better solution. – jiaopjie May 21 '23 at 12:12
  • @jiaopjie, OK, do you mean that it is enough to place the \vspace negative solution? I suppose that shorter programm is better program and here we need more complex soluton. But if you're satisfied with Rahman's solution it is OK – Programmer1988 May 22 '23 at 10:56
  • 1
    @Programmer1988 I mean the desired result is just like Rahman's picture. I want some better solutions, than a negative \vspace. But if there is no one, the latter is acceptable. In my example, the right column is just for comparison. My needs is not to recurrent my picture using other methods. – jiaopjie May 30 '23 at 11:23