LaTeX \hrule exceed tabularx width [closed] - latex

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}

Related

Make text in table fit in page [closed]

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 2 years ago.
Improve this question
I have a latex table that extends beyond the page like this
The latex code looks as follows
% Please add the following required packages to your document preamble:
% \usepackage{longtable}
% Note: It may be necessary to compile the document several times to get a multi-page table to line up properly
\begin{longtable}[c]{|l|l|l|}
\hline
Term & Explanation & Comment \\ \hline
\endfirsthead
%
\endhead
%
Product Owner & Otto \& Lene & \\ \hline
Lene & Team Manager & \\ \hline
Otto & Software Engineer & \\ \hline
Angular & Frontend javascript framework to build modern single page applications & \\ \hline
GFS Upload & \begin{tabular}[c]{#{}l#{}}GFS Upload is an internal system used by employees at to insert the extra financial statements that haven't been inserted automatically yet.\\ \\ While there are different financial information the different places want GFS upload sorts by having Chart Bookings and Account Bookings.\end{tabular} & \\ \hline
Chart Booking & Chart Booking is financial statements used to report to Nationalbanken. & \\ \hline
Account Booking & Account booking is used for internal account reporting. & \\ \hline
Cloud 2 & cloud service & \\ \hline
\end{longtable}
I would like the text to fit inside the page, automatically inserting linebreaks. How can I achieve this?
You can use a column of fixed width. You will have to find out yourself which width you'll need for your document, as this will depend from the exact page geometry you use and unfortunately you only provided a not-compilable code fragment and no minimal working example
\documentclass{article}
\usepackage{geometry}
\usepackage{longtable}
\begin{document}
% Please add the following required packages to your document preamble:
% \usepackage{longtable}
% Note: It may be necessary to compile the document several times to get a multi-page table to line up properly
\begin{longtable}[c]{|l|p{9.7cm}|l|}
\hline
Term & Explanation & Comment \\ \hline
\endfirsthead
%
\endhead
%
Product Owner & Otto \& Lene & \\ \hline
Lene & Team Manager & \\ \hline
Otto & Software Engineer & \\ \hline
Angular & Frontend javascript framework to build modern single page applications & \\ \hline
GFS Upload & GFS Upload is an internal system used by employees at to insert the extra financial statements that haven't been inserted automatically yet. While there are different financial information the different places want GFS upload sorts by having Chart Bookings and Account Bookings. & \\ \hline
Chart Booking & Chart Booking is financial statements used to report to Nationalbanken. & \\ \hline
Account Booking & Account booking is used for internal account reporting. & \\ \hline
Cloud 2 & cloud service & \\ \hline
\end{longtable}
\end{document}

how to wrap the text inside the cell while using tabularx in latex? [closed]

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}

Formatting the columns of a table in LaTeX [closed]

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}

How to create a multirow table [closed]

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.

Text alignment on top with multirow command [closed]

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.

Resources