多列中的垂直对齐

多列中的垂直对齐

如何避免因垂直对齐而导致行间出现空白,如下面的 MWE 第一列和第三列所示?

\documentclass{article}


\usepackage[utf8]{inputenc} %-> accepts Latin accentuation
\usepackage[T1]{fontenc}
%... allows the user to select font encodings, and for each encoding provides an interface to ‘font-encoding-specific’ commands for each font. Its most powerful effect is to enable hyphenation to operate on texts containing any character in the font

\usepackage{multicol}
\def\deg{\ensuremath{^\circ}}
\def\v#1{\ensuremath{\mathrm{#1}}}

\usepackage[a4paper, left=15mm, right=15mm]{geometry}

\begin{document}

\textbf{Sobre as leis de Kepler}

{\footnotesize
Considere elipse de semi-eixo maior $a$, semi-eixo menor $b$, excentricidade $e$ e área $A$.

\begin{multicols}{4}
\textit{Excentricidade de elipse}
\[
    e = \frac{c}{a}
\]

\textit{Área de elipse}
\[
    A = \pi a b
\]

\textit{2\deg\ Lei de Kepler}
\[
    \frac{\Delta A}{\Delta t} = \v{constante}
\]

\textit{3\deg Lei de Kepler}
\[
    \frac{T^2}{a^3} = \v{constante}
\]

\textit{Velocidade média}
\[
    \bar{v} = \frac{\Delta s}{\Delta t}
\]
\end{multicols}
}

\end{document}

编辑:应避免使用需要手动操作的方法(例如\columnbreak或用 替换multicols) 。tabular

答案1

如果添加该命令,\raggedcolumns您将无法获得列中的所有空格。

\documentclass{article}


\usepackage[utf8]{inputenc} %-> accepts Latin accentuation
\usepackage[T1]{fontenc}
%... allows the user to select font encodings, and for each encoding provides an interface to ‘font-encoding-specific’ commands for each font. Its most powerful effect is to enable hyphenation to operate on texts containing any character in the font

\usepackage{multicol}
\def\deg{\ensuremath{^\circ}}
\def\v#1{\ensuremath{\mathrm{#1}}}

\usepackage[a4paper, left=15mm, right=15mm]{geometry}

\begin{document}
\raggedcolumns
\textbf{Sobre as leis de Kepler}

{\footnotesize
Considere elipse de semi-eixo maior $a$, semi-eixo menor $b$, excentricidade $e$ e área $A$.

\begin{multicols}{4}
\textit{Excentricidade de elipse}
\[
    e = \frac{c}{a}
\]

\textit{Área de elipse}
\[
    A = \pi a b
\]

\textit{2\deg\ Lei de Kepler}
\[
    \frac{\Delta A}{\Delta t} = \v{constante}
\]

\textit{3\deg Lei de Kepler}
\[
    \frac{T^2}{a^3} = \v{constante}
\]

\textit{Velocidade média}
\[
    \bar{v} = \frac{\Delta s}{\Delta t}
\]
\end{multicols}
}

\end{document}

在此处输入图片描述

答案2

使用multicolswithout\columnbreak会导致自动分栏。在简单文档中,可以使用下面的方法。

输出

在此处输入图片描述

代码

\documentclass{article}


\usepackage[utf8]{inputenc} %-> accepts Latin accentuation
\usepackage[T1]{fontenc}
%... allows the user to select font encodings, and for each encoding provides an interface to ‘font-encoding-specific’ commands for each font. Its most powerful effect is to enable hyphenation to operate on texts containing any character in the font

\usepackage{multicol}
\def\deg{\ensuremath{^\circ}}
\def\v#1{\ensuremath{\mathrm{#1}}}

\usepackage[a4paper, left=15mm, right=15mm]{geometry}

\begin{document}

\textbf{Sobre as leis de Kepler}

{\footnotesize
Considere elipse de semi-eixo maior $a$, semi-eixo menor $b$, excentricidade $e$ e área $A$.

\begin{multicols}{4}
%--------------------------------
\textit{Excentricidade de elipse}
\[
    e = \frac{c}{a}
\]
\columnbreak


%--------------------------------
\textit{Área de elipse}
\[
    A = \pi a b
\]

\textit{2\deg\ Lei de Kepler}
\[
    \frac{\Delta A}{\Delta t} = \v{constante}
\]


%--------------------------------
\textit{3\deg Lei de Kepler}
\[
    \frac{T^2}{a^3} = \v{constante}
\]
\columnbreak


%--------------------------------    
\textit{Velocidade média}
\[
    \bar{v} = \frac{\Delta s}{\Delta t}
\]
\end{multicols}
}

\end{document}

答案3

让我分享另一种简单的方法,这种方法也是可以接受的,事实上,这是我选择使用的方法。在这种情况下,我定义了一个\setinfo接受两个参数的命令:标题及其数学定义。这样,我就可以避免标题与其数学定义被列或分页符分开。此外,编辑也很容易进行,因为我没有完整的表格,而是分开的、独立的表格。

\documentclass{article}

\usepackage[utf8]{inputenc} %-> accepts Latin accentuation
\usepackage[T1]{fontenc}
%... allows the user to select font encodings, and for each encoding provides an interface to ‘font-encoding-specific’ commands for each font. Its most powerful effect is to enable hyphenation to operate on texts containing any character in the font

\usepackage{multicol}
\def\deg{\ensuremath{^\circ}}
\def\v#1{\ensuremath{\mathrm{#1}}}

\usepackage[a4paper, left=15mm, right=15mm]{geometry}

\newcommand{\setinfo}[2]{%
    \begin{tabular}{l}
        \textit{#1} \\ \multicolumn{1}{r}{$\displaystyle #2$}
    \end{tabular}
    }

\begin{document}

\textbf{Sobre as leis de Kepler}

{\footnotesize
Considere elipse de semi-eixo maior $a$, semi-eixo menor $b$, excentricidade $e$ e área $A$.

\begin{multicols}{4}
\setinfo{Excentricidade de elipse}{e = \frac{c}{a}}

\setinfo{Área de elipse}{A = \pi a b}

\setinfo{2\deg\ Lei de Kepler}{\frac{\Delta A}{\Delta t} = \v{constante}}

\setinfo{3\deg Lei de Kepler}{\frac{T^2}{a^3} = \v{constante}}

\setinfo{Velocidade média}{\bar{v} = \frac{\Delta s}{\Delta t}}
\end{multicols}
}

\end{document}

相关内容