Guest User

Untitled

a guest
Jan 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. documentclass{article}
  2.  
  3. usepackage[showframe,papersize={5.5in,8.5in}]{geometry}
  4. newlength{testwd}
  5.  
  6. newcommand{entry}[4][]{%
  7. setbox1=hbox{strutbfseries#2}%
  8. setbox2=hbox{strutitshape#3}%
  9. setbox3=hbox{strut#4}%
  10. setlength{testwd}{ifdimwd1>wd3 wd1elsewd3fi}% Which is longer, L or R? Use it.
  11. noindent%
  12. if###1##elsellap{#1thinspace}fi
  13. hbox to 0pt{box1hss}%
  14. hfill
  15. %% If the longer side (L or R) is longer than the half the remaining area around
  16. %% the center text, drop the center text.
  17. ifdimdimexpr testwd - (linewidth - wd2)/2relax>0ptlowerbaselineskipfi
  18. hbox{box2}%
  19. hfill
  20. hbox to 0pt{hssbox3}%
  21. par
  22. }
  23.  
  24. begin{document}
  25.  
  26. entry{Left side text}{Center Text}{Right text}
  27.  
  28. entry{Left side text that is rather long}{Center Text}{Right side text}
  29.  
  30. entry{Left side text}{Center Text}{Right side text that is rather long}
  31.  
  32. end{document}
  33.  
  34. documentclass{article}
  35.  
  36. usepackage[showframe,papersize={5.5in,8.5in}]{geometry}
  37.  
  38. usepackage{makecell}
  39.  
  40. newlength{LeftItem}
  41. newlength{CentreItem}
  42. newlength{RightItem}
  43.  
  44. newcommand{entry}[3]{%
  45. par
  46. settowidth{LeftItem}{bfseries #1}%
  47. settowidth{CentreItem}{itshape #2}%
  48. settowidth{RightItem}{#3}%
  49. noindent
  50. makebox[0pt][l]{bfseries #1}hfill
  51. makebox[0pt]{%
  52. ifdimLeftItem>.5dimexprlinewidth-CentreItemrelax
  53. makecell[t]{strut \ itshape #2}%
  54. else
  55. ifdimRightItem>.5dimexprlinewidth-CentreItemrelax
  56. makecell[t]{strut \ itshape #2}%
  57. else
  58. itshape #2%
  59. fi
  60. fi
  61. }hfill
  62. makebox[0pt][r]{#3}%
  63. par
  64. }
  65.  
  66. begin{document}
  67.  
  68. entry{Left side text}{Center Text}{Right text}
  69.  
  70. entry{Left side text that is rather long}{Center Text}{Right side text}
  71.  
  72. entry{Left side text}{Center Text}{Right side text that is rather long}
  73.  
  74. end{document}
  75.  
  76. newcommand{entry}[3]{%
  77. % ...
  78. settowidth{CentreItem}{itshape ~#2~}% Add space on either side of centre item
  79. % ...
  80. }
Add Comment
Please, Sign In to add comment