我有两个minipage
相邻的 s,第一个包含描述方程的文本,第二个包含实际的方程。我想垂直对齐文本,以便第一行文本使用与方程相同的基线。
这是我目前得到的,但正如你所见,它并不完全正确。小间距错误让我很烦恼,我觉得我不明白它是如何与垂直间距一起工作的。
\documentclass[a4paper, 11pt, fleqn]{article}
\usepackage{autobreak}
\usepackage[left=15mm,right=15mm]{geometry}
\usepackage{etoolbox}
\newcommand{\zerodisplayskips}{%
\setlength{\abovedisplayskip}{0pt}%
\setlength{\belowdisplayskip}{0pt}%
\setlength{\abovedisplayshortskip}{0pt}%
\setlength{\belowdisplayshortskip}{0pt}}
\appto{\normalsize}{\zerodisplayskips} % To omit vertical spacing in the align-environment
\newlength{\equationheight}
\setlength{\mathindent}{0pt}
\newcommand{\textWidth}{.17\linewidth}
\newcommand{\eqnWidth}{.81\linewidth}
\begin{document}
\paragraph{Long-Term Load}\mbox{}\\[-1.4ex]
\settoheight{\equationheight}{$\alpha_{\mathrm{long}}=\alpha(1+\varphi_{\mathrm{creep}})$}
\addtolength{\equationheight}{-1ex}
\begin{minipage}[t]{\textWidth}
\vspace{0ex} \vspace{\equationheight} Stiffness Ratio, Long-term \raggedright
\end{minipage}
\hfill
\begin{minipage}[t]{\eqnWidth}
\begin{align*}
\begin{autobreak}
\alpha_{\mathrm{long}}=\alpha(1+\varphi_{\mathrm{creep}})=6.06(1+0)=6.06
\end{autobreak}
\end{align*}
\end{minipage}\\[0.5ex]
%
\settoheight{\equationheight}{$\dfrac{\dfrac{b\,h^2}{2} + (\alpha_{\mathrm{long}}-1)A_{\mathrm{s}} \, d}{A_{\mathrm{I,long}}}$}
\addtolength{\equationheight}{-1ex}
\begin{minipage}[t]{\textWidth}
\vspace{0ex} \vspace{\equationheight} Distance to C.o.G \raggedright
\end{minipage}
\hfill
\begin{minipage}[t]{\eqnWidth}
\begin{align*}
\begin{autobreak}
x_{\mathrm{I,long}}
=\dfrac{\dfrac{b\,h^2}{2} + (\alpha_{\mathrm{long}}-1)A_{\mathrm{s}} \, d}{A_{\mathrm{I,long}}}
=\dfrac{\dfrac{300\cdot600^2}{2} + (6.06-1)679 \cdot 564}{183434}
=304.9\text{ mm}
\end{autobreak}
\end{align*}
\end{minipage}\\[0.5ex]
%
\settoheight{\equationheight}{$\dfrac{b \, h^3}{12} + b \, h (\dfrac{h}{2}-x_{\mathrm{I,long}})^2 + (\alpha_{\mathrm{long}}-1) A_{\mathrm{s}} \, (d-x_{\mathrm{I,long}})^2$}
\addtolength{\equationheight}{-1ex}
\begin{minipage}[t]{\textWidth}
\vspace{0ex} \vspace{\equationheight} Second Moment of Area \raggedright
\end{minipage}
\hfill
\begin{minipage}[t]{\eqnWidth}
\begin{align*}
\begin{autobreak}
I_{\mathrm{I,long}}
=\dfrac{b \, h^3}{12} + b \, h (\dfrac{h}{2}-x_{\mathrm{I,long}})^2 + (\alpha_{\mathrm{long}}-1) A_{\mathrm{s}} \, (d-x_{\mathrm{I,long}})^2
=\dfrac{300\cdot600^3}{12} + 300\cdot600 (\dfrac{600}{2}-304.9)^2 + (6.06-1) 679 (564-304.9)^2
=5.63\cdot10^9 mm^4
\end{autobreak}
\end{align*}
\end{minipage}\\[0.5ex]
\end{document}
输出:
有人能帮我理解我遗漏了什么吗?我以为
\settoheight{\equationheight}{...<equation>...}
...
\vspace{\equationheight} <text>
足以获得文本和方程的相同基线。
附言:align*
和autobreak
环境始终存在,因为我无法完全控制输入,而且有时方程式太长而无法容纳一行。
答案1
我的解决方案仅基于 TeX 基元和纯 TeX 宏。基本思想是每个都\eqline
包含\hbox
两个\vtop
s,因为您需要将第一行对齐。第一个包括和\vtop
的设置。第二个包括两列,声明为等式的左侧和右侧。等式中的更多行必须用 分隔。\hsize
\raggedright
\vtop
\halign
\displaystyle
\cr
\def\eqlin#1#2{\medskip\hbox{\vtop{\hfuzz=2pt \hsize=.17\hsize \raggedright \noindent#1}%
\kern.02\hsize
\vtop{\halign{\hfil$\displaystyle##$&$\displaystyle{}##$\hfil\cr#2\crcr}}}}
\eqlin{Stiffness Ratio, Long-term}
{\alpha_{\rm long} &= \alpha(1+\varphi_{\rm creep}) = 6.06(1+0) = 6.06}
\eqlin{Distance to C.o.G}
{x_{\rm I,long} &= {\displaystyle {b\,h^2\over2} + (\alpha_{\rm long} - 1) A_{\rm s} d \over A_{\rm I,long}}
= {\displaystyle {300\cdot600^2\over2} + (6.06-1)\,697\cdot564 \over 183434} = 304.9\,\rm mm
}
\eqlin{Second Moment of Area}
{I_{\rm I,long} &= {b\,h^3\over12} + b\,h \left({h\over2}-x_{\rm I,long}\right)^2
+ (\alpha_{\rm long} - 1)\, A_{\rm s}\, (d-x_{\rm I,long}) \cr
&= {300\cdot600^3\over12} + 300\cdot600\,\left({600\over2} - 304.9\right)^2
+ (6.06 - 1)\,679\,(564-304.9)^2 \cr
&= 5.63\cdot 10^9 \rm mm^4
}
\bye
编辑好的,根据您的评论:有第二种解决方案,它实现了一个简单的“自动中断”功能:第一个等号的行为类似于&=
,另一个等号的行为类似于\penalty0{}=
,这是一个可能的断点。此外,所有等式中的等号都是对齐的。
\def\adef#1{\catcode`#1=13 \begingroup \lccode`\~=`#1\lowercase{\endgroup\def~}}
\def\eqA{&=}
\def\eqlin{\bgroup\let\tmp=\relax \adef={\ifx\tmp\relax\expandafter\eqA\else\penalty0{}=\fi}\eqlinA}
\def\eqlinA#1#2{\medskip\hbox to\hsize{\vtop{\hfuzz=2pt \hsize=.17\hsize \raggedright \noindent#1}%
\hfil
\vtop{\halign{\hfil$\displaystyle##$&\vtop{\hsize=.74\hsize
\rightskip=0pt plus1fil\noindent\binoppenalty=10000 \let\tmp=\empty
$\displaystyle{}##$}\hfil\cr#2\crcr}}}\egroup}
\eqlin{Stiffness Ratio, Long-term}
{\alpha_{\rm long} = \alpha(1+\varphi_{\rm creep}) = 6.06(1+0) = 6.06}
\eqlin{Distance to C.o.G}
{x_{\rm I,long} = {\displaystyle {b\,h^2\over2} + (\alpha_{\rm long} - 1) A_{\rm s} d \over A_{\rm I,long}}
= {\displaystyle {300\cdot600^2\over2} + (6.06-1)\,697\cdot564 \over 183434}
= 304.9\,\rm mm
}
\eqlin{Second Moment of Area}
{I_{\rm I,long} = {b\,h^3\over12} + b\,h \left({h\over2}-x_{\rm I,long}\right)^2
+ (\alpha_{\rm long} - 1)\, A_{\rm s}\, (d-x_{\rm I,long})
= {300\cdot600^3\over12} + 300\cdot600\,\left({600\over2} - 304.9\right)^2
+ (6.06 - 1)\,679\,(564-304.9)^2
= 5.63\cdot 10^9 \rm mm^4
}
\bye
答案2
我提出了一个更简单的解决方案,没有。为了更好地格式化带单位的数字,autobreak
我添加了所有符号的垂直对齐:siunitx
=
\documentclass[a4paper, 11pt, fleqn]{article}
\usepackage{autobreak}
\usepackage[hmargin=15mm, showframe]{geometry}
\usepackage{etoolbox}
\newcommand{\zerodisplayskips}{%
\setlength{\abovedisplayskip}{0pt}%
\setlength{\belowdisplayskip}{0pt}%
\setlength{\abovedisplayshortskip}{0pt}%
\setlength{\belowdisplayshortskip}{0pt}}
\appto{\normalsize}{\zerodisplayskips} % To omit vertical spacing in the align-environment
\setlength{\mathindent}{0pt}
\usepackage{siunitx}
\sisetup{exponent-product =\cdot}
\newcommand\descrbox[1]{\parbox[t]{0.2\linewidth}{\raggedright#1}}
\begin{document}
\paragraph{Long-Term Load}\mbox{}\\[-1.4ex]
\begin{align*}
& \descrbox{Stiffness Ratio, Long-term\raggedright} & \alpha_{\mkern1mu\mathrm{long}} & =\alpha(1+\varphi_{\mathrm{creep}})=6.06(1+0)=6.06 \\
& \descrbox{Distance to C.o.G}& x_{\mkern1mu\mathrm{I,long}}
&=\dfrac{\dfrac{b\,h^2}{2} + (\alpha_{\mathrm{long}}-1)A_{\mathrm{s}} \, d}{A_{\mathrm{I,long}}}
=\dfrac{\dfrac{300\cdot600^2}{2} + (6.06-1)679 \cdot 564}{183434} = \SI{304.9}{mm}\\[1.5ex]
& \descrbox{Second Moment of Area}
&I_{\mathrm{I,long}}
& =\dfrac{b \, h^3}{12} + b \, h \Bigl(\dfrac{h}{2}-x_{\mathrm{I,long}}\Bigr)^2 + (\alpha_{\mathrm{long}}-1) A_{\mathrm{s}} \, (d-x_{\mathrm{I,long}})^2 \\
& & & =\dfrac{300\cdot600^3}{12} + 300\cdot600\Bigl(\dfrac{600}{2}-304.9\Bigr)^2 + (6.06-1) 679 (564-304.9)^2 \\
& & & =\SI{5.63e9}{mm^4}
\end{align*}
\end{document}
答案3
使用minipages
必须是没有它(希望我能正确理解问题)我得到以下结果:
如果改用minipages
这种方法,tabularx
代码就会变得更加简单(并且简洁):
\documentclass[a4paper, 11pt, fleqn]{article}
\usepackage[showframe,
left=15mm,right=15mm]{geometry}
\usepackage{amsmath}
\usepackage{booktabs,tabularx}
\usepackage[exponent-product=\cdot]{siunitx}
\begin{document}
\paragraph{Long-Term Load}\mbox{}\\%[-1.4ex]
\noindent%
\begin{tabularx}{\linewidth}{@{}>{\raggedright}X>{$\displaystyle}l<{$}}
Stiffness Ratio, Long-term
& \alpha_{\mathrm{long}}
= \alpha(1+\varphi_{\mathrm{creep}})
= 6.06(1+0)
= 6.06
\\ \addlinespace[1ex]
Distance to C.o.G
& x_{\mathrm{I,long}}
= \dfrac{\dfrac{b\,h^2}{2} + (\alpha_{\mathrm{long}}-1)A_{\mathrm{s}}\, d}
{A_{\mathrm{I,long}}}
= \dfrac{\dfrac{300\cdot600^2}{2} + (6.06-1)679 \cdot 564}{183434} %\\
= \SI{304.9}{mm}
\\ \addlinespace[3ex]
Second Moment of Area
& \begin{aligned}[t]
I_{\mathrm{I,long}}
& = \dfrac{b \, h^3}{12} + b \, h (\dfrac{h}{2}-x_{\mathrm{I,long}})^2 +
(\alpha_{\mathrm{long}}-1) A_{\mathrm{s}} \, (d-x_{\mathrm{I,long}})^2 \\
& = \dfrac{300\cdot600^3}{12} + 300\cdot600 (\dfrac{600}{2}-304.9)^2 +
(6.06-1) 679 (564-304.9)^2
\\
& = \SI{5.6e9}{mm^4}
\end{aligned}
\end{tabularx}
\end{document}