我很确定这个问题之前已经在某个地方解决过,但我找不到解决方案,可能是因为我不知道如何定义/调用这个问题。
几乎所有非正常文本大小都会影响两列之间的文本垂直对齐,我怎样才能强制乳胶对齐两列布局两侧线条的位置?
最小示例:
\documentclass[A4,12pt]{article}
\usepackage{blindtext,amsmath}
\begin{document}
\sloppy
\twocolumn
\section{Random Section}
\blindtext
\blindtext
\begin{align*}
\sum_i X(i) \cdot x
\end{align*}
\blindtext
\blindtext
\end{document}
注意到了,即使章节标题也没有合适的高度,因此第二列上的文本无法对齐……或者这是正常的吗?只有我一个人有这个问题吗?
答案1
收集完每一列后,我可能会尝试重新调整收集到的列中的线条,使其与网格对齐。以下内容并不完美,但它展示了基本技术。
\documentclass[a4paper,12pt]{article}
\usepackage{blindtext,amsmath}
\showboxdepth1
\showboxbreadth\maxdimen
\def\myround#1{%
\dimen0#1\relax
\divide\dimen0 \mycountb
\multiply\dimen0\mycountb
}
\global\let\myset Y
\makeatletter
% 4 + 11 = 15
\baselineskip15pt
\normalbaselineskip\baselineskip
\newcount\mycountb
\mycountb\baselineskip
\let\old@makecol\@makecol
\def\@makecol{%
\old@makecol
\global\setbox1\vbox{}%
\setbox0\vbox{\unvbox\@outputbox
\loop
\ifnum\lastnodetype=\m@ne
\else
\ifcase\lastnodetype
%0 char
\showthe\lastnodetype
\or
%1 hlist
\setbox0\lastbox
\myround{\ht0}
\advance\dimen0 11pt
\ht0 \dimen0
\myround{\dp0}
\advance\dimen0 4pt
\dp0 \dimen0
\global\setbox1\vbox{\box0\unvbox1}%
\or
%2 vlist
\setbox0\lastbox
\myround{\ht0}
\advance\dimen0 11pt
\ht0 \dimen0
\myround{\dp0}
\advance\dimen0 4pt
\dp0 \dimen0
\global\setbox1\vbox{\box0\unvbox1}%
\or
%3 rule
\showthe\lastnodetype
\or
%4 ind
\showthe\lastnodetype
\or
%5 mark
\showthe\lastnodetype
\or
%6 adjust
\showthe\lastnodetype
\or
%7 rule
\showthe\lastnodetype
\or
%8 disc
\showthe\lastnodetype
\or
%9 whatsit
\let\lastnodetype\m@ne
\or
%10 math
\showthe\lastnodetype
\or
%11 glue
\myround{\lastskip\unskip}%
\global\setbox1\vbox{\vskip\dimen0\unvbox1}%
\or
%12 kern
\myround{\lastskip\unskip}%
\global\setbox1\vbox{\vskip\dimen0\unvbox1}%
\or
%13 penalty
\unpenalty
\or
%14 unset
\showthe\lastnodetype
\or
%15 math mode nodes
\showthe\lastnodetype
\fi
\repeat
}%
\setbox\@outputbox\vbox to\@colht{%
\offinterlineskip
\myround{\ht0}
\advance\dimen0 11pt
\ht0 \dimen0
\myround{\dp0}
\advance\dimen0 4pt
\dp0 \dimen0
\box0
\box1
\vss
}%
}
\makeatother
\begin{document}
\sloppy
\twocolumn
\section{Random Section}
\blindtext
\blindtext
\begin{align*}
\sum_i X(i) \cdot x
\end{align*}
\blindtext
\blindtext
\end{document}
答案2
单靠这个grid
包可能无法解决您的问题,特别是在align*
环境之后。要恢复电网,\vskipnextgrid
这个gridset
包确实有帮助。
如果有太多元素需要强制放回电网,这种方法将会失败:如果是这样,gridset
将无法实现稳定的值。
这是 MWE(为了显示效果,它很长)
\documentclass{article}
\usepackage{blindtext,amsmath}
\usepackage{gridset}% gridset provides us with \vskipnextgrid
\usepackage[fontsize=12pt,% if you don't set the font size and the baseline
baseline=14pt]% here, things go wrong (I don't know why, since
{grid}% it's supposed to have a default value for both)
\begin{document}
\sloppy
\twocolumn
\section{Random Section}
\blindtext[2]
\begin{align*}
\sum_i X(i) \cdot x
\end{align*}
\vskipnextgrid
\blindtext[2]
\section{Another Random Section}
\blindtext[2]\footnote{\blindtext}% Added a footnote to see if it
\begin{align*}% messes with the grid
\sum_i X(i) \cdot x
\end{align*}
\vskipnextgrid
\blindtext[2]
\end{document}