我如何获得以下输出?
f a b c =
<centered definition of f>
g a b c d =
<centered definition of g>
这些是函数的定义,但是函数体很大;我想将函数和参数移到左边,但将函数体置于中央。
困难在于(函数和参数)+(函数定义)的长度大于列的长度。我无法找到使用 、 、 和 中的任何一个来做到这multline
一点align
的alignat
方法flalign
。
答案1
滥用flalign
;-)
在我看来,将第一部分刷新到边缘似乎不太好,因此我提供了两个宏来将其向前推;使用 ,\rhide
您可以将其对齐到右端,反之亦然\lhide
。
\documentclass{article}
\usepackage{showframe}
\usepackage{mathtools}
\newcommand{\rhide}[2]{\mathrlap{\hspace{#1}\mathllap{#2}}}
\newcommand{\lhide}[2]{\mathrlap{\hspace{#1}#2}}
\begin{document}
\begin{flalign*}
\mathrlap{f a b c ={}}\\
&& <very very very very long centered definition of f>&&\\
\mathrlap{g a b c d ={}}\\
&& <very very very very long centered definition of g>&&
\end{flalign*}
\begin{flalign*}
\rhide{8em}{f a b c ={}}\\
&& <very very very very long centered definition of f>&&\\
\rhide{8em}{g a b c d ={}}\\
&& <very very very very long centered definition of g>&&
\end{flalign*}
\begin{flalign*}
\lhide{4em}{f a b c ={}}\\
&& <very very very very long centered definition of f>&&\\
\lhide{4em}{g a b c d ={}}\\
&& <very very very very long centered definition of g>&&
\end{flalign*}
\end{document}
答案2
如果也允许使用棘手的解决方案...我们使用的事实是,将gather
线条居中。棘手的是\intertext
。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather*}
\intertext{$f a b c ={}$}
<very very very very long centered definition of f>\\
\intertext{$g a b c d ={}$}\\
<very very very very long centered definition of g>
\end{gather*}
\begin{gather*}
\intertext{\hfill$f a b c ={}$}
<very very very very long centered definition of f>\\
\intertext{\hfill$g a b c d ={}$}\\
<very very very very long centered definition of g>
\end{gather*}
\end{document}
答案3
您是否尝试过将正文的字体大小调小?我想这样可以更轻松地有效使用其中一个环境。或者尝试使用环境tabular
?