如何仅将单列的内容居中对齐?

如何仅将单列的内容居中对齐?

在此处输入图片描述

我试图用它nicematrix来很好地说明所呈现的材料,并很好地对齐所解释的条目。我想要的内容

p1、p2、p3

保持顶部对齐,如图所示。但是,

p_{1} + p_{2} + p_{3} = 1

必须正好走到中间

我的MWE

\documentclass{article}

\usepackage{calc}

\usepackage{nicematrix}
\newlength{\widthWidest}

\begin{document}
    
\setlength{\widthWidest}{\widthof{weight of constant impedance, constant current,}}
\begin{NiceTabularX}{\linewidth}{@{}r p[l]{\widthWidest} X[l, p]@{}}
    
    $p_{1}, \medspace p_{2}, \medspace p_{3}$ & weight of constant impedance, constant current, and constant power components of the real portion of loads & $p_{1} + p_{2} + p_{3} = 1$
    
    \CodeAfter
    \SubMatrix{.}{1-1}{1-2}{\rbrace}
    
\end{NiceTabularX}
    
\end{document}

答案1

使用最新版本nicematrix(6.14 版2023/02/18)。

\documentclass{article}
\usepackage{calc}
\usepackage{nicematrix}
\newlength{\widthWidest}

\begin{document}
    
\setlength{\widthWidest}{\widthof{weight of constant impedance, constant current,}}
\begin{NiceTabularX}{\linewidth}{@{}r p[l]{\widthWidest} X[l, p]@{}}
    
    $p_{1}, \medspace p_{2}, \medspace p_{3}$ & weight of constant impedance, constant current, and constant power components of the real portion of loads & \Block[v-center]{}{$p_{1} + p_{2} + p_{3} = 1$}
    \CodeAfter
    \SubMatrix{.}{1-1}{1-2}{\rbrace}
\end{NiceTabularX}
    
\end{document}

与往常一样nicematrix,您需要进行多次编译。

上述代码的输出

答案2

我认为没有理由使用整个文本宽度;相反,我认为有理由不是到。

\documentclass{article}

\usepackage{lipsum}

\newlength{\auxlen}

\begin{document}

\lipsum[12][1-4]    
\[
\settowidth{\auxlen}{%
  $p_{1}$, $p_{2}$, $p_{3}$\hspace{6em}$p_{1} + p_{2} + p_{3} = 1$%
}
\left.
\begin{tabular}{@{} l p{\dimexpr\displaywidth-\auxlen} l @{}}
    $p_{1}$, $p_{2}$, $p_{3}$ &
    weight of constant impedance, constant current,
    and constant power components of the real portion of loads
\end{tabular}
\right\}
p_{1} + p_{2} + p_{3} = 1
\]
\lipsum[19][1-3]
    
\end{document}

在此处输入图片描述

不同的提议

\documentclass{article}
\usepackage{amsmath}

\usepackage{lipsum}

\begin{document}

\lipsum[12][1-4]    
\begin{gather*}
\left.
\begin{tabular}{@{} l l @{}}
$p_{1}$ & weight of constant impedance \\
$p_{2}$ & constant current \\
$p_{3}$ & constant power components
\end{tabular}
\right\}
\text{of the real portion of loads}
\\
p_{1} + p_{2} + p_{3} = 1
\end{gather*}
\lipsum[19][1-3]
    
\end{document}

在此处输入图片描述

答案3

tabularray通过将花括号插入为表格的垂直线,可以使用该包生成您想要的内容。

在此处输入图片描述

\documentclass{article}

\usepackage{calc}
\usepackage{tabularray}

\newlength{\widthWidest}

\begin{document}
    
    \setlength{\widthWidest}{\widthof{weight of constant impedance, constant current,}}
    \begin{tblr}{
        width=\linewidth,   
        colspec={@{}r h{\widthWidest} X[l, m]@{}},
        column{1}={h, mode=math},
        column{2}={rightsep=0pt},
        column{3}={mode=math},
        vline{3} = {text=$\Bigg\}$}
    }
        p_{1}, \medspace p_{2}, \medspace p_{3} & weight of constant impedance, constant current, and constant power components of the real portion of loads & p_{1} + p_{2} + p_{3} = 1
    \end{tblr}
\end{document}

相关内容