Adding \color{&lt;value&gt;} inside the rightmost cell of a 2x1 table creates a vertical offset relative to the leftmost cell. Why, and how to remedy it?  \documentclass{report} \usepackage{xcolor}   %geometry---------------------------------------------------------- \usepackage[a6paper]{geometry} \savegeometry{default}  \usepackage{xparse}%---------------------------------------------- \NewDocumentCommand{\thisdoc}{} {abcdefghijklmnopqrs}  \usepackage{tabularx}%--------------------------------------------- \newcolumntype{R}{&gt;{\raggedleft\arraybackslash}X} \newcolumntype{C}{&gt;{\centering\arraybackslash}X} \NewDocumentCommand{\myheaderii} {+mm} {%   \begin{tabularx}{\textwidth}{@{}lR@{}}#1&amp;#2\end{tabularx} }    \begin{document} \pagestyle{empty} \begin{titlepage}TITLE\end{titlepage} % --------------------------------- \newpage \pagecolor{white}     \myheaderii{%       \thisdoc     }     {%       1/2     }      \myheaderii{%       \thisdoc     }     {%       \color{red}% CULPRIT       1/2     }  \end{document}
52490
The following code shows that a \color{red} command increases the height of a tabular cell. I want to use a switch, not a command as \textcolor{red}{text}.  \documentclass{article}  \usepackage{xcolor} \usepackage{float}  \begin{document}  \begin{table}[H] \begin{tabular}{*{2}{p{0.45\textwidth}}} \hline \color{red} header &amp; header \tabularnewline \hline  %  content  &amp; content \tabularnewline  content  &amp; content \tabularnewline  content  &amp; content \tabularnewline \hline \end{tabular} \end{table}  \end{document}     How can I work around this problem?
14384
still working on that table. Here's my new question reguarding the table borders:  It appears, that i do something wrong setting boarders. Here is my code, and a screenshot:  \documentclass{article} \usepackage{multirow} % Used for the vertical cells \usepackage{rotating} % Used for the vertical cells  \usepackage{xcolor} % Used for cell-colors \usepackage{colortbl} % Used for cell-colors  \usepackage[a4paper]{geometry}% Used to set the pdf margins manually \newgeometry{left=2cm,bottom=0.1cm}  \definecolor{grey}{HTML}{F2F2F2} % Define grey for the cells \definecolor{red}{HTML}{FF0000} % Define red for testing  \begin{document} \scriptsize % Use a small font size  \begin{tabular}{|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0,6cm}|}  \cline{10-17}  \multicolumn{9}{|c|}{} &amp; \multicolumn{2}{p{\dimexpr (0.6cm)*2+2\arrayrulewidth+2\tabcolsep\relax}|}{\cellcolor{grey}Work to retired ratio} &amp; \multicolumn{4}{p{\dimexpr (0.6cm)*4+1\arrayrulewidth+2\tabcolsep\relax}|}{Health care sizing (per thousand)} &amp; \multicolumn{2}{p{\dimexpr (0.6cm)*2+1\arrayrulewidth+2\tabcolsep\relax}|}{\cellcolor{grey}Inverse dependency ratio}\\\cline{3-9}  \multicolumn{2}{|c|}{} &amp; \multicolumn{4}{c|}{\cellcolor{grey}Population (mio.)} &amp; \multicolumn{3}{c}{Workforce (1000)}  &amp; \multicolumn{2}{|c|}{\cellcolor{grey}} &amp; \multicolumn{2}{l|}{Physicians by} &amp; \multicolumn{2}{l}{Nurses by} &amp; \multicolumn{2}{|l|}{\cellcolor{grey}Old agers by}\\\hline  \multicolumn{2}{|c|}{} &amp; \begin{sideways}\cellcolor{grey}\parbox{4cm}{Overall}\end{sideways} &amp; \begin{sideways}\cellcolor{grey}\parbox{4cm}{Young age}\end{sideways} &amp; \begin{sideways}\cellcolor{grey}\parbox{4cm}{Working age}\end{sideways} &amp; \begin{sideways}\cellcolor{grey}\parbox{4cm}{Old age}\end{sideways} &amp; \begin{sideways}\parbox{4cm}{Overall}\end{sideways} &amp; \begin{sideways}\parbox{4cm}{Physicians (Proj: 2025)}\end{sideways} &amp; \begin{sideways}\parbox{4cm}{Nurses (Proj: 2030)}\end{sideways} &amp; \begin{sideways}\parbox{4cm}{\cellcolor{grey}Working age by Old age}\end{sideways} &amp; \begin{sideways}\parbox{4cm}{\cellcolor{grey}Work force by Old age}\end{sideways} &amp; \begin{sideways}\parbox{4cm}{Workforce}\end{sideways} &amp; \begin{sideways}\parbox{4cm}{Working age}\end{sideways} &amp; \begin{sideways}\parbox{4cm}{Workforce}\end{sideways} &amp; \begin{sideways}\parbox{4cm}{Working age}\end{sideways} &amp; \begin{sideways}\parbox{4cm}{\cellcolor{grey}1 physicians}\end{sideways} &amp; \begin{sideways}\parbox{4cm}{\cellcolor{grey}1 nurse}\end{sideways}\\\hline  \multicolumn{2}{|l}{USA} &amp; \multicolumn{4}{l}{\cellcolor{grey}} &amp; \multicolumn{3}{l}{} &amp; \multicolumn{2}{l}{\cellcolor{grey}} &amp; \multicolumn{4}{l}{} &amp; \multicolumn{2}{l|}{\cellcolor{grey}}\\\hline  1990/1 &amp; &amp; 248,6 &amp; 71,3 &amp; 146,1 &amp; 31,2 &amp; 127.500 &amp; 615,4 &amp; 1491,6 &amp; 4,68 &amp; 4,09 &amp; 4,83 &amp; 4,21 &amp; 11,70 &amp; 10,21 &amp; 50,7 &amp; 20,9\\\hline  1 &amp; 2 &amp; 3 \\\hline  \end{tabular}  \end{document}     On 1 the Top border of Population is not visible although i did used \\\cline{3-9}\cline{12-17} on that line.  In 2 both borders are pushed a bit to the right for no reason i can see.  And in 3 again the top borders are not visible despite using \cline{10-17} on that line. What did i do wrong?  Thanks!
47460
I want to add a box in a tabularx table that would frame several cells vertically. There is this post that shows how to frame cells horizontally (), but I cannot figure out how to do to have the box extend over several rows. Here is what I would roughly like to get (but with a nice box):  Column 1 &amp; Column 2 &amp; Column 3                       +-----+ bla      &amp; bla      &amp; |bla  |                       |     | bla      &amp; bla      &amp; |bla  |                       +-----+   Any idea of how I could do that?  Edit: the solutions proposed below are very nice. But they are compatible with the tabular environment only, it seems, and not with tabularx and booktabs. Below is the code I have used. Does anyone have an idea of how to extend these solutions to the tabularx style? If not, then I will just rewrite all my tables using the simple tabular style.        \documentclass{article}    \usepackage{tabularx, booktabs}    \usepackage{tikz}    \usetikzlibrary{calc}     \newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}    \newcommand{\DrawBox}[1][]{%         \tikz[overlay,remember picture]{         \draw[black,#1]            ($(left)+(-0.5em,2.0ex)$) rectangle            ($(right)+(0.75em,-0.75ex)$);}           }     \begin{document}    \begin{table}[H]    \centering     \begin{tabularx}{0.3\textwidth}{Y*{4}{c}}         \toprule          &amp; Masc  &amp; Fem &amp; Neut\\          \midrule  \cline{4-4}         Nom &amp; hic &amp; haec &amp; \multicolumn{1}{|c|}{hoc} \\          Acc &amp; hunc &amp; hanc &amp; \multicolumn{1}{|c|}{hoc} \\ \cline{4-4}         \bottomrule      \end{tabularx}     \end{table}      \begin{table}[H]    \centering     \begin{tabularx}{0.3\textwidth}{Y*{4}{c}}         \toprule          &amp; Masc  &amp; Fem &amp; Neut\\          \midrule           Nom &amp; hic &amp; haec &amp; \tikzmark{left}hoc \\          Acc &amp; hunc &amp; hanc &amp; hoc\tikzmark{right} \\          \bottomrule      \end{tabularx}       \end{table}     \end{document}
78791
I am trying to create a table with specific cells coloured either green or red. As a trial, I used the following code to colour one cell green \documentclass[a4paper,12pt]{extarticle} %% Language and font encodings \usepackage[english]{babel} \usepackage[utf8x]{inputenc} \usepackage[T1]{fontenc}  %% Sets page size and margins \usepackage[a4paper,top=2.5cm,bottom=2.5cm,left=2.5cm,right=2.5cm,marginparwidth=1.75cm]{geometry}  \usepackage{amsmath} \usepackage{amsfonts}  \usepackage{amssymb} \usepackage{amsthm} \usepackage{mathtools} \usepackage{optidef}  \usepackage[framed,numbered,autolinebreaks,useliterate]{mcode} \usepackage[table]{xcolor}  \begin{document} \begin{table} \centering \begin{tabular}{ | l | l | l | }       \hline       A &amp; B &amp; C \\       \hline       D &amp; E &amp; \cellcolor{green}F \\       \hline       G &amp; H &amp; I \\       \hline \end{tabular} \end{table} \end{document}  Here I have used \usepackage[table]{xcolor}. This did not work, and the output generated is shown below  Is there a way to create a table with specific cell colours
21495
I'm colorizing the header of a table formatted with column -ts $'\t'  Works well without color codes, but when I add color codes to the first line column doesn't properly align the output.  Without colored output it works as expected: printf "1\t2\t3\nasdasdasdasdasdasdasd\tqwe\tqweqwe\n" | column -ts $'\t'  But when adding color on the first line column doesn't align the text of the colored row: printf "\e[7m1\t2\t3\e[0m\nasdasdasdasdasdasdasd\tqwe\tqweqwe\n" | column -ts $'\t'  Observed this behaviour both on Ubuntu Linux and Mac OS X.
87374
I have been successfully using xcolor and its \cellcolor command for a while, and produced beautiful results with it. However, I would like to create some more advanced background effects: color the cell with two colors:    The example above is produced using , but this approach falls apart for a number of reasons:    Tikz's matrix command is not nearly as powerful as ordinary tabulars with the array package and others. I have some numeric data that I am happily aligning on the decimal point using dcolumn - I have no idea how I would do this is in a tikz matrix. I would like to emulate booktabs behaviour, but I just can't get it working.  suggests a workaround, but it doesn't work. The coloring falls apart if the width of the columns is not predefined:   and it all falls apart.  I have had a look through other questions;  and  manage to create one-colored bars dynamically;  combines tabularx and tikz in a promising approach, but I did not manage to adapt this to my purpose;  draws lines and manages to stick to a tabular environment - maybe a good starting point?   So ideally I would like to stick to a tabular environment, and be able to specify the cells' background content freely (for the point of this question I would be happy with a solution that gives me the diagonally separated effect as in the top left corner of the two examples), with a command such as \twocolor{blue}{purple}.
118058
I am trying to create a table which uses both multicolumns and multirows, and I am getting some graphical problems.   As you can see on below image, the top right corner is missing a line and the second horizontal line cuts off in the middle of a cell)    Find the code below.  \documentclass{article}  %Used to create Macro 1 \usepackage{array}  \usepackage{multirow}  %Used for \textsubscript \usepackage{fixltx2e}  %Macro \newcolumntype{"}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}} \makeatother  \begin{document}   \begin{table}        \centering        \begin{tabular}[ht]{|c"c|c|c|c|}                \hline                \multirow{2}{*}{\textbf{Change}}          &amp; \multicolumn{2}{c}{\textbf{Main}}       &amp; \multicolumn{2}{c}{\textbf{Sub}}        \\ \cline{2-5}                       &amp; \textbf{P}                &amp; \textbf{A}                &amp; \textbf{P}                &amp; \textbf{A}         \\ \hline                   1      &amp; U                         &amp; R\textsubscript{ef}       &amp; R\textsubscript{ef}       &amp; U                  \\ \hline               2      &amp; U                         &amp; U                         &amp; R\textsubscript{ef}       &amp; R\textsubscript{ef} \\ \hline               3      &amp; G                         &amp; P                         &amp; P                         &amp; G                  \\ \hline               4      &amp; P                         &amp; P                         &amp; G                         &amp; G                  \\ \hline               5      &amp; A                         &amp; A                         &amp; N/A                       &amp; N/A                \\ \hline               6      &amp; E                         &amp; E                         &amp; N/A                       &amp; N/A                \\ \hline               7      &amp; E                         &amp; E                         &amp; N/A                       &amp; N/A                \\ \hline               8      &amp; E                         &amp; E                         &amp; N/A                       &amp; N/A                \\ \hline               9      &amp; E                         &amp; E                         &amp; N/A                       &amp; N/A                \\ \hline               10     &amp; E                         &amp; E                         &amp; G                         &amp; G                  \\ \hline               11     &amp; E                         &amp; E                         &amp; G                         &amp; G                  \\ \hline               12     &amp; E                         &amp; E                         &amp; G                         &amp; G                  \\ \hline               13     &amp; R\textsubscript{ed}       &amp; R\textsubscript{ed} &amp;     N/A                         &amp; N/A                \\ \hline          \end{tabular}        \caption{X }        \label{table:X} \end{table}   \end{document}   If you need any additional information, please leave a comment and I'll add info.
118949
I am trying to wrap text in the multirow column (1st one) and only have the vertical lines inside the table if that makes sense.   Can anyone help me? `  \begin{table*}[!htbp] \centering \renewcommand{\arraystretch}{1.4} \begin{tabular}{|c| p{2cm}|c|c|c|c|} \cline{3-6} &amp;&amp;\multicolumn{2}{c|}{\textbf{Gravité du Dommage G1}} &amp; \multicolumn{2}{c|}{\textbf{Gravité du Dommage G2}}\\  \cline{3-6} &amp;&amp;\textbf{Fréquence F1} &amp; \textbf{Fréquence F2} &amp; \textbf{Fréquence F1} &amp; \textbf{Fréquence F2}\\ \hline \multirow{ 2}{*}{\textbf{Probabilité Occurence O1}}&amp;\textbf{Possibilité Evitement P1}&amp;&amp;&amp;&amp;\\ \cline{2-6} &amp;\textbf{Possibilité Evitement P2}&amp;&amp;&amp;&amp;\\ \hline \multirow{ 2}{*}{\textbf{Probabilité Occurence O2}}&amp;\textbf{Possibilité Evitement P1}&amp;&amp;&amp;&amp;\\ \cline{2-6} &amp;\textbf{Possibilité Evitement P2}&amp;&amp;&amp;&amp;\\ \hline \multirow{ 2}{*}{\textbf{Probabilité Occurence O3}}&amp;\textbf{Possibilité Evitement P1}&amp;&amp;&amp;&amp;\\ \cline{2-6} &amp;\textbf{Possibilité Evitement P2}&amp;&amp;&amp;&amp;\\ \hline \end{tabular} \end{table*}
6125
I'm trying to typeset a table that would have a header in the first row (I'm not looking for a different/better solution to adding a header, but for a fix to this solution. Thanks). I want to achieve this by having a multicolumn cell spanning all the columns of the first row. The problem is that if the text is too long, the column widths are uneven, with the last column accumulating excess width. I would expect all of the columns to be of approximately the same width (although I cannot find a decent source that would say they should), given the fact that all the text in the second row is of approximately the same width.  I find this behaviour quite puzzling and have no idea what the cause could be. I know I could perhaps remedy this by manually setting the column widths, but am curious as to how to fix this without doing that (I do not need or indeed want the columns to be of the same width, but roughly proportional to the length of their content), preferably but not necessarily by using the tabular environment only (some other conflict with the document class I am using).   What is it that I'm doing or assuming wrong? And why?  MWE:  \documentclass{article} \begin{document}  \begin{tabular}{ccccc} \multicolumn{5}{c}{This is a piece of text. The longer it is, the longer the last column.} \\  1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 \\ \hline \end{tabular}  \end{document}   Resulting table. Notice how the last column of the second row accumulates excess width.
61190
I asked a  a while ago about vertically aligning enumerate labels to the top of table. Now I am having the same problem, but with images. Since my problem was solved in my previous thread, I tried sticking the image in a single-cell table and aligning that with the tabular's alignment parameter, but it seemed to have no effect.  Can someone explain what is the correct way to align this image and why didn't sticking it in a table work as expected? I am simply trying to align the enumerate label with the top of my image.    \begin{enumerate}[label=(\alph*)]   \item\begin{tabular}[t]{l}\includegraphics[width=10cm]{13a.png}\end{tabular} \end{enumerate}
41703
I have the following code that produces the table that is shown. What I am trying to do is to get the fourth and fifth column titles vertically aligned at the top. Is this possible?  \documentclass{article} \usepackage{multirow} \usepackage{array}  \newcolumntype{x}[1]{% &gt;{\raggedright\hspace{0pt}}p{#1}}%  \begin{document} \centering \renewcommand{\arraystretch}{1.2} \begin{tabular}{| m{2cm} | p{2cm} | p{2cm} | p{2cm} | p{2cm} | p{2cm} |} \hline     \multirow{3}{1.7cm}{Data Set} &amp;%     \multicolumn{3}{c |}{Raw Data} &amp;%     Offline Processing Time &amp;     Index Size (KB)\\ \cline{2-4} %     &amp; %     RDF N3 File SizeKB (sec)    &amp;%     Number of Triples &amp;%     Number of Entities\\    \hline \end{tabular} \end{document}
121808
\documentclass{article} \usepackage{tabularx} \usepackage{multirow} \begin{document}  \begin{table}[h!] \setlength\extrarowheight{2pt} % for a ever so slightly more open "look"     \begin{tabularx}{\textwidth}{c X | c | c | c |}     \cline{3-5}     &amp;  &amp; \multicolumn{3}{c|}{Paired Differences} \\     \cline{3-5}      &amp; &amp; Mean &amp;  Std. Deviation &amp; Std. Error Mean \\          \hline     Pair 1 &amp; Testing 1 and Testing 2 and Testing 3 &amp; 4.20\% &amp; 44.6\% &amp; 4.54\%  \\     \hline       \end{tabularx} \caption{Testing 123} \end{table}  \end{document}   Outcome:    I cannot figure out. If I added \begin{tabularx}{\textwidth}{|c X | c | c | c |} It will not be working
49147
In the following example the double line is shifted a bit to the right:  \documentclass[12pt]{article} \usepackage{tikz} \begin{document} \begin{tabular}{ll} \tikz[baseline=-0.5ex]\draw[thick](0,0)--(3ex,0);&amp;test\\    \tikz[baseline=-0.5ex]\draw[thick,double](0,0)--(3ex,0);&amp;test\\  \end{tabular} \end{document}     Looks like a bug to me, but how can I correct it?   Addition  The shift gets larger with larger double distance values.
15263
How can I vertically center the content in the cells of the left table (marked 1) so that it looks like the cells of the right table (marked 2):    My code thus far:  \begin{table}[H]     \setcellgapes{5pt}     \makegapedcells     \caption{Local Area Network vs Wide Area Network.}     \label{tab:lanvswan}     \centering     \begin{tabular}{         &gt;{\centering\arraybackslash}p{3.5cm}         |&gt;{\centering\arraybackslash}p{4.5cm}         |&gt;{\centering\arraybackslash}p{4.5cm}         }         \thead{Características}     &amp; \thead{LAN}                           &amp; \thead{WAN}                                                       \\  \hline         Extensión Geográfica        &amp; Pequeña                               &amp; Extensa                                                           \\  \hline         Dispositivos                &amp; Host, Switches (L2 y L3) y Routers    &amp; Especializados de ATM y Frame Relay, Switches (L3) y Routers      \\  \hline         Tecnologías                 &amp; Ethernet                              &amp; MPLS, ATM, Frame Relay y X.25     \end{tabular} \end{table}
13247
The tabular environment does not add any vertical space before or after it. This looks odd, in my view. What is the "correct" or "best" way to add some space? Also, why is there more space after the tabular environment than before it, as seen in the example below?  \documentclass{article} \begin{document} \noindent Here is a line with some text in it.  \begin{tabular}{*4{l}}     Worg &amp; Worg &amp; Worg &amp; Worg\\     Worg &amp; Worg &amp; Worg &amp; Worg\\ \end{tabular}  \noindent Here is another line with some text in it. \end{document}
50768
I can't find a way to vertically center a single line within a table cell.  Take a look at this screenshoot:    I'd like to vertically center the text within the bottom right cell and I just can't find a way to do it. I tried \usepackage{array} but I couldn't figure out how to apply the \centering\arraybackslash, which seems to align things vertically within cells, just to this single cell.  (I'm also not sure why the right border is missing for this cell.)  Here is the LaTeX code that generates this table:  \documentclass{article}  \usepackage[left=1cm,top=1cm,right=1cm,bottom=1cm,nohead,nofoot]{geometry}  \usepackage[pdftex]{hyperref} \usepackage{verbatim} \usepackage{listings} \usepackage{array}  \hypersetup{colorlinks}  \lstset{basicstyle=\ttfamily}  \pagestyle{empty}  % -----------------------------------------------------------------------  \begin{document}  \begin{tabular}{|p{5.5cm}|p{12.2cm}|} \hline \large\textbf{Redirection} &amp; \large\textbf{Description} \\ \hline \verb|&gt; file| &amp; Redirect standard output (stdout) to a file. \\ \hline \verb|1&gt; file| &amp; Same as \verb|&gt; file|. \verb|1| is the default file descriptor for stdout. \\  \hline \verb|2&gt; file| &amp; Redirect standard error (stderr) to a file. \verb|2| is the default file descriptor for stderr. \\ \hline \verb|&gt;&gt; file| &amp; Append stdout to a file. \\ \hline \verb|2&gt;&gt; file| &amp; Append stderr to a file. \\ \hline \verb|&amp;&gt; file| &amp; Redirect stdout and stderr to a file. \\ \hline \verb|&gt;file 2&gt;&amp;1| &amp; Another way to redirect both stdout and stderr to a file. This \textbf{is not} the same as \verb|2&gt;&amp;1 &gt;file|. \textbf{Redirection order matters!} \\ \hline \verb|&gt; /dev/null| &amp; Discard stdout. \\ \hline \verb|2&gt; /dev/null| &amp; Discard stderr. \\ \hline \verb|&amp;&gt; /dev/null| &amp; Discard stdout and stderr. \\ \hline \verb|&lt; file| &amp; Redirect the contents of the file to the stdin. \\ \hline \verb|&lt;&lt; EOL| \\  \verb|foo| \\ \verb|bar| \\ \verb|baz| \\ \verb|EOL| &amp; Redirect a bunch of lines to the stdin. \\ \hline \end{tabular}  \end{document}
48092
I want to typeset a tabular with alterning row colors, containing matrices. Somehow, when adding \rowcolors{1}{}{black!5} the left bracket of some matrices is just omited. What am I doing wrong and how can I avoid this?   \documentclass[ border=2pt]{standalone}  \usepackage{amsmath} \usepackage[natural,table]{xcolor}  \begin{document}     \rowcolors{1}{}{black!5}     \begin{tabular}[t]{ll}         \rowcolor{gray!50}{\bfseries SKP} &amp; \\ \hline         $A$ &amp; $\begin{bmatrix}-0.25 &amp; 1 \\ 0 &amp; 0.5  \end{bmatrix}$\\         $b=g$ &amp; $\begin{bmatrix}0 \\ 1\end{bmatrix}$         \end{tabular} \end{document}