Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
I am trying to use LaTeX for documentation. I am unable to format the table. Please refer the following snippet of code.
\begin{table}[!htbp]
\begin{center}
\begin{tabular}{| m{3cm} | m{3cm} | m{3cm}| m{3cm} | m{3cm} |}
\hline
Software Project & a_a & b_b & c_b & d_b \\
\hline
Organic & 2.4 & 1.05 & 2.5 & 0.38\\
\hline
Semi-detached & 3.0 & 1.12 & 2.5 & 0.35\\
\hline
Embedded & 3.6 & 1.20 & 2.5 & 0.32\\
\hline
Do you mean something like the code+screenshot I posted below?
If that fits, remember what follows:
check to have \usepackage{array} in your preamble;
use \centering instead of nesting tabular into center into table;
review the width of the columns;
a_a only works in math mode: $a_a$;
check to have your environments closed properly (\end{tabular}, etc. are missing in the code you pasted in your question).
\documentclass[11pt,a4paper]{article}
\usepackage{array}
\begin{document}
\begin{table}[!htbp]
\centering
\begin{tabular}{| m{3.5cm} | m{1.5cm} | m{1.5cm} | m{1.5cm} | m{1.5cm} |}
\hline
Software Project & $a_a$ & $b_b$ & $c_b$ & $d_b$\\
\hline
Organic & 2.4 & 1.05 & 2.5 & 0.38\\
\hline
Semi-detached & 3.0 & 1.12 & 2.5 & 0.35\\
\hline
Embedded & 3.6 & 1.20 & 2.5 & 0.32\\
\hline
\end{tabular}
\end{table}
\end{document}
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
\begin{tabularx}{\textwidth}{|c|X|X|c|}
\hline
S.no & \multicolumn{1}{|c|}{\textbf{headline}} & \multicolumn{1}{|c|}{\textbf{article\_link}} & \bf\Centering is\_sarcastic \\ \hline
1 &
man who said 'yes' to life found with mountain bike at bottom of gorge &
{https://local.theonion.com/man-who-said-yes-to-life-found-with-mountain-bike-at-bo-1819573183} &
1\\
\hline
2 &
tina fey is worried about what the internet is doing to society &
{https://www.huffingtonpost.com/entry/tina-fey-internet\_us\_5848252ce4b08c82e888ff80} &
0 \\
\hline
3 &
why a woman refuses to leave her husband who threatened to kill her &
{https://www.huffingtonpost.com/entry/pro-fighter-allegedly-abuses-wife\_n\_6072618.html} &
0 \\ \hline
\end{tabularx}
Don't write urls as text. There are packages like url or hyperref that provide a dedicated \url{} macro for them. This also saves you from manually escaping all special letters.
to enable more possible breaking points to squeeze them into your way to narrow column, try the xurl package
Never use two-letter font commands like \bf, they are deprecated
Have a look at https://inf.ethz.ch/personal/markusp/teaching/guides/guide-tables.pdf for some suggestions about professional looking tables. Main point: don't use vertical lines
\documentclass{article}
\usepackage{tabularx}
\usepackage{xurl}
\begin{document}
\begin{tabularx}{\textwidth}{|c|X|X|c|}
\hline
S.no & \textbf{headline} & \textbf{article\_link} & \textbf{is\_sarcastic} \\ \hline
1 &
man who said 'yes' to life found with mountain bike at bottom of gorge &
\url{https://local.theonion.com/man-who-said-yes-to-life-found-with-mountain-bike-at-bo-1819573183} &
1\\
\hline
2 &
tina fey is worried about what the internet is doing to society &
\url{https://www.huffingtonpost.com/entry/tina-fey-internet_us_5848252ce4b08c82e888ff80} &
0 \\
\hline
3 &
why a woman refuses to leave her husband who threatened to kill her &
\url{https://www.huffingtonpost.com/entry/pro-fighter-allegedly-abuses-wife_n_6072618.html} &
0 \\ \hline
\end{tabularx}
\end{document}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
\begin{center}
\footnotesize
\begin{tabular}{| c | c c c |}
\hline
\multirow{3}{*}{Equipment acquired at start of year} & \multicolumn{3}{c|}{Replacement cost (\$) for given years} & &\\
\cline{2-4}
& 1 & 2 & 3\\
\hline
1 & 4000 & \multicolumn{1}{|c|}{5400} & 9800\\
2 & 4300 & \multicolumn{1}{|c|}{6200} & 8700\\
3 & 4800 & \multicolumn{1}{|c|}{7100} & -\\
4 & 4900 & \multicolumn{1}{|c|}{-} & -\\
\hline
\end{tabular}
\end{center}
im getting an error:
Extra alignment tab has been changed to \cr.
Also for this portion of code I'm not sure what exactly is the error (I'm getting like 20 misplaced errors and missing brackets):
\begin{table}[]
\centering
\begin{tabular}{c|c|c|c|c|c|c|c|c|c|c}
\multicolumn{11}{Directed Edge Weights (Row $\rightarrow$ Col)} & & & & & & & & & & \\
\hline
$\rightarrow$ & A & B & C & D & E & F & G & H & I & J\\
\hline
A&0&4000&&&&&&&&\\
B&&0&5400&4300&&&&&&\\
C&&&0&&9800&6200&4800&&&\\
D&&&&0&9800&6200&4800&&&\\
E&&&&&0&&&8700&7100&4900\\
F&&&&&&0&&8700&7100&4900\\
G&&&&&&&0&8700&7100&4900\\
H&&&&&&&&0&&\\
I&&&&&&&&&0&\\
J&&&&&&&&&&0\\
\hline
\end{tabular}
\caption{Table of Adjacent Edges}
\label{tab:Edges of graph}
\end{table}
please help :)
In both cases it appears that there are additional cells added after your use of multicolumn. In the first case you can remove & & after the multicolumn and all should work fine:
\begin{center}
\footnotesize
\begin{tabular}{| c | c c c |}
\hline
\multirow{3}{*}{Equipment acquired at start of year} & \multicolumn{3}{c|}{Replacement cost (\$) for given years} \\
\cline{2-4}
& 1 & 2 & 3\\
\hline
1 & 4000 & \multicolumn{1}{|c|}{5400} & 9800\\
2 & 4300 & \multicolumn{1}{|c|}{6200} & 8700\\
3 & 4800 & \multicolumn{1}{|c|}{7100} & -\\
4 & 4900 & \multicolumn{1}{|c|}{-} & -\\
\hline
\end{tabular}
\end{center}
and in the second case you need to remove the repeated & symbols after multicolumn. Also in this case there is no indication of the spacing in multicolumn. The below table works fine for me, though I have added {c} in the multicolumn.
\begin{table}
\centering
\begin{tabular}{c|c|c|c|c|c|c|c|c|c|c}
\multicolumn{11}{c}{Directed Edge Weights (Row $\rightarrow$ Col)} \\
\hline
$\rightarrow$ & A & B & C & D & E & F & G & H & I & J\\
\hline
A&0&4000&&&&&&&&\\
B&&0&5400&4300&&&&&&\\
C&&&0&&9800&6200&4800&&&\\
D&&&&0&9800&6200&4800&&&\\
E&&&&&0&&&8700&7100&4900\\
F&&&&&&0&&8700&7100&4900\\
G&&&&&&&0&8700&7100&4900\\
H&&&&&&&&0&&\\
I&&&&&&&&&0&\\
J&&&&&&&&&&0\\ \hline
\end{tabular}
\caption{Table of Adjacent Edges}
\label{tab:Edges of graph}
\end{table}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
Here's my code:
\begin{table}[H]
\begin{tabularx}{\textwidth}{sfmX}
\noalign{\hrule height 1.5pt}
\rowcolor{orange!85} Version & Date & Autore & Description \\
\noalign{\hrule height 1.5pt}
1.1.1 & 2016-01-11 & Person 1 & Action 1 \\
\noalign{\hrule height 0.5pt}
1.1.0 & 2016-01-10 & Person 2 & Action 2 \\
\noalign{\hrule height 1.5pt}
\end{tabularx}
\caption{Diary \label{tab:table_label}}
\end{table}
with:
\newcolumntype{s}{>{\hsize=.22\hsize}X}
\newcolumntype{f}{>{\hsize=.4\hsize}X}
\newcolumntype{m}{>{\hsize=.5\hsize}X}
Result:
Is there any way to remove the exceed of \noalign{\hrule}s?
Can-t find out why tabularx won-t take all that space, or why rules take too much!
The problem is actually the coloured header row being shorter than the \hrules, as they fit nicely within \textwidth. Also, your choice for column s is too narrow.
Instead, I would suggest forgoing the use of your \hrules, since you can use the constructions already available in booktabs:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{booktabs,tabularx}
\colorlet{headcol}{orange!85}
\newcommand{\headcol}{\rowcolor{headcol}}
\newcommand{\toprulec}{\arrayrulecolor{black}\specialrule{0.1em}{\abovetopsep}{0pt}%
\arrayrulecolor{headcol}\specialrule{\belowrulesep}{0pt}{0pt}%
\arrayrulecolor{black}}
\newcommand{\midrulec}{\arrayrulecolor{headcol}\specialrule{\aboverulesep}{0pt}{0pt}%
\arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
\arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
\arrayrulecolor{black}}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{l l l X}
\toprulec
\headcol Version & Date & Autore & Description \\
\midrulec
1.1.1 & 2016-01-11 & Person 1 & Action 1 \\
1.1.0 & 2016-01-10 & Person 2 & Action 2 \\
\bottomrule
\end{tabularx}
\end{document}
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am trying to make a multirow table in LaTeX which looks like the true positive, true negative, etc table shown in this Wikipedia article.
I am trying to use multirow, but I'm not sure how to get the y hat to be 'outside' the table.
\begin{table}[tbh!]
\centering
\begin{tabular}{|l|l|l|}
\multicolumn{3}{c}{$y$} \\ \hline
%\multirow{3}{*}{$\hat{y}$} \\
& \textbf{T} & \textbf{F} \\ \hline
\textbf{T} & TP & FP \\ \hline
\textbf{F} & FN & TN \\ \hline
\end{tabular}
\caption{Truth and prediction comparison.}
\label{tab:revpol}
\end{table}
Can anyone explain what I need to change here to achieve this?
It's easiest to include the "out of table" components as part of the tabular structure:
\documentclass{article}
\usepackage{multirow}% http://ctan.org/pkg/multirow
\begin{document}
\begin{table}[t]
\centering
\begin{tabular}{l|l|l|l|}
\multicolumn{2}{c}{} & \multicolumn{2}{c}{$y$} \\ \cline{3-4}
\multicolumn{2}{c|}{} & \textbf{T} & \textbf{F} \\ \cline{2-4}
\multirow{2}{*}{$\hat{y}$} & \textbf{T} & TP & FP \\ \cline{2-4}
& \textbf{F} & FN & TN \\ \cline{2-4}
\end{tabular}
\caption{Truth and prediction comparison.}
\label{tab:revpol}
\end{table}
\end{document}
\clines are meant to put an \hline only in certain columns. \multicolumn is used to hide some of the vertical lines inserted using your tabular column specification.
On a side note, consider booktabs as a tabular representation alternative.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a problem with the following code:
\begin{table}[!h]
\centering
\caption{Titel}
\resizebox{.95\columnwidth}{!}{%
\begin{tabular}{p{4.5cm}p{10cm}p{3.5cm}}
\hline
Name & \multicolumn{2}{p{\textwidth-3\tabcolsep-\widthof{test}-2\fboxrule}}
{long_title which goes over two coloums}\\
\hline
Explanation & \multicolumn{2}{p{\textwidth-3\tabcolsep-\widthof{test}-2\fboxrule}}
{Explanation which goes over two coloums}\\
\hline
\multirow{3}{*}{Targets}
& Target 1 is long text with two lines & not reached\\
\cline{2-3}
& Target 2 & reached\\
\cline{2-3}
& Target 3 & reached\\
\hline
\end{tabular}%
}
\label{tab:test}%
\end{table}%
I hope this photo helps to understand my problem:
I would like to align the text "Targets" on the top of the cell, like the second table. I'm sure this must be simple to do, but I can't seem to put my finger on it. Please help me with this alignment.
Instead of specifying the widths of the columns explicitly use the l specifier (which may require the array package). An example of its usage would be the following
\begin{center}
\begin{tabular}{ | l | l | l | p{5cm} |}
\hline
Day & Min Temp & Max Temp & Summary \\ \hline
Monday & 11C & 22C & A clear day with lots of sunshine.
However, the strong breeze will bring down the temperatures. \\ \hline
Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
across most of Scotland and Northern Ireland,
but rain reaching the far northwest. \\ \hline
Wednesday & 10C & 21C & Rain will still linger for the morning.
Conditions will improve by early afternoon and continue
throughout the evening. \\
\hline
\end{tabular}
\end{center}
this will provide an output like this
Note the top alignment of all columns.
I hope this helps.