Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass{article}
- usepackage[showframe,papersize={5.5in,8.5in}]{geometry}
- newlength{testwd}
- newcommand{entry}[4][]{%
- setbox1=hbox{strutbfseries#2}%
- setbox2=hbox{strutitshape#3}%
- setbox3=hbox{strut#4}%
- setlength{testwd}{ifdimwd1>wd3 wd1elsewd3fi}% Which is longer, L or R? Use it.
- noindent%
- if###1##elsellap{#1thinspace}fi
- hbox to 0pt{box1hss}%
- hfill
- %% If the longer side (L or R) is longer than the half the remaining area around
- %% the center text, drop the center text.
- ifdimdimexpr testwd - (linewidth - wd2)/2relax>0ptlowerbaselineskipfi
- hbox{box2}%
- hfill
- hbox to 0pt{hssbox3}%
- par
- }
- begin{document}
- entry{Left side text}{Center Text}{Right text}
- entry{Left side text that is rather long}{Center Text}{Right side text}
- entry{Left side text}{Center Text}{Right side text that is rather long}
- end{document}
- documentclass{article}
- usepackage[showframe,papersize={5.5in,8.5in}]{geometry}
- usepackage{makecell}
- newlength{LeftItem}
- newlength{CentreItem}
- newlength{RightItem}
- newcommand{entry}[3]{%
- par
- settowidth{LeftItem}{bfseries #1}%
- settowidth{CentreItem}{itshape #2}%
- settowidth{RightItem}{#3}%
- noindent
- makebox[0pt][l]{bfseries #1}hfill
- makebox[0pt]{%
- ifdimLeftItem>.5dimexprlinewidth-CentreItemrelax
- makecell[t]{strut \ itshape #2}%
- else
- ifdimRightItem>.5dimexprlinewidth-CentreItemrelax
- makecell[t]{strut \ itshape #2}%
- else
- itshape #2%
- fi
- fi
- }hfill
- makebox[0pt][r]{#3}%
- par
- }
- begin{document}
- entry{Left side text}{Center Text}{Right text}
- entry{Left side text that is rather long}{Center Text}{Right side text}
- entry{Left side text}{Center Text}{Right side text that is rather long}
- end{document}
- newcommand{entry}[3]{%
- % ...
- settowidth{CentreItem}{itshape ~#2~}% Add space on either side of centre item
- % ...
- }
Add Comment
Please, Sign In to add comment