TeX - LaTeX Asked by lhk on October 2, 2021
Here is an example of a parbox that produces both an underfull and an overfull warning:
parbox{100pt}{A set of comparison triplets (T = { (i,j,l) | z_i ;is; more; similar; to; z_j; than; z_l}) is given.}
When rendered to pdf, it looks like this:
Apparently, parts of the formula can’t be broken up across multiple lines.
I would like to allow Latex to linebreak the text within the curly braces and to position it like the other text in the parbox. Is that possible?
I have searched for similar questions:
Why do I have overfull hbox when I use inline math without line breaks The answer explains the difference between ${...}$
and $...$
. I’m already using the latter, so I would expect linebreaks to work for me.
How can I split an equation over two (or more) lines This seems to target equations that are in their own line already. I would like the equation to be embedded in the text.
Break an inline math formula The accepted answer does a complex redefinition of the comma sign, based on the showframe package. But another answer points to allowbreak.
There is also this: How to auto linebreak before/after parenthesis in inline math But to be honest, I don’t understand what the accepted answer is doing (some parts of latex are still completely magic to me).
allowbreak works for me as well. I can define specific points at which the equation may be broken up. But how can I avoid sprinkling allowbreak everywhere in my math typesetting?
The following code works (well it still produces an underfull warning, but that’s my text content and has nothing to do with the inline formula) but is horrible to read and edit:
parbox{100pt}{A set of comparison triplets (T = { (i,j,l) | allowbreak z_i ; allowbreak is; allowbreak more; allowbreak similar; allowbreak to; allowbreak z_j; allowbreak than; allowbreak z_l}) is given.}
The general recommendation I give is to avoid long textual set builder notation: readers will be very tired when looking at the text and they'll have a hard time in isolating the closing brace.
A set $T$ consisting of comparison triplets $(i,j,l)$ such that $z_i$
is more similar to $z_j$ than $z_l$ is given.
However, if you use the set builder notation, it is not a set, but the set:
The set $T$ consisting of all comparison triplets $(i,j,l)$ such that $z_i$
is more similar to $z_j$ than $z_l$ is given.
If you insist in using the set builder notation, go back and forth in and out of math mode:
The set of comparison triplets $T={(i,j,l)mid z_i$
is more similar to $z_j$ than $z_l}$ is given.
I used twocolumn
in order to emulate your problem. Note mid
and not the simple |
that has wrong spacing around it.
Alternative way: define a symbol.
documentclass[twocolumn]{article}
newcommand{MST}{mathrm{MST}}
begin{document}
Define the ternary relation ``is more similar to than'' on the positive integers
by stipulating that $MST(i,j,l)$ holds if and only if $z_i$ is more similar
to $z_j$ than $z_l$ and set
[
T={(i,j,l)mid MST(i,j,l)}
]
end{document}
Correct answer by egreg on October 2, 2021
You can just put text in textmode.
documentclass[12pt,a4paper]{article}
usepackage{amsmath}
begin{document}
parbox{100pt}{A set of comparison triplets $T={(i,j,l) | z_i$ is more similar to $z_j$ than $z_l}$ is given.}
end{document}
Answered by AboAmmar on October 2, 2021
Personally I think the set builder notation is appropriate, but stylistically, I would say this (or really anything this long) should be a displayed equation, simply because it's much easier to read that way than as an inline equation.
parbox{100pt}{
A set of comparison triplets
[
T = { (i,j,l) mid text{$z_i$ is more similar to $z_j$ than $z_l$}}
]
is given.
}
(Note that I also changed it to use text
for the text part of the equation, which requires including the amsmath
package. Additionally, using mid
instead of |
puts the correct spacing around the vertical bar.)
That doesn't solve the overful/underfull hbox issue by itself, but by using the multline
environment, also provided by amsmath
, you can add line breaks yourself:
documentclass{article}
usepackage{amsmath}
begin{document}
parbox{100pt}{
A set of comparison triplets
begin{multline*}
T = { (i,j,l) mid text{$z_i$ is}
text{more similar to $z_j$}
text{than $z_l$}}
end{multline*}
is given.
}
end{document}
Admittedly, this still looks a little bit silly, but I'm hoping the 100pt column is just for the sake of the example and you actually have at least a little bit more space than that.
You can use to insert line breaks in the
multline
environment, but they have to be outside of any command, which is why I've had to put several separate text
commands.
You can remove the *
from multline*
to give it an equation number. (I recommend always numbering displayed equations.) Also note that, for some reason, it's "multline" with one 'i', and not "multiline" as you might expect.
Answered by Nathaniel on October 2, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP