LaTeX forum ⇒ Graphics, Figures & Tablestabularx uppercase all

Information and discussion about graphics, figures & tables in LaTeX documents.
comandos
Posts: 5
Joined: Sat Dec 15, 2018 3:46 pm

tabularx uppercase all

Postby comandos » Fri Aug 09, 2019 11:52 pm

Greetings,

I wish to uppercase/makeuppercase every entry in a tabularx table. Any suggestions? (Beside doing it manually for every entry.)
I tried using the command in the following manner but it didn’t work.

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \begin{tabularx}{\textwidth\MakeUppercase\bfseries\large}{l X}
  2. Test 1 & test 2 \\
  3. Test 1 & test 2 \\
  4. Test 1 & test 2 \\
  5. Test 1 & test 2 \\
  6. \end{tabularx}


Best regards

kaiserkarl13
Posts: 636
Joined: Tue Mar 25, 2008 5:02 pm

Postby kaiserkarl13 » Sun Aug 11, 2019 8:08 pm

I got something to work by defining an environment (using environ) that makes everything inside it uppercase:
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass{article}
  2. \usepackage{tabularx}
  3. \usepackage{environ}
  4. \begin{document}
  5. \NewEnviron{Uppercase}
  6. {\MakeUppercase{\BODY}}
  7. \begin{tabularx}{\textwidth}{>{\begin{Uppercase}}l<{\end{Uppercase}} X}
  8. Test 1 & test 2 \\
  9. Test 3 & test 4 \\
  10. \end{tabularx}
  11. \end{document}

rais
Posts: 250
Joined: Sun Nov 16, 2014 8:51 pm

Postby rais » Mon Aug 12, 2019 7:37 pm

@comandos: even if the tabularx environment would allow stuff like that in its first argument (which it doesn't, it expects a length there), \MakeUppercase expects an argument, Since there are no braces, it would grab the \bfseries command, biut since there's no text...

The easiest way would be to use small caps instead of all uppercase, then you could say
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. {\scshape\bfseries\large
  2. \begin{tabularx}[\textwidth}{lX}
  3. %table's contents
  4. \end{tabularx}
  5. }

Then again, small caps may not be available for your font at your used encoding
.
An alternate to kaiserkarl13's example might be the usage of collcell package:
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage{tabularx}
  4. \usepackage{collcell}
  5. \newcommand\tabfmt[1]{\MakeUppercase{\bfseries\large#1}}
  6. \newcolumntype{E}{>{\collectcell\tabfmt}X<{\endcollectcell}}
  7. \begin{document}
  8. \begin{tabularx}{\textwidth}{>{\collectcell\tabfmt}l<{\endcollectcell} E}
  9. Test 1 & test 2 \\
  10. Test 1 & test 2 \\
  11. Test 1 & test 2 \\
  12. Test 1 & test 2 \\
  13. \end{tabularx}
  14. \end{document}

KR
Rainer

comandos
Posts: 5
Joined: Sat Dec 15, 2018 3:46 pm

Postby comandos » Wed Aug 14, 2019 6:46 pm

I know I'm doing it wrong but thank you both!
Both examples were helpful.


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 8 guests