Graphics, Figures & Tables ⇒ auto-size table width to make use of all space available
auto-size table width to make use of all space available
problem: table is width-wise, very long and runs off the page
do not want to manually set column width for columns. too much thinking and effort. want an automatic solution.
Latex editor of choice: TexWorks (for dual view feature)
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
auto-size table width to make use of all space available
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: auto-size table width to make use of all space available
As in, how do I tell tabularx just to use the full width of a line of text for the table? Use all the space available to it without going outside my page's margin.
Latex editor of choice: TexWorks (for dual view feature)
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
auto-size table width to make use of all space available
There is a length \textwidth which should be self-explanatory. More flexible is the length \linewidth. Just try and see what happens.ptrcao wrote:To use the tabularx package in the way I want, I have to know what the default width of the text is across the page, do you know? […]
Read the package manual. That's what it's made for. Either follow the link in my last reply or open a command line for access on your local machine.ptrcao wrote:[…] As in, how do I tell tabularx just to use the full width of a line of text for the table? Use all the space available to it without running off the page.
Code: Select all
texdoc tabularx
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: auto-size table width to make use of all space available
Latex editor of choice: TexWorks (for dual view feature)
auto-size table width to make use of all space available
Code: Select all
\begin{tabularx}{1\linewidth}{X X X X X}
Latex editor of choice: TexWorks (for dual view feature)
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: auto-size table width to make use of all space available
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
auto-size table width to make use of all space available
Suppose I want to center the text contents of columns.
Normally this is done as
Code: Select all
{c c c c c}
Code: Select all
{m{width} m{width} m{width} m{width} m{width}}
Code: Select all
{X X X X X}
I would like to center the contents nonetheless. Can you suggest how?
---------
PS. While you see my table in the image, can you suggest a solution also for the ugly situation with:
Lyx Stand-
alone
The combination of excessive spacing and hyphenation gives a really ugly look.
Edit: I think the solution would involve disabling hyphenation and disabling justified text, but I have no idea how to do this inside a table.
---------
Thank you.
Latex editor of choice: TexWorks (for dual view feature)
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
auto-size table width to make use of all space available
[1] View topic: Avoidable mistakes
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
auto-size table width to make use of all space available
Code: Select all
\documentclass[12pt]{article}
\usepackage{booktabs} %for top, middle and bottomline
\usepackage{array} %enables, for table columns, m{width} and b{width} (only p{width is available without it})
\usepackage{tabularx} %for automation of column widths so that the table spans the width defined by textwidth and linewidth
\begin{document}
{\small
\begin{table}[h]
\caption{Comparison of \LaTeX-based or \LaTeX-supporting Equation Editors}
\label{editor-comparison}
\centering
\begin{tabularx}{1\linewidth}{X X X X X}
\toprule
Editor (Type) & Edited as & Previewed as & Inserted as \\
\toprule
LyX (Standalone) & WYSIWYG inline or button-facilitated mark-up & WYSIWYG inline & WYSIWYG inline \\
\bottomrule
\end{tabularx}
\end{table}
}
\end{document}
Latex editor of choice: TexWorks (for dual view feature)