Generaleqparbox with raggedleft

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
daroepi
Posts: 4
Joined: Tue Mar 23, 2010 6:37 pm

eqparbox with raggedleft

Post by daroepi »

I am using eqparbox and want to right-justify a number of words (separated by a newline). I tried to use \raggedleft but it complains with the error:

Code: Select all

Error: ! LaTeX Error: Something's wrong--perhaps a missing \item.
Here is a code sample to illustrate the problem:

Code: Select all

\documentclass{article}
\usepackage{eqparbox}
\begin{document}
\setlength{\parindent}{0in}

\framebox{%
\begin{tabular}{l|l}
\eqparbox[t]{boxtest}{Pythagorean} &
\parbox[t]{2cm}{\raggedleft one \\two \\ three \\ four}
\end{tabular}}
\newline
\framebox{%
\begin{tabular}{l}
\eqparbox[t]{boxtest}{\raggedleft one\\two\\three\\four}  % PROBLEM
\end{tabular}}

\end{document}
Note, the standard parbox can use \raggedleft without a problem, yet eqparbox complains - why is this?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cacajean
Posts: 4
Joined: Fri Feb 04, 2011 7:02 pm

Re: eqparbox with raggedleft

Post by cacajean »

up
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

eqparbox with raggedleft

Post by frabjous »

I'm no expert on eqparboxes, but I gather from the eqparbox manual that since it uses a tabular environment internally, it's best to avoid \\'s internally. Seems to work if you use \linebreak instead:

Code: Select all

\documentclass{article}
\usepackage{eqparbox}
\begin{document}
\setlength{\parindent}{0in}

\framebox{%
\begin{tabular}{l|l}
\eqparbox[t]{boxtest}{Pythagorean} &
\parbox[t]{2cm}{\raggedleft one \\two \\ three \\ four}
\end{tabular}}
\newline
\framebox{%
\begin{tabular}{l}
\eqparbox[t]{boxtest}{\raggedleft one\linebreak two\linebreak three\linebreak four}  % PROBLEM
\end{tabular}}

\end{document}
cacajean
Posts: 4
Joined: Fri Feb 04, 2011 7:02 pm

Re: eqparbox with raggedleft

Post by cacajean »

Completely working!
Post Reply