TransWikia.com

Why does raggedright not work inside a minipage in this case?

TeX - LaTeX Asked on December 7, 2020

In trying to suppress underfull box warnings in annotations to equations in align environments, I’m experimenting with raggedright. I’ve discovered that it works inside a parbox but not inside a minipage environment. Why is that?

% !TEX TS-program = lualatexmk
% !TEX encoding = UTF-8 Unicode

documentclass{article}
usepackage{amsmath}

newcommand*{reason}[1]{&&begin{minipage}{3cm}{raggedrightsmall{#1}}end{minipage}}
newcommand*{thereason}[1]{&&parbox[c]{3cm}{raggedrightsmall{#1}}}

begin{document}
begin{align}
  begin{split}
    a &= b + c + d + e + f + g + h + i + j + k + l   
      &quad + m + n + o + o + q + r + s + t + u + v 
      &quad + w + x + y + z 
  end{split} reason{a really stupidly long equation split over multiple lines} 
  begin{split}
    a &= b + c + d + e + f + g + h + i + j + k + l   
      &quad + m + n + o + o + q + r + s + t + u + v 
      &quad + w + x + y + z 
  end{split} thereason{a really stupidly long equation split over multiple lines} 
end{align}
end{document}

One Answer

raggedright does work in minipages as well as in parbox. What matters is the state at the end of the parargaph. In your minipage test, you have extra braces that delimit the raggedright effect before the paragraph is ended.

begin{minipage}{3cm}{raggedrightsmall{#1}}end{minipage}

should be

begin{minipage}{3cm}raggedrightsmall{#1}end{minipage}

though you could do

begin{minipage}{3cm}{raggedrightsmall{#1}par}end{minipage}

Correct answer by Donald Arseneau on December 7, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP