Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a simple graphic I'm trying to make with a table, but for it to work I need to extend the text beyond the table cell - through something like a negative margin - is this possible? Specifically, the bottom row of the table (0,c,r) should line up with the vertical borders above - currently also slightly to the right of each. The graphic represents a number line.

enter image description here

\documentclass[11pt]{article}
\usepackage{array}
\usepackage[math]{cellspace}
\begin{document}

\begin{table}[!htdp]
\begin{center}
\begin{tabular}{Sc m{5cm} m{5cm}}
\cline{2-3} 
$\dfrac{1}{x}$ & \multicolumn{1}{|c}{F} & \multicolumn{1}{|c|}{O} \\
\cline{2-3} 
0 & \flushright{c} & \flushright{r} \\
\end{tabular}
\end{center}
\end{table}


\end{document}  
share|improve this question
    
Welcome to TeX SE! Please complete your code with \documentclass, \begin{document}... \end{document} etc. being sure to include any packages required. The code should be compilable by others who want to reproduce the output you've posted. A complete small document is much more useful than mere code fragments. –  cfr Aug 25 at 3:15
    
You can answer your own question... –  cfr Aug 25 at 3:43

3 Answers 3

up vote 2 down vote accepted

With package mathtools:

\documentclass[11pt]{article}
\usepackage{mathtools}
\usepackage{array}
\usepackage[math]{cellspace}
\begin{document}
\begin{table}[!htdp]
\begin{center}
\begin{tabular}{Sc @{\clap{0}} m{5cm} @{$\mathclap{c}$} m{5cm} @{$\mathclap{r}$}}
\cline{2-3} 
\multicolumn{1}{c}{$\dfrac{1}{x}$} & \multicolumn{1}{|c}{F} & \multicolumn{1}{|c|}{O} \\
\cline{2-3} 
&&
\end{tabular}
\end{center}
\end{table}
\end{document}

Notice that \clap{text} is typeset as normal text and that $\mathclap{\alpha}$ is typeset as inline math. They both create boxes of zero width with entries centered.

share|improve this answer
    
Perfect! Thanks Symbol 1 –  user3717830 Aug 26 at 2:52

I figured out how to do it with a graphics package. Still interested if there's a way with tables.

enter image description here

\documentclass[11pt]{article}
\usepackage{array}
\usepackage[math]{cellspace}
\usepackage{tikz}
\definecolor{fillcolour}{HTML}{eeeeee}

\begin{document}

\begin{tikzpicture}
\draw (5,0) -- (5,1);
\draw (0,0) rectangle (10,1);
\draw [fill=fillcolour] (0,0) rectangle (5,1); 
\node at (2.5,.5) {F}; 
\node at (7.5,.5) {O}; 
\node at (-0.5,0.5) {$\dfrac{1}{x}$};
\node at (0,-0.5) {0};
\node at (5,-0.5) {c};
\node at (10,-0.5) {r};
\end{tikzpicture}


\end{document}
share|improve this answer

With tabularx:

\documentclass[11pt]{article}
\usepackage{amsmath}   %% showframe just for demo
\usepackage{tabularx}
\usepackage[table]{xcolor}
\begin{document}

\noindent\arrayrulewidth1pt
\begin{tabularx}{\textwidth}{>{\hsize=0.05\hsize}XXX}
\cline{2-3}
\noalign{\vspace{\arrayrulewidth}}
\raggedleft$\dfrac{1}{x}$ &  \multicolumn{1}{|c}{\cellcolor{gray!30} F} & \multicolumn{1}{|c|}{O} \\ \cline{2-3}
\noalign{\vspace{2ex}}
\makebox[\dimexpr\hsize+1.5\tabcolsep][r]{0} & \makebox[\dimexpr\hsize+1.5\tabcolsep][r]{c} & \makebox[\dimexpr\hsize+1.5\tabcolsep][r]{r}
\end{tabularx}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.