重新定义 \equation 进行网格排版

重新定义 \equation 进行网格排版

请查看以下 MWE:

\documentclass[17pt, twocolumn, landscape]{extbook}% \baselineskip=22pt

\newdimen\mathheight
\newdimen\mathdepth

% Redefine \equation for grid typesetting
\makeatletter

\def\equation{$$\refstepcounter{equation}\setbox0\hbox\bgroup$\displaystyle\bgroup}

\def\endequation{\egroup$\egroup% Calculate the value for \vrule
                 \mathheight\ht0
                 \advance\mathheight.3\baselineskip
                 \divide\mathheight\baselineskip
                 \multiply\mathheight\baselineskip
                 \advance\mathheight.7\baselineskip
                 \mathdepth\dp0
                 \advance\mathdepth.7\baselineskip
                 \divide\mathdepth\baselineskip
                 \multiply\mathdepth\baselineskip
                 \advance\mathdepth.3\baselineskip
                 \vrule\@height\mathheight\@depth\mathdepth\@width3pt
                 \box0\eqno\strut\hbox\@eqnnum$$\@ignoretrue}

\makeatother

\usepackage{hyperref}

\lineskip=0pt
\topskip=37.4pt% for split equations

\begin{document}

\abovedisplayskip=22pt
\belowdisplayskip=22pt
\abovedisplayshortskip=22pt
\belowdisplayshortskip=22pt
\parskip=\baselineskip
\jot=22pt

Let's look at a high equation. We must add a \string\strut\ at the end of the line.\strut
\begin{equation}\label{first}
  \int \frac1{\sqrt{1-x^2}} dx = \arcsin x + c
\end{equation}
\strut Here we must place a \string\strut\ again.
If we don't set the \string\strut's the grid typesetting is lost.
Look here:
\begin{equation}\label{second}
  \int \frac1{\sqrt{1-x^2}} dx = \arcsin x + c
\end{equation}
Really ugly...

\newpage\bfseries

Let's look at the second column to verify if the typesetting is grid-oriented.
No problem for equation (\ref{first}).
The \string\strut's and the \string\vrule work together perfectly.
Even the equation number is sitting on the baseline.

Around equation (\ref{second}) we can see that the typesetting
is not grid-oriented. It only works when we insert the \string\strut's\ manually.

The result is really ugly!!

\end{document}

我尝试找到一种用于大型方程式的网格排版解决方案。我的想法是基于将方程式装箱,然后计算“\vrule”的值。但我的解决方案只有在方程式周围插入“\strut”时才有效。

有没有办法自动完成这个操作?

结果:

答案1

您几乎已经用 MWE 完成了所有工作!只需\strut在重新定义中插入 s 即可完成:

结果

\documentclass[17pt, twocolumn, landscape]{extbook}% \baselineskip=22pt

\newdimen\mathheight
\newdimen\mathdepth

% Redefine \equation for grid typesetting
\makeatletter

\def\equation{\strut$$\refstepcounter{equation}\setbox0\hbox\bgroup$\displaystyle\bgroup}

\def\endequation{\egroup$\egroup% Calculate the value for \vrule
                 \mathheight\ht0
                 \advance\mathheight.3\baselineskip
                 \divide\mathheight\baselineskip
                 \multiply\mathheight\baselineskip
                 \advance\mathheight.7\baselineskip
                 \mathdepth\dp0
                 \advance\mathdepth.7\baselineskip
                 \divide\mathdepth\baselineskip
                 \multiply\mathdepth\baselineskip
                 \advance\mathdepth.3\baselineskip
                 \vrule\@height\mathheight\@depth\mathdepth\@width3pt
                 \box0\eqno\strut\hbox\@eqnnum$$\@ignoretrue\strut}

\makeatother

\usepackage{hyperref}

\lineskip=0pt
\topskip=37.4pt% for split equations

\begin{document}

\abovedisplayskip=22pt
\belowdisplayskip=22pt
\abovedisplayshortskip=22pt
\belowdisplayshortskip=22pt
\parskip=\baselineskip
\jot=22pt

Let's look at a high equation. We must add a \string\strut\ at the end of the line.%\strut
\begin{equation}\label{first}
  \int \frac1{\sqrt{1-x^2}} dx = \arcsin x + c
\end{equation}
%\strut
Here we must place a \string\strut\ again.
If we don't set the \string\strut's the grid typesetting is lost.
Look here:
\begin{equation}\label{second}
  \int \frac1{\sqrt{1-x^2}} dx = \arcsin x + c
\end{equation}
Really ugly...? No more!

\newpage\bfseries

Let's look at the second column to verify if the typesetting is grid-oriented.
No problem for equation (\ref{first}).
The \string\strut's and the \string\vrule work together perfectly.
Even the equation number is sitting on the baseline.

Around equation (\ref{second}) we can see that the typesetting
is not grid-oriented. It only works when we insert the \string\strut's\ manually.

The result is really ugly!! Oh what? Maybe not so ugly anymore. Now as the struts are inserted automatically. And we need one more line.

\end{document}

相关内容