After using the solution of another problem (see ), my tabularx table is too wide now. Please see the MWE and its output below.  Adding \noindent before the first table doesn't help (as suggested in one of the comments ).  Setting the table width to \dimexpr\linewidth-\parindent does help a bit, but still the table is slightly too wide (.92703pt).  When I don't use my \task command the table is just fine. As far as I can see this issue is caused by the definition of \task.  Can anyone tell me how to fix this?  \documentclass{scrartcl}  \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc}  \usepackage[a6paper, showframe=true]{geometry}  \usepackage{etoolbox} \usepackage{booktabs} \usepackage{ltablex} \usepackage{xifthen}  \def\credits{} \newcounter{subtask} \setcounter{subtask}{1} \renewcommand{\thesubtask}{\alph{subtask})} \makeatletter \newcommand{\task}[1][]{%     \ifx\hfuzz\@tempdima% %   % tabularx trial do nothing     \else%         \ifthenelse{\isempty{#1}}{%             \thesubtask%             \stepcounter{subtask}%         }{%             \thesubtask%                 \gappto\credits{(#1 BE)\\}%             \stepcounter{subtask}%         }%     \fi } \makeatother   \begin{document} \noindent\begin{tabularx}{\linewidth}[l]{&gt;{\bfseries}l@{\hspace*{1ex}}X@{}}     \task[1]    &amp;   Some longer text that exceedes the line width. Some longer text that exceedes the line width. Some longer text that exceedes the line width.\\     \task[3]    &amp;   TEXT2 \end{tabularx} \credits  \begin{tabularx}{\dimexpr\linewidth-\parindent}[l]{&gt;{\bfseries}l@{\hspace*{1ex}}X@{}}     \task[1]    &amp;   Some longer text that exceedes the line width. Some longer text that exceedes the line width. Some longer text that exceedes the line width.\\     \task[3]    &amp;   TEXT2 \end{tabularx}  \begin{tabularx}{\linewidth}[l]{&gt;{\bfseries}l@{\hspace*{1ex}}X@{}}     a)  &amp;   Some longer text that exceedes the line width. Some longer text that exceedes the line width. Some longer text that exceedes the line width.\\     b)  &amp;   TEXT2 \end{tabularx} \end{document}
122219
I'm trying to print worksheets. I have already implemented an automatic numbering for subtasks. I use tabularx for my subtasks (see the MWE below).  Yesterday, I tried to define a new macro called \task that has one optional argument which is the amount of points you can obtain for this particular question. I would like these optional arguments to be gathered with etoolbox's \appto command so that I can print them with my \credits command.  So far, this seems to be ind of struggling as tabularx is working on the tables several times. Every time tabularx calculates the width of X columns the points are appended to \credits which leads to an incorrect list of points.  Is there any way I can solve this problem? I'm currently stucked with this issue.  Plus, I don't know why my \task command does work. Why is the counter subtask not affected by tabularx's several trials?  \documentclass{scrartcl}  \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc}  \usepackage{etoolbox} \usepackage{booktabs} \usepackage{ltablex} \usepackage{xifthen}  \def\credits{} \newcounter{subtask} \setcounter{subtask}{1} \renewcommand{\thesubtask}{\alph{subtask})} \newcommand{\task}[1][]{%     \ifthenelse{\isempty{#1}}{%         \thesubtask%         \stepcounter{subtask}%     }{%         \thesubtask%         \gappto\credits{(#1)}%         \stepcounter{subtask}%     }% }  \begin{document} \begin{tabularx}{\linewidth}[l]{l@{\hspace*{1ex}}X}     \task[1]    &amp;   TEXT1\\     \task       &amp;   TEXT2\\     \task[3]    &amp;   TEXT3 \end{tabularx} \credits \end{document}       The solution given by David Carlisle below causes a table that is too wide. How can this be undone?  \documentclass{scrartcl}  \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc}  \usepackage[a6paper, showframe=true]{geometry}  \usepackage{etoolbox} \usepackage{booktabs} \usepackage{ltablex} \usepackage{xifthen}  \def\credits{} \newcounter{subtask} \setcounter{subtask}{1} \renewcommand{\thesubtask}{\alph{subtask})} \makeatletter \newcommand{\task}[1][]{%     \ifx\hfuzz\@tempdima% %   % tabularx trial do nothing     \else%         \ifthenelse{\isempty{#1}}{%             \thesubtask%             \stepcounter{subtask}%         }{%             \thesubtask%                 \gappto\credits{(#1 BE)\\}%             \stepcounter{subtask}%         }%     \fi } \makeatother   \begin{document}  \begin{tabularx}{\linewidth}[l]{l@{\hspace*{1ex}}X}     \task[1]    &amp;   Some longer text that exceedes the line width.\\     \task[4]    &amp;   TEXT2\\     \task[3]    &amp;   TEXT3 \end{tabularx} \credits  \end{document}
55828
I have seen similar questions on the matter (, ) of adding vertical space and not breaking vertical lines, the solutions suggested are to add space after the \\ using \\[0.1cm] for example or changing the \arraystretch which I do not want to do. Using \\[0.1cm] allows me to add space just before a \hline but not after as well.  How can I add vertical space after a \hline without breaking vertical lines in a table?  Please find my MWE below:  \documentclass{scrreprt} \usepackage{setspace} \usepackage[left=2.5cm,right=2.5cm,top=3cm,bottom=3cm]{geometry} \usepackage{array,tabularx} \doublespacing  \begin{document} \begin{table}[htb]   \centering   \onehalfspacing   \caption{Table of info.}      \begin{tabular}{c | c c}  &amp; C/S Analyser &amp; O/N/H Analyser \\  &amp; EMIA 320 V2 &amp; EMGA 830 \\[0.1cm]    \hline    \noalign{\vskip 0.1cm} Sensitivity (ppm) &amp; 0.1 &amp; 0.001 \\ Furnace type &amp; Induction &amp; Impulse \\ Carrier gas &amp; Pure O2 &amp; Pure He \\[0.1cm]    \hline     \end{tabular}    \doublespacing   \label{tab:chem} \end{table} \end{document}
77930
I currently have this table:  \begin{table} \centering \begin{tabular}{ |c|c| } \hline no test &amp; no test \\ \hline no test &amp; \begin{tabular}{c|c} D1 &amp; 1.23 \\ \hline D2 &amp; 1.23 \\ \end{tabular} \\ \hline \end{tabular} \end{table}    Giving:    hline in the nested tabular does not span the entire cell width.  Of course multirow/multicolumn would be a choice. However, this is a "mutable" table, to which I will need to add "sub-rows" each time new data arrives, but I do not know in advance where. So, it could become something like:    For such purpose, multirow/multicolumn seems that would require constantly changing their row/column numbers.  How can this be solved in such a way that minimizes the work each time a new "sub-row" is added?  Thanks.
103708
I'm getting some odd table alignment issues with a table that I'm constructing inside of a \whileboolexpr.  The .tex file is the following:  \documentclass{article}  \usepackage{etoolbox}  \newcounter{pcnt} \setcounter{pcnt}{0}  \newenvironment{defineperson}[1] {\csgdef{person\thepcnt}{#1}} {\stepcounter{pcnt}}  \newcommand\persontitle[1]{\csgdef{persontitle\thepcnt}{#1}} \newcommand\personmail[1]{\csgdef{personmail\thepcnt}{#1}} \newcommand\showperson[1]{\textbf{#1}}  \newcommand\maketabular[1]{\begin{tabular}{| l | l | l |} \hline #1 \end{tabular}}  \newcounter{nada}  \newcommand\makepersonrtable{%   \setcounter{nada}{0}%   \maketabular{%   \whileboolexpr     { test {\ifnumcomp{\value{nada}}{&lt;}{\value{pcnt}}} }%     {\showperson{\csuse{person\thenada}} &amp; \csuse{persontitle\thenada} &amp; \csuse{personmail\thenada} \\ \hline \stepcounter{nada} }   }}  \begin{defineperson}{Mr.}   \persontitle{Wall Eye}   \personmail{weye@gmail.com} \end{defineperson}  \begin{defineperson}{Mrs.}   \persontitle{Perch}   \personmail{perch@gmail.com} \end{defineperson}  \begin{defineperson}{Mr.}   \persontitle{Brook Trout}   \personmail{btrout@gmail.com} \end{defineperson}  \begin{document}  \makepersonrtable  \end{document}   This does generate a table as I would have expected, but the alignment is off - e.g.,   Notice that the first "Mr." is not aligned with the second row.  Also notice the extra vertical lines at the bottom.  Any idea what's going on here? I know there are other ways of making tables, but this I'm trying a few alternatives as a learning exercise.
91922
I'm making an ordinary table in LyX and the table is going off-page. Seems that LyX isn't wrapping text inside the cells, and having done a search here on SE I still cannot find a solution which would simply   Restrict the overall table width to page width; and Wrap text inside table cells   I've tried some of the advice offered in other answers to this question, but it seems to scale the entire table which is definitely not what I want. I just want text wrapping inside the cells. Thanks.
78460
I received a table template, which I'm intended to generate dynamically with data using Java. But when the table becomes to large, the compilation with LaTeX fails. The specific about this template is, that it stretches the table width into the maximal page width and has same column widths for all data columns (except the first column).  Here is a minimal version of the full template, that still works fine:  \documentclass[final,authoryear,3p,twocolumn]{elsarticle}  \usepackage{amssymb,amsmath} \usepackage{calc} \usepackage{array} \newcolumntype{L}[1]{&gt;{\raggedright\arraybackslash}p{#1}} \newcolumntype{R}[1]{&gt;{\raggedleft\arraybackslash}p{#1}} \usepackage{eurosym} \usepackage{microtype} \usepackage{needspace} \usepackage{fp}  \usepackage{graphicx} \DeclareGraphicsExtensions{.pdf} \input{pgfexternal}  \newcommand\tabt{\rule{0pt}{2.6ex}} \newcommand\tabb{\rule[-1.2ex]{0pt}{0pt}}  \begin{document}  \begin{table*}[t]     \footnotesize     \begin{tabular*}{\linewidth}{@{}L{2em}@{}*9{R{(\linewidth-2em)/9}@{}}}\hline\tabt $i$ &amp; $1$ &amp; $2$ &amp; $3$ &amp; $4$ &amp; $5$ &amp; $6$ &amp; $7$ &amp; $8$ &amp; $9$\tabb\tabularnewline\hline\tabt $1$ &amp;  &amp; $48.87$ &amp; $0.01$ &amp; $0.05$ &amp; $1.23$ &amp; $0.00$ &amp; $0.20$ &amp; $5.67$ &amp; $2.35$\tabularnewline     \end{tabular*} \end{table*}  \end{document}   But when extending this example by another column, so that the table would look like the following example, it fails:  \begin{table*}[t]     \footnotesize     \begin{tabular*}{\linewidth}{@{}L{2em}@{}*10{R{(\linewidth-2em)/10}@{}}}\hline\tabt $i$ &amp; $1$ &amp; $2$ &amp; $3$ &amp; $4$ &amp; $5$ &amp; $6$ &amp; $7$ &amp; $8$ &amp; $9$ &amp; a\tabb\tabularnewline\hline\tabt $1$ &amp;  &amp; $48.87$ &amp; $0.01$ &amp; $0.05$ &amp; $1.23$ &amp; $0.00$ &amp; $0.20$ &amp; $5.67$ &amp; $2.35$ &amp; b\tabularnewline     \end{tabular*} \end{table*}   This fails, no matter how many columns I add. So far, it seems for me to be a problem with the division by 10. May it be, that LaTeX isn't able to handle that properly by default? How can I solve this problem and make even larger tables work using this template. Or is that to any other problem I don't see yet? Thanks for any help!
108696
I notice that the space between each column of a table in LaTeX is not quite wide (at least for me). Is there any way to set this? I found the \hspace, but I don't get how to use this in the table.
71522
I am using the tocloft package so that the word Table shows up before the number in the list of tables.  When I do this, the tables with long captions wrap to the next line but are not aligned.  This is the code that I am using.   \documentclass [12pt] {article} \usepackage{times, url} \usepackage[left=1.5in,top=1in,bottom=1in,right=1in,footskip=0.5in]{geometry} \usepackage{float} \usepackage{booktabs,threeparttable} \usepackage[subfigure]{tocloft} \usepackage{subfigure} \usepackage[justification=centering]{caption}  \renewcommand{\cfttabfont}{Table }   \begin{document}   \listoftables    \begin{table}[htbp] \begin{threeparttable} \captionsetup{font=normalsize} \caption{Summary Statistics for Structural Housing Characteristics.  Central Kentucky Data, 2000-2011. N=142,164.} \centering \footnotesize \label{table:sumstatsfull} \begin{tabular}{lcccc} \hline Variable &amp; Mean &amp; Std. Dev. &amp; Min &amp; Max \\ \hline \end{tabular} \end{threeparttable} \end{table}  \end{document} `  I want the Table to precede the table number but I want the caption to be aligned like it is when the code below is used  ` \documentclass [12pt] {article} \usepackage{times, url} \usepackage[left=1.5in,top=1in,bottom=1in,right=1in,footskip=0.5in]{geometry} \usepackage{float} \usepackage{booktabs,threeparttable} \usepackage[subfigure]{tocloft} \usepackage{subfigure} \usepackage[justification=centering]{caption}  %\renewcommand{\cfttabfont}{Table }   \begin{document}   \listoftables    \begin{table}[htbp] \begin{threeparttable} \captionsetup{font=normalsize} \caption{Summary Statistics for Structural Housing Characteristics.  Central Kentucky Data, 2000-2011. N=142,164.} \centering \footnotesize \label{table:sumstatsfull} \begin{tabular}{lcccc} \hline Variable &amp; Mean &amp; Std. Dev. &amp; Min &amp; Max \\ \hline \end{tabular} \end{threeparttable} \end{table}  \end{document}
56667
I have a two-column LyX document. I want to add a table that will be as wide as the entire page, so that it will not have to be squeezed into a single column. I found some suggestions:   , however, I have no idea how to implement them in LyX...
83635
I'm writing a short tabular CV that I have to add to my thesis. I thought a quick way would be to use a table for that purpose:  \begin{tabular}{ll} 2009-present           &amp; very long text 1, very long text 2, very long text 3 , very long text 4, very long text 5, very long text 6, very long text 7, very long text 8, very long text 9, very long text 10\\ 2009  &amp; Masters\\ 2006  &amp; Bachelors\\ \end{tabular}   Unfortunately, LaTeX does not break the lines at the spaces. The only solutions I found so far, are   "adding additional rows to the table" "use fixed table size + \newline".   Manually adjusting texts is not very efficient.  Is there also a way to automate this (e.g. by define a cell/column as "text-cell/column")?  \begin{tabular}{lp{12cm}} 2009-present           &amp; very long text 1, very long text 2, very long text 3 , very long text 4, very long text 5, very long text 6, very long text 7, very long text 8, very long text 9, very long text 10\\ 2009  &amp; Masters\\ 2006  &amp; Bachelors\\ \end{tabular}   Could be a solution, but the right column does not automatically reach the right "border" of the page.
7966
Seems like \rowcolors when used for a {tabularx} doesn’t work properly: The specific number of the first row to be colored is ignored. This is not the case for a normal {tabular}.    In both tables the coloring should start in the third row.   \documentclass{article}  \usepackage{tabularx} \usepackage[table]{xcolor}  \begin{document}  \begin{minipage}{0.45\textwidth}    \verb|{tabularx}| \\[2ex]    \rowcolors{3}{blue!50}{yellow!60}    \begin{tabularx}{40mm}{X}       1 \\ 2 \\ 3 \\ 4 \\ 5 \\ 6 \\    \end{tabularx} \end{minipage}\hfill \begin{minipage}{0.45\textwidth}    \verb|{tabular}| \\[2ex]    \rowcolors{3}{blue!50}{yellow!60}    \begin{tabular}{p{40mm}}       1 \\ 2 \\ 3 \\ 4 \\ 5 \\ 6 \\    \end{tabular} \end{minipage}  \end{document}   Is this a bug in xcolor/tabularx?    This question is kind of a follow-up question of my answer on
4963
I have some text in a table and I want to add a forced line break. I want to insert a forced line break without having to specify the column width, i.e. something like the following: \begin{tabular}{|c|c|c|} \hline Foo bar &amp; Foo &lt;forced line break here&gt; bar &amp; Foo bar \\ \hline \end{tabular}  I know that \\ inserts a line break in most cases, but here it starts a new table row instead.  A similar question was asked before:
40889
So I have this table, which I just used an online tool to create, but I want the columns to wrap. So, I just change \begin{tabular} to \begin{tabularx} and then the last column vertical line is about 1cm from the table... How can I fix that gap? \begin{tabularx}{\textwidth}{|X|X|X|X|} \hline Name:                                      &amp; Donald Trump                              &amp; Student ID:                                         &amp; 99999999                                     \\ \hline \multicolumn{2}{|p{0.5\textwidth}|}{Feedback focus:}                                                 &amp; \multicolumn{2}{p{0.5\textwidth}|}{asoidjfaopsidjfp oiajdfpo iasjdfp oiasjdfpo ij}                                \\ \hline \multicolumn{2}{|p{0.5\textwidth}|}{askdljf ;laksjdf;l aksjdf;lkajsd;:}                          &amp; \multicolumn{2}{l|}{as;ldifja;lsdkfja;lsdkfja; slkfj; aldkjf ;aslkdj ;alk}                         \\ \hline \hline \multicolumn{4}{|p{\textwidth}|}{as;ldkf;lkj: aklsduhf asldkj f;alskdjf ;alskdjf ;alskdf }                                                                  \\ \hline Fully Met                                  &amp; Met                                      &amp; Partially Met                                       &amp; Not Met                                      \\ \hline Comments:                                  &amp; \multicolumn{3}{l|}{}                                                                                                                         \\ \hline \multicolumn{4}{|p{\textwidth}|}{asldkjf;alksdj f;laksjdf:as;dlk ja;lsdk fjas;ldkfj a;slkdfj ;lakasdlk;jkdj }                                                                               \\ \hline Fully Met                                  &amp; Met                                      &amp; Partially Met                                       &amp; Not Met                                      \\ \hline Comments:                                  &amp; \multicolumn{3}{l|}{}                                                                                                                         \\ \hline \multicolumn{4}{|p{\textwidth}|}{a;lsdkjf; lakj;l3: alkjdsf l;aksjdf;l kasjd;lf kjasd;l fkjas;ldkfjas;ldkf jas;ldkf ja;sldkfj asldkfj alksjferopijp34qjp asdf} \\ \hline Fully Met                                  &amp; Met                                      &amp; Partially Met                                       &amp; Not Met                                      \\ \hline Comments:                                  &amp; \multicolumn{3}{l|}{}                                                                                                                         \\ \hline \multicolumn{4}{|p{\textwidth}|}{as;ldkfjal;kej ;l4: alskdjf ;lasdkjf ;alskdjf ;laskd}                                                                                                                      \\ \hline Fully Met                                  &amp; Met                                      &amp; Partially Met                                       &amp; Not Met                                      \\ \hline Comments:                                  &amp; \multicolumn{3}{l|}{}                                                                                                                         \\ \hline \multicolumn{4}{|p{\textwidth}|}{asl;dkjf;lk4j: asl;dkjfaslkdjf eirkajp (asl;dkfj a) aslkdjf l}                                                                                             \\ \hline Fully Met                                  &amp; Met                                      &amp; Partially Met                                       &amp; Not Met                                      \\ \hline Comments:                                  &amp; \multicolumn{3}{l|}{}                                                                                                                         \\ \hline \end{tabularx}  Gives:
58636
Note: My hope is that this can become a general resource for "use a list instead" comments. If you have suggestions for improvement, please let me know.    I often see comments such as      This layout should be typeset using a list, not a tabular.   and (my favorite, paraphrasing because I cannot find the exact quotation right now)     If every tabularx with an lX preamble was a list instead, the world would be a better place.   This is all well and good, and I can see the benefits (chiefly: page breaking mid-"row" and without specialty table packages).  A description environment gets close, but it has a fixed left indent that does not depend on the longest item name.  The  at  shows a way to do this using the environ and enumitem packages.    What other methods do you use to achieve this layout? I'd like to avoid manually specifying the longest label (its width, essentially). This is something that tabularx does not require, and I don't want it to be required in the solution to this problem either, if I can avoid it.    Alternatively, what other layouts are recommended for this type of content? Examples of common document elements for which tabularx is used include nomenclature lists and other lists of notation.    MWE  \documentclass{article} \usepackage{tabularx} \usepackage{lipsum} % just for blind texts \newenvironment{mylist} % what else goes here?   {\trivlist}   {\endtrivlist}  \begin{document}  \section{trivlist version} \begin{mylist}   \item[Text 2] \lipsum*[2] \end{mylist}  \section{tabularx version} \noindent \begin{tabularx}{\textwidth}{@{}lX@{}}   Text 2 &amp; \lipsum*[2] \end{tabularx}  \section{description version} \begin{description}   \item[Text 2] \lipsum*[2] \end{description}  \end{document}
100425
When I put X in column specifier, how can I define column formatting? How can I get center alignment? Currently I am putting \centering, but that is not a proper solution.   This is my code:  \documentclass{article} \usepackage{pgfplots} \usetikzlibrary{patterns} \usepackage{booktabs,tabularx} \usepackage[margin=1in]{geometry}% http://ctan.org/pkg/geometry   \begin{document}  \begin{table}[t] \caption{Case studies} \centering  \begin{tabularx}{\textwidth}{p{4cm}*{5}{X}}     \toprule \centering Nature of unreliability &amp; \centering Sender SST &amp; \centering Receiver SST &amp; \centering Implementation SST &amp;  Retransmission Bound \\   \midrule  Noisy (Single fixed error message) &amp; DSST &amp; DSST &amp; DSST &amp; Unbounded \\ \bottomrule \end{tabularx} \label{case-studies} \end{table}    \end{document}
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}
96328
I have a LaTeX table generated like this,   \begin{table}[ht] \begin{center} \begin{tabular}{rrrrrrr} \hline &amp; 1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 &amp; 6 \\  \hline 1 &amp; 181.21 &amp; 169.01 &amp; 130.03 &amp; 135.93 &amp; 142.31 &amp; 108.11 \\  2 &amp; 106.80 &amp; 130.71 &amp; 186.43 &amp; 126.46 &amp; 167.28 &amp; 137.91 \\  3 &amp; 162.69 &amp; 198.98 &amp; 188.33 &amp; 184.30 &amp; 147.02 &amp; 197.38 \\  4 &amp; 132.42 &amp; 150.50 &amp; 148.69 &amp; 134.31 &amp; 129.52 &amp; 172.72 \\  \hline \end{tabular} \end{center} \end{table}   but when i compile it in MiKTeX I am getting the following error   ! Undefined control sequence. l.1 \begin           {table}[ht] ?  Process interrupted by user   I want a table generated from this i am compiling under pdfTeX. I am using LaTeX for first time, can anyone please give a suggestion?