Graphics, Figures & Tablestabularx uppercase all

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

tabularx uppercase all

Post by comandos »

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

\begin{tabularx}{\textwidth\MakeUppercase\bfseries\large}{l X}
    Test 1 & test 2  \\
    Test 1 & test 2  \\
    Test 1 & test 2  \\
    Test 1 & test 2  \\
  \end{tabularx}
Best regards

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

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

tabularx uppercase all

Post by kaiserkarl13 »

I got something to work by defining an environment (using environ) that makes everything inside it uppercase:

Code: Select all

\documentclass{article}
\usepackage{tabularx}
\usepackage{environ}
\begin{document}
\NewEnviron{Uppercase}
    {\MakeUppercase{\BODY}}
\begin{tabularx}{\textwidth}{>{\begin{Uppercase}}l<{\end{Uppercase}} X}
    Test 1 & test 2 \\
    Test 3 & test 4 \\
\end{tabularx}
\end{document}
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

tabularx uppercase all

Post by rais »

@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

{\scshape\bfseries\large
\begin{tabularx}[\textwidth}{lX}
%table's contents
\end{tabularx}
}
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

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tabularx}
\usepackage{collcell}
\newcommand\tabfmt[1]{\MakeUppercase{\bfseries\large#1}}
\newcolumntype{E}{>{\collectcell\tabfmt}X<{\endcollectcell}}
\begin{document}
  \begin{tabularx}{\textwidth}{>{\collectcell\tabfmt}l<{\endcollectcell} E}
    Test 1 & test 2  \\
    Test 1 & test 2  \\
    Test 1 & test 2  \\
    Test 1 & test 2  \\
  \end{tabularx}
\end{document}
KR
Rainer
comandos
Posts: 15
Joined: Sat Dec 15, 2018 3:46 pm

tabularx uppercase all

Post by comandos »

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