Graphics, Figures & TablesExtra space to the left of a tabular

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Extra space to the left of a tabular

Post by LavaTyper »

Greetings, how do I get rid of the extra space on the left of tabular so that it is aligned with the rest of the text?

Also, how do I format the second column to be a paragraph that automatically uses the remaining space in \textwidth (so that I don't have to keep making line breaks)?

Code: Select all

\documentclass[10pt]{article}
\usepackage[margin=1in]{geometry}

\parindent=0cm



% THE DOCUMENT
\begin{document}

\raggedright

\begin{center}{\LARGE TITLE}\\ \vspace{0.2em}
Subtitle \\
\end{center}

\begin{minipage}{0.45\textwidth}
\begin{flushleft}
\textbf{Left} \\
Some information goes here \\
to the left
\end{flushleft}
\end{minipage}
\hfill
\begin{minipage}{0.45\textwidth}
\begin{flushright}
\textbf{Right} \\
More information goes here \\
to the right
\end{flushright}
\end{minipage}

\vspace{\baselineskip}

\begin{tabular*}{\textwidth}{p{100pt} @{\hspace{\fill}} l}
SHOULD NOT & first first first first first first first first first first first first first first first first first first first first first first first first first first first first \\
HAVE INDENT & second second second second second second second second second second second second second second second second second second second second \\
ON THE LEFT & these entries should wrap around into a paragraph instead \\
& of running off the page
\end{tabular*}



\end{document}

Recommended reading 2024:

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

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

LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Extra space to the left of a tabular

Post by LavaTyper »

Greetings again!
I have not yet received a response to my inquiry.

How do I make a table or tabular that uses the full textwidth?


SEE THE MWE in the PREVIOUS POST.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Extra space to the left of a tabular

Post by Johannes_B »

Code: Select all

\documentclass[10pt]{article}
\usepackage[showframe,margin=1in]{geometry}
\usepackage{array}
\usepackage{blindtext}
\usepackage{tabularx}
\newcolumntype{P}{>{\raggedright\arraybackslash}X}
\parindent=0cm
\begin{document}
\begin{tabularx}{\textwidth}{
		@{}
		p{100pt}
P}
	SHOULD NOT & \blindtext first first first first first first first
	first first first first first first first first first first
	first first first first first first first first first first
	\\
	HAVE INDENT & second second second second second second second
	second second second second second second second second second
	second second second second \\
	ON THE LEFT & these entries should wrap around into a paragraph
	instead running off the page \\
\end{tabularx}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Re: Extra space to the left of a tabular

Post by LavaTyper »

That worked. But what if I want to define a multiple-character variable instead of "P", like, "MyRightColumn"?
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Re: Extra space to the left of a tabular

Post by LavaTyper »

Also I have another question regarding your MWE:


What if I want the "X" column to be center aligned?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Extra space to the left of a tabular

Post by Johannes_B »

Don't change the X-column. Change the P-column instead by replacing raggedright with centering.

Code: Select all

\newcolumntype{P}{>{\centering\arraybackslash}X}
You cannot use words as column names.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Extra space to the left of a tabular

Post by cgnieder »

Johannes_B wrote:You cannot use words as column names.
One could use macros ...

Code: Select all

\documentclass{scrartcl}

\usepackage{array}
\newcolumntype{\foo}{>{foo}c}

\begin{document}

\begin{tabular}{\foo\foo}
  a & b
\end{tabular}

\end{document}
But I don't think that this is to be encouraged... :)

Regards
site moderator & package author
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Extra space to the left of a tabular

Post by LavaTyper »

Alright but what if I want the table to also continue onto a second page?

Code: Select all

\documentclass[12pt]{article}
\usepackage[showframe,margin=1in]{geometry}
%\usepackage[margin=1in]{geometry}
\usepackage{array}
\usepackage{blindtext}
\usepackage{tabularx}

\newcolumntype{P}{>{\raggedright\arraybackslash}X}

\parindent=0cm



\begin{document}




\begin{tabularx}{\textwidth}{@{} p{100pt} P}
SHOULD NOT & \blindtext \\
HAVE INDENT & second second second second second second second second second second second second second second second second \\
ON THE LEFT & these entries should wrap around into a paragraph instead running off the page \\
Extra text & \blindtext \\
Extra text & \blindtext \\
Extra text & \blindtext \\
Extra text & \blindtext \\
\end{tabularx}





\end{document}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Extra space to the left of a tabular

Post by Johannes_B »

You have to use ltxtable there.

Code: Select all

\documentclass[12pt]{article}
\usepackage[showframe,margin=1in]{geometry}
%\usepackage[margin=1in]{geometry}
\usepackage{array}
\usepackage{blindtext}
\usepackage{tabularx}
\usepackage{ltxtable}

\newcolumntype{P}{>{\raggedright\arraybackslash}X}

\parindent=0cm
\usepackage{filecontents}
\begin{filecontents}{\jobname Table.tex}
\begin{longtable}{@{} p{100pt} P}
SHOULD NOT & \blindtext \\
HAVE INDENT & second second second second second second second second second second second second second second second second \\
ON THE LEFT & these entries should wrap around into a paragraph instead running off the page \\
Extra text & \blindtext \\
Extra text & \blindtext \\
Extra text & \blindtext \\
Extra text & \blindtext \\
\end{longtable}
\end{filecontents}
\begin{document}

\LTXtable{\linewidth}{\jobname Table.tex}

\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply