Created
June 17, 2018 01:19
-
-
Save LanternD/1edd0fcc64f287d841b6da3ec38c69a2 to your computer and use it in GitHub Desktop.
LaTeX - Fixed table column width while aligning text left/center/right
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{array} | |
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} | |
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} | |
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} | |
\begin{document} | |
\begin{tabular}{| c | L{3cm} | C{3cm} | R{3cm} |} | |
foo & | |
A cell with text that wraps around, is raggedright and allows \newline | |
manual line breaks & | |
A cell with text that wraps around, is centered and allows \newline | |
manual line breaks & | |
A cell with text that wraps around, is raggedleft and allows \newline | |
manual line breaks \\ | |
\end{tabular} | |
\end{document} |
Thank you for that, helped my table from looking like a piece of garbage.
Thank you. Very useful!
Good job, Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very helpful.