1

I am trying to create legend for fraction

some text

\[Y = \frac{X_{A}}{X_{AB}}\]

$\begin{array}{l l}
     X_{A}:         & \text{Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book}  \\ 
     X_{AB}:         & \text{Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.} \\
  \end{array}$

some other text

Result:

enter image description here

Any possible solution? The lines are without spaces and part is outside the document.

Ady96
  • 157
  • 1
    Just a guess, do you have \usepackage{amsmath} in your preamble? It's required for \text{}. Or mathtools would also do I believe – Au101 May 25 '19 at 01:42
  • 1
    "and part is outside the document" Yes are you sure a simple table wouldn't do the job just as well – Au101 May 25 '19 at 01:43
  • Welcome to tex.sx. For this sort of material, it's usually better to use a tabular approach, with the second element of each line treated as a paragraph (ragged right will usually look better than justified text). I'm sure this has been treated before but I haven't found a good example. Something like a nomenclature package might also be useful. – barbara beeton May 25 '19 at 01:43

2 Answers2

2

As you are not providing the MWE, I assume that the below code may help you:

\documentclass{book}
\usepackage{array}
\begin{document}

\newlength{\tabuserlength}%
\setlength{\tabuserlength}{\textwidth}%
\addtolength{\tabuserlength}{-1.5pc}%

\[
Y = \frac{X_{A}}{X_{AB}}
\]
\begin{tabular}{@{}m{1.5pc}p{\tabuserlength}@{}}
    $ X_{A}$:         & Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book \\ 
    $ X_{AB}$:         & Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
\end{tabular}

\end{document}

Another method tabularx, which suggested by Mico, is better than the previous one, and the code is:

\documentclass{book}
\usepackage{tabularx}
\begin{document}

\[
Y = \frac{X_{A}}{X_{AB}}
\]
\begin{tabularx}{1\linewidth}{@{}lX@{}}
    $ X_{A}$:         & Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book \\ 
    $ X_{AB}$:         & Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
\end{tabularx}

\end{document}
MadyYuvi
  • 13,693
  • 1
    This setup doesn't guarantee that the tabular environment will fit inside the width of the textblock. Can you think of a solution that uses a tabularx environment? – Mico May 25 '19 at 05:22
  • @Mico Thanks, modified the answer... – MadyYuvi May 25 '19 at 05:31
2

Here's a solution that employs a customized \parbox to typeset the explanatory material.

enter image description here

The default width of \mybox is 3in; you're obviously free to choose a different value. You can also override the default width on a case by case basis, e.g., by writing \mybox[5cm]{...}.

\documentclass{article}
\usepackage{mathtools,ragged2e}
%% Default width of \mybox is 3in:
\newcommand\mybox[2][3in]{\parbox[t]{#1}{\RaggedRight #2}}

\begin{document}

\begin{align*}
Y &= \frac{X_{A}}{X_{AB}}\\
\shortintertext{where}
X_{A} &\quad \mybox{Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.}  \\ 
X_{AB} &\quad \mybox{Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.} 
\end{align*}

\end{document}
Mico
  • 506,678