在增廣矩陣中排版分數

在增廣矩陣中排版分數

我想在增強矩陣中以顯示數學模式排版分數。2一行的分母中的「 」1與下一行的分子中的「 」相接觸,這是不合適的。如何增加行間距?

如何在文字模式下排版分數?

我想要使​​用環境的程式碼array。任何使用該bmatrix環境呈現的程式碼與使用該array環境的程式碼類似,也很容易看到。

\documentclass[10pt]{amsart}

\usepackage{mathtools,array}
\usepackage{amsmath}
\usepackage{amssymb}


\begin{document}

\begin{equation*}
\renewcommand{\arraystretch}{1.2}
\left[
\begin{array}{@{}ccc|r@{}}
1   &   0   &   -1  &   a \\
0   &   1   &   0   &   \dfrac{1}{2} \, a + \dfrac{1}{2} \, b + \dfrac{1}{2} \, c \\
0   &   0   &   1   &  -\dfrac{1}{2} \, a - \dfrac{1}{2} \, b + \dfrac{1}{2} \, c
\end{array}
\right]
\end{equation*}

\end{document}

答案1

我會避免在最後一列中右對齊。

我有三個建議:我認為最好的是最後一個;最糟糕的是中間的那個。

\documentclass{amsart}

\usepackage{mathtools}

\begin{document}

\begin{equation*}
\left[\begin{array}{@{}ccc|c@{}}
1   &   0   &   -1  &   a \\[1ex]
0   &   1   &   0   &  \hphantom{-}\frac{1}{2} a + \frac{1}{2} b + \frac{1}{2} c \\[1ex]
0   &   0   &   1   &  -\frac{1}{2} a - \frac{1}{2} b + \frac{1}{2} c \\[0.5ex]
\end{array}\right]
\end{equation*}

\begin{equation*}
\left[\begin{array}{@{}ccc|c@{}}
1   &   0   &   -1  &   a \\[2ex]
0   &   1   &   0   &  \hphantom{-}\dfrac{1}{2} a + \dfrac{1}{2} b + \dfrac{1}{2} c \\[2ex]
0   &   0   &   1   &  -\dfrac{1}{2} a - \dfrac{1}{2} b + \dfrac{1}{2} c \\[1ex]
\end{array}\right]
\end{equation*}

\begin{equation*}
\left[\begin{array}{@{}ccc|c@{}}
1   &   0   &   -1  &   a \\
0   &   1   &   0   &  (a + b + c)/2 \\
0   &   0   &   1   &  (-a - b + c)/2
\end{array}\right]
\end{equation*}

\end{document}

在此輸入影像描述

答案2

對於數值係數,我首先使用 中的中等大小的分數nccmath,以及empheq同名套件中的環境,然後增加 的值\arraystretch

\documentclass[10pt]{amsart}

\usepackage{nccmath}
\usepackage{empheq}
\usepackage{amssymb}

\begin{document}

\begin{empheq}[left = \empheqlbrack, right =\empheqrbrack]{equation*}
\renewcommand{\arraystretch}{1.75}
\begin{array}{@{\,}ccc|l@{\,}}
1 & 0 & 0 & \phantom{-}a \\
0 & \phantom{-}1 & -1 & \phantom{-}\mfrac{1}{2} \, a + \mfrac{1}{2} \, b + \mfrac{1}{2} \, c \\
0 & 0 & 1 & -\mfrac{1}{2} \, a - \mfrac{1}{2} \, b + \mfrac{1}{2} \, c
\end{array}
\end{empheq}

\end{document}

在此輸入影像描述

答案3

另一種使用nicematrix包的解決方案。您可以使用指令將 a 更多移到右側\mkern-180mu。例如,\mkern-150mu角色a向右移動更多。

註:我沒有看到用戶的正確評論@米科為集\renewcommand{\arraystretch}{2}

在此輸入影像描述

%% Compile and read me!
\documentclass[a4paper,12pt]{article}
\usepackage{nicematrix}
\begin{document}
\renewcommand{\arraystretch}{2}
$\left[\begin{NiceArray}{CCC|R}
1 & 0 & -1 & \mkern-180mu a \\
0 & 1 & 0 & \dfrac{1}{2}  a + \dfrac{1}{2}  b + \dfrac{1}{2}  c \\
0 & 0 & 1 & -\dfrac{1}{2}  a - \dfrac{1}{2}  b + \dfrac{1}{2}  c
\end{NiceArray}\right]$
\end{document}

如果沒有\mkern-180mu 你,將會有這樣的輸出:

在此輸入影像描述

答案4

\dfrac我看不到在此數組中使用的有效理由。更改\dfracto的所有實例\frac,擺脫同樣沒有動機的\,指令,將值\arraystretch從 1.2 增加到 1.333,將第四列的列類型從rto更改l,並插入幾個明智選擇的\phantom指令會產生以下結果:

在此輸入影像描述

\documentclass{amsart}
\begin{document}
\begin{equation*}
\renewcommand{\arraystretch}{1.333}
\left[
\begin{array}{@{}rrr|l@{}}
1 & 0 &-1 & \phantom{-\frac{1}{2}}a \\
0 & 1 & 0 & \phantom{-}\frac{1}{2}a + \frac{1}{2}b + \frac{1}{2}c \\
0 & 0 & 1 & -\frac{1}{2}a - \frac{1}{2}b + \frac{1}{2}c
\end{array}
\right]
\end{equation*}
\end{document}

相關內容