![如何使用文字包装描述作为方程式中的术语?](https://linux22.com/image/380334/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E6%96%87%E5%AD%97%E5%8C%85%E8%A3%85%E6%8F%8F%E8%BF%B0%E4%BD%9C%E4%B8%BA%E6%96%B9%E7%A8%8B%E5%BC%8F%E4%B8%AD%E7%9A%84%E6%9C%AF%E8%AF%AD%EF%BC%9F.png)
答案1
那么你可以做的就是使用bmatrix
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\begin{bmatrix}
\text{What I want to} \\
\text{do is this}
\end{bmatrix}
= +
\begin{bmatrix}
\text{A balance equation} \\
\text{I need}
\end{bmatrix}
-
\begin{bmatrix}
\text{Into brackets that} \\
\text{describe things}
\end{bmatrix}
-
\begin{bmatrix}
\text{In two rows between} \\
\text{big brackets}
\end{bmatrix}
\end{equation*}
\end{document}
在某些方面,这可能有点像黑客行为,因为它们可能不是真正的矩阵,但它看起来是正确的。
答案2
这是一个解决方案,它允许在每个“框”中自动换行。材料自动在每行居中。该\Centering
指令(由ragged2e
软件包提供)允许连字符,并且可以很好地平衡框内的行长。(LaTeX 的基本\centering
指令既不允许连字符也不允许平衡行长。)
在以下屏幕截图的上半部分,我0.2\textwidth
为所有四个框选择了相同的宽度。在下半部分,我稍微减小了前两个框的宽度。
\documentclass{article}
\usepackage{geometry} % set page parameters suitably
\usepackage{ragged2e} % for '\Centering' macro
\usepackage{array} % for '\newcolumntype' macro
\newcolumntype{Q}[1]{% % box widths expressed as fractions of '\textwidth'
>{\Centering\arraybackslash}p{#1\textwidth}}
\usepackage{amsmath} % for 'bmatrix' environment
\newcommand\mybox[2]{%
\begin{bmatrix}
\begin{tabular}{@{}Q{#1}@{}}
#2
\end{tabular}
\end{bmatrix}}
\begin{document}
%% first attempt: uniform widths
\[
\mybox{0.2}{What I want to do is this}
= +\mybox{0.2}{A balance equation I need}
-\mybox{0.2}{Intro brackets that describe things}
-\mybox{0.2}{In two rows between big brackets}
\]
%% second attempt: customized widths
\[
\mybox{0.14}{What I want to do is this}
= +\mybox{0.17}{A balance equation I need}
-\mybox{0.20}{Intro brackets that describe things}
-\mybox{0.20}{In two rows between big brackets}
\]
\end{document}
答案3
这与 Mico 的回答一致,建议创建自己的环境 - textmatrix
- 提供一些对齐灵活性(文本列内对齐的可选参数):
\documentclass{article}
\newenvironment{textmatrix}[1][c]
{
\left[
\begin{tabular}{@{} #1 @{}}
}{%
\end{tabular}
\right]
}
\begin{document}
\[
\begin{textmatrix}
What I want to \\
do is this
\end{textmatrix}
=
\begin{textmatrix}[l]
A balanced equation \\
I need
\end{textmatrix}
+
\begin{textmatrix}[r]
into brackets that \\
describe things
\end{textmatrix}
-
\begin{textmatrix}
in two rows between \\
big brackets
\end{textmatrix}
\]
\end{document}