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
goal: 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.
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.
Last edited by ptrcao on Mon Feb 21, 2011 12:13 pm, edited 1 time in total.
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)
Latex editor of choice: TexWorks (for dual view feature)
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
auto-size table width to make use of all space available
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
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
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?
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.
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.
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)
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
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
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
Thank you for the \linewidth tip - I wouldn't have figured that out.
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)
Latex editor of choice: TexWorks (for dual view feature)
auto-size table width to make use of all space available
Um...there is no way to text-align the contents of the columns with the specification {X X X} used in
Some help on this please?
Code: Select all
\begin{tabularx}{1\linewidth}{X X X X X}
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)
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
I'm afraid I can't follow you. Please describe more precise what you want to do and how the text alignment shall look like.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
auto-size table width to make use of all space available
This is my table:
Suppose I want to center the text contents of columns.
Normally this is done as
or
However, here we are using
There is no optional argument which I can use to center the text inside columns.
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.
You'll see that everything is left-aligned by default.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.
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)
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
It can't do any harm to add at least the code of the table. A complete but minimal example would be better [1]. I don't feel like writing the table from scratch for testing possible solutions.
[1] View topic: Avoidable mistakes
[1] View topic: Avoidable mistakes
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
auto-size table width to make use of all space available
No problem. The minimal example is as follows. I've included the offending line also for the other problem with excessive spacing and hyphenation.
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}
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)
Latex editor of choice: TexWorks (for dual view feature)