How do I use word-wrapped descriptions as terms in equations?

Here's a solution that allows for automatic line breaking in each of the "boxes". The material is automatically centered on each line. The \Centering instruction (provided by the ragged2e package) allows hyphenation and does a reasonably good job of balancing the line lengths within a box. (LaTeX's basic \centering instruction does not allow either hyphenation or line-length balancing.)

In the upper half of the following screenshot, I chose a common width of 0.2\textwidth for all four boxes. In the lower half, I reduced the widths of the first two boxes a bit.

enter image description here

\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}

This is in-line with Mico's answer suggesting to create your own environment - textmatrix - that provides some alignment flexibility (optional argument for alignment within the text column):

enter image description here

\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}

Well what you could do is simply use a 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}

It's maybe a bit of a hack in some ways since they're probably not really matrices, but it looks right.

enter image description here

Tags:

Equations