# How to create a -left and -right aligned table of a certain width?

I am trying to create a table that spans the width of the page, with two columns, aligned right-ragged and left-ragged respectively. However, this is proving weirdly difficult, as I cannot seem to get my tables to behave the way I want them too width-wise.

An example of what I've tried:

\begin{tabular*}{\pagewidth}{l r}
\gray \textbf{Endpoint} & \textbf{0}\\
\end{tabular*}


It seems like a simple problem but the inconsistency of table behavior in LaTeX is really getting to me. Help would be appreciated; perhaps I need to use a minipage?

Edit:

\documentclass[a4paper, oneside, final, 10pt]{scrartcl} % Paper options using the scrartcl class
\usepackage{scrpage2} % Provides headers and footers configuration
\usepackage{titlesec} % Allows creating custom \section's
\usepackage{marvosym} % Allows the use of symbols
\usepackage{fontspec} % Allows font customization

\defaultfontfeatures{Mapping=tex-text}
\titleformat{\section}{\large\scshape\raggedright}{}{0em}{}[\titlerule]
\newcommand{\gray}{\rowcolor[gray]{.90}}

\begin{document}

\begin{center} % Center everything in the document

\begin{tabular*}{\pagewidth}{l r}
\gray \textbf{Apple} & \textbf{Banana}\\
\gray Apple & \textbf{Banana}\\
\gray Apple & \textbf{Banana}\\
\end{tabular*}
\begin{itemize} \itemsep1pt \parskip0pt \parsep0pt
\item Apple
\item Apple
\item Mango
\end{itemize}
\end{center}

\end{document}

• Welcome to TeX.SX! Please provide a working document, not just fragments of code. \pagewidth seems weird and is no usually defined length, in addition there are margins to be considered as well! -- What is \gray supposed to do? – user31729 Oct 18 '15 at 3:22
• This snippet is not long enough? Unfortunately the full document includes a lot of personally identifiable information (it's a resume) that would take me a long time to edit out, so I am very hesitant to paste it here. – Aleksey Bilogur Oct 18 '15 at 3:38
• You want to have some help from us but you require to make document around that snippet, i.e. typing work to do. Why should we do that for you? – user31729 Oct 18 '15 at 3:39
• @ResMar: We don't want any personal information. See how to create a minimal working example (MWE)... – Werner Oct 18 '15 at 3:42
• Ok, I made one. – Aleksey Bilogur Oct 18 '15 at 3:53

\documentclass{article}
\usepackage{tabularx}
\usepackage{lipsum}% Just for this example
\begin{document}

\lipsum[2]

\begin{table}[ht]
\makebox[\textwidth]{% https://tex.stackexchange.com/q/16582/5764
\begin{tabularx}
{\pdfpagewidth}
{>{\raggedright}X>{\raggedleft\arraybackslash}X}
\lipsum*[2] &
\lipsum*[2]
\end{tabularx}%
}
\end{table}

\lipsum[2]

\end{document}


With some help from [Center figure that is wider than \textwidth]Center figure that is wider than \textwidth) you can center content within the text block.

The tabularx package will do it.

\noindent
\begin{tabularx}{\linewidth}
{>{\raggedright}X >{\raggedleft \arraybackslash}X}
\gray \textbf{Apple} & \textbf{Banana}\\
\gray Apple & \textbf{Banana}\\
\gray Apple & \textbf{Banana}\\
\end{tabularx}


gives you the first column left-aligned and the second one right-aligned, spanning the page:

Edit: changed examples to suit your code.

• One would need \noindent as well. Also, only the second \arraybackslash is necessary. – Werner Oct 18 '15 at 4:07
• What is \noindent for? I added it in several places and it didn't appear to make a difference. Edited to remove the first \arraybackslash. – Tranquilled Oct 18 '15 at 4:10
• Without it, the tabularx alone will be indented with \parindent, causing an overfull \hbox since it's width is \linewidth. – Werner Oct 18 '15 at 4:12
• Thank you for the advice. I did not see an overfull \hbox warning when I ran it. – Tranquilled Oct 18 '15 at 4:16