Creating a Gantt Chart and to fit page correctly in Latex - tex

At the moment I have made a Gantt Chart, but as you see from the image you cannot see it properly and looks messy. I have tried to tweak but have had no luck with it. If anyone can help me to make it look better please. This is my first attempt of trying to create a Gantt Chart. Also I have tried making it so that it shows both an active line to where we are currently in the process. Additionally if a task is less then week a way of showing this without making the Gantt Chart exceedingly long. Any suggestions?
http://imgur.com/a/TJqgl
\documentclass[final]{cmpreport}
\subsection{Gantt Chart \& Critical Path}
\begin{sideways}
\newganttchartelement{voidbar}{
voidbar/.style={
draw=black,
top color=black!25,
bottom color=black!23
}}
\begin{ganttchart}[x unit=0.27cm, vgrid, title label font=\footnotesize,
canvas/.style={draw=black, dotted}]{1}{44}
\gantttitlelist{1,...,22}{2} \\
%the elements, bars and milestones, are identified as elem0, elem1, etc
%elem1
\ganttbar{A.Project Assigned}{1}{2} \\ %elem0
\ganttbar{B. Create Plan}{1}{4} \\ %elem1
\ganttbar{C. Ambassador Requirements}{5}{6} \\ %elem2
\ganttbar{D. Recruit Ambassadors} {7}{8} \\
\ganttbar{E. Communicate with Ambassadors } {9}{10} \\
\ganttbar {F. Set Marketing Objectives} {11}{11} \\
\ganttbar {G. Design, publish \& evaluate survey} {11}{14} \\
\ganttbar {H. Design Marketing Comms} {15}{18} \\
\ganttbar {I. Execute Plan} {19}{24} \\
\ganttbar {J. Set Webpage Objectives} {25}{25} \\
\ganttbar {K. Website Research} {25}{26} \\
\ganttbar {L. Website Prototype} {27}{28} \\
\ganttbar {M. Approve design/develop} {28}{29} \\
\ganttbar {N. Test \& evaluate} {30}{30} \\
\ganttbar {O. Venue \& theme} {31}{34} \\
\ganttbar {P. Choose Catering \& Entertainment } {35}{36} \\
\ganttbar {Q. Final Presentation} {37}{37} \\
\ganttlink{elem0}{elem2}
\ganttlink{elem1}{elem2}
\ganttlink{elem2}{elem3}
\ganttlink{elem5}{elem6}
\ganttlink{elem8}{elem9}
\ganttlink{elem9}{elem10}
\ganttlink{elem9}{elem11}
\end{ganttchart}
\end{sideways}

I know it's a very old question but today I began learning about pgfgantt and I found that there is the expand chart option for ganttchart to resize the diagram. Example:
expand chart=1.2\textwidth
More info at the pgfgantt package documentation:
http://bay.uchicago.edu/CTAN/graphics/pgf/contrib/pgfgantt/pgfgantt.pdf

Related

RMarkdown Knitr Won't Render LaTeX tabular table in pdf

I'm trying to format a table using latex notation in RMarkdown. My code is the following:
\begin{table}[h!]
\center
\begin{tabular}{l|c|c}
\hline
Model & Coefficient & \\
Predictors & Value $ p-value\\
\hline
Intercept & -1.716 & 0.022\\
Retire & 0.197 & 0.020\\
Age & -0.015 & 0.020\\
Health Status & 0.312 & <0.001\\
Income & 0.002 & 0.002\\
Years of Education & 0.114 & <0.001\\
Married & 0.579 & <0.001\\
Hispanic & -0.810 & <0.001\\
\hline
\end{tabular}
\end{table}
For some reason though, when I go to knit the document together, I get the following error:
You may need to add $ $ around a certain inline R expression `r ` in draft.Rmd (see the above hint). See https://github.com/rstudio/rmarkdown/issues/385 for more info.
Error: LaTeX failed to compile draft.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See draft.log for more info.
Execution halted
When I remove this chunk, it knits together fine (including other tables I have put together using this method) and I can't figure out what is going on with this code. Any help would be great!
Two problems:
you have one $ instead of a &
it is \centering or \begin{center}...\end{center}, but not \center (this kind of works only by accident)
Furthermore, I suggest you take a look at the siunitx package to get correct minus/< signs and proper alignment of the cells. Also the booktabs package might be worth a look to get a good looking table.
\documentclass{article}
\begin{document}
\begin{table}[h!]
\centering
\begin{tabular}{l|c|c}
\hline
Model & Coefficient & \\
Predictors & Value & p-value\\
\hline
Intercept & -1.716 & 0.022\\
Retire & 0.197 & 0.020\\
Age & -0.015 & 0.020\\
Health Status & 0.312 & <0.001\\
Income & 0.002 & 0.002\\
Years of Education & 0.114 & <0.001\\
Married & 0.579 & <0.001\\
Hispanic & -0.810 & <0.001\\
\hline
\end{tabular}
\end{table}
\end{document}

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}

Making self-adjusting table in latex

I am trying to create self-adjusting table in latex. THis is going to be a big table so I need text to go to the next line if not enough space but I am not able to do this. I need to have 5 columns.
Below is the image of what I have managed but "description" is now going into the next cell. I'd appreciate if someone could tell me where I am going wrong. I have spent so much time on this
Code I am using,
\begin{table}[h]
\begin{tabularx}{\textwidth}{|l|X|X|X|X|}
\hline
Author & Clustering Technique & Dataset & Description & Industry\\
\hline
\citeauthor{shen2009study} & Quantiles & Customer and Transaction Department store & RFM; Customer Lifetime Value; Target Marketing; Data Mining
& Retail Store \\
\hline
\citeauthor{aggelis2005customer} & Quantiles & E-Banking Dataset & Data Mining; e-banking; RFM analysis & Banking\\
\hline
\end{tabularx}
\end{table}
EDIT: I also need it either to fit on one page or be able to continue in the next page.
Very belated answer...
To adjust the width of the column I have used p{.1\textwidth}, this is paragraph alignment with width of the column equal to 0.1 times the width of the text body (or other fraction of it).
For the table to continue in next page(s), if necessary, I have used the excellent environment longtable from the package with the same name.
\documentclass{article}
\usepackage{longtable,natbib}
\begin{document}
\begin{longtable}{|p{.1\textwidth}|p{.15\textwidth}|p{.25\textwidth}|p{.3\textwidth}|p{.15\textwidth}|}
%\caption[Short caption]{Full caption}\label{longt}\\
\hline
% content of first header
Author & Clustering Technique & Dataset & Description & Industry\\
\hline
\endfirsthead
% content of following headers if the table continues in other page(s)
Author & Clustering Technique & Dataset & Description & Industry\\
\hline
\endhead
% content of all footers
\hline
\endfoot
% content of last footer
\hline
\endlastfoot
\citeauthor{shen2009study} & Quantiles & Customer and Transaction Department store & RFM; Customer Lifetime Value; Target Marketing; Data Mining & Retail Store\\
\hline
\citeauthor{aggelis2005customer} & Quantiles & E-Banking Dataset & Data Mining; e-banking; RFM analysis & Banking\\
\end{longtable}
\end{document}
The output of the code above:
To avoid intruding into the next cell, you can help latex by suggesting possible hyphenation points for description
\documentclass{book}
\usepackage{tabularx}
\begin{document}
\begin{table}[h]
\begin{tabularx}{\textwidth}{|l|X|X|X|X|}
\hline
Author & Clustering Technique & Dataset & De\-scrip\-tion & Industry\\
\hline
xxx & Quantiles & Customer and Transaction Department store & RFM; Customer Lifetime Value; Target Marketing; Data Mining
& Retail Store \\
\hline
xxxxxx xxx xxxx xxxxxx xxx & Quantiles & E-Banking Dataset & Data Mining; e-banking; RFM analysis & Banking\\
\hline
\end{tabularx}
\end{table}
\end{document}
(if you need the table to allow page breaks, use the xltabular package instead)

I want to add two tables one after one in a section using latex. But, my second table is going to another section. What to do?

In my 2nd section I want to add two table. One table is in the right position, but the second table went to the next section. it was supposed to be in the previous section. How can I bring the second table in the right section?
Here is the code I used:
% table 3 begins
\begin{table}[h]
\centering
\caption{}
\label{my-label}
\begin{tabular}{cccc}
\hline
\textbf{Properties} & \textbf{Model 1} & \textbf{Model 2} & \textbf{Model 3} \\ \hline
\begin{tabular}[c]{#{}c#{}}Training\\ Window width\end{tabular} & 2 & 2 & 1 \\
\begin{tabular}[c]{#{}c#{}}Training\\ window step\end{tabular} & 1 & 1 & 1 \\
\begin{tabular}[c]{#{}c#{}}Test\\ window width\end{tabular} & 2 & 2 & 1 \\
Horizon & 5 & 10 & 15 \\
\begin{tabular}[c]{#{}c#{}}Cumulative\\ training\end{tabular} & No & No & No \\ \hline
\end{tabular}
\end{table}
\\
% table 4 begins
\begin{table}[!t]
\centering
\caption{}
\label{my-label}
\begin{tabular}{ccccc}
\hline
\textbf{Date} & \textbf{\begin{tabular}[c]{#{}c#{}}Actual Price\\ (USD)\end{tabular}} & \multicolumn{3}{c}{\textbf{Predicted Price}} \\ \hline
\textbf{} & \textbf{} & \textbf{Model 1} & \textbf{Model 1} & \textbf{Model 1} \\
13-01-15 & 89.30 & 89.44 & 87.90 & 91.71 \\
07-11-14 & 78.76 & 77.63 & 77.72 & 78.08 \\
29-07-14 & 75.44 & 75.00 & 76.43 & 77.59 \\
04-06-14 & 77.12 & 76.26 & 76.96 & 77.53 \\ \hline
\end{tabular}
\end{table}
In addition to Norman Gray:s answer, I might also add that there are several different methods to force your floats (tables/figures and so on) to stay within "their" sections.
One method would be to use the placeins package, as described in its documentation. From the documentation:
Placeins.sty keeps floats ‘in their place’, preventing them from
floating past a “\FloatBarrier” command into another section. To use
it, declare “\usepackage{placeins}” and insert “\FloatBarrier” at
places that floats should not move past, perhaps at every
“\section”.
...
If you specify “\usepackage[section]{placeins}”, then the “\section” command will be redefined with “\FloatBarrier” inserted at the beginning.
So in your case, try adding
\usepackage[section]{placeins}
in your document header.
It's not so much that LaTeX put the second table in the next section, but it put it on the next page that had room. LaTeX has a slightly intricate algorithm for working out how best to relocate tables and figures, but unfortunately its decisions can be rather ... unpredictable.
One solution is to accept that this is OK, and perhaps give the reader a clue by saying see table~\ref{my-label} on page~\pageref{my-label}, which helps the reader find the table. The varioref package can do this in a smarter way. I think, myself, that this is the best solution.
Another is to adjust the maximum fraction of a page that LaTeX will permit to have tables. A command like \renewcommand{\floatpagefraction}{0.75} will permit up to three quarters of the page to be floats – so only a quarter of the page text – before spilling on to a new page. This can quickly look ugly if the fraction is too large, however.
This is a very common problem, and searching online for ‘controlling latex floats’, or similar, should uncover lots of help. There should also be help on this topic elsewhere on Stackoverflow, or on the companion TeX site.

Length parbox LaTeX

I am trying to build a table on LaTeX with parbox. I have found how to do with parbox. However, the length between rows makes the text so pack. Do you know how to increase the length?
\documentclass{article}
\usepackage{multirow}
\begin{document}
{\raggedright
\vspace{3pt} \noindent
\begin{tabular}{|p{108pt}|p{223pt}|p{52pt}|}
\hline
\parbox{108pt}{\raggedright
Attribute
} & \parbox{223pt}{\raggedright
Description
} & \parbox{52pt}{\raggedright
Characteristic
} \\
\hline
\parbox{108pt}{\raggedright
Language
} & \parbox{223pt}{\raggedright
Programming language of the source code.
} & \parbox{52pt}{\raggedright \multirow{5}{*}{
Project
}} \\
\cline{1-3}
\parbox{108pt}{\raggedright
Team\_size
} & \parbox[70em]{223pt}{\raggedright
Number of active core team members during the last 3 months prior to creation.
} & \\
\cline{1-3}
\parbox[15em]{108pt}{\raggedright
Perc\_external\_contribs
} & \parbox{223pt}{\raggedright
Ratio of commits from external contributors over core team members in the last 3 months prior to creation of pull request.
} & \\
\cline{1-2}
\hline
\end{tabular}
\vspace{2pt}
\end{document}
Thank you for your help.
The tabular columns are already set using a paragraph specification, so there's no need to set each cell using a \parbox (of similar width) as well.
You might be interested in tabularx as it allows for a flexibly-width X-column:
\documentclass{article}
\usepackage{tabularx}% Loads the array package
\begin{document}
\noindent
\begin{tabularx}{\linewidth}{|>{\raggedright}p{108pt}|>{\raggedright}X|>{\raggedright\arraybackslash}p{62pt}|}
\hline
Attribute & Description & Characteristic \\
\hline
Language & Programming language of the source code. & Project \\
\hline
Team\_size & Number of active core team members during the last 3 months prior to creation. & \\
\hline
Perc\_external\_contribs & Ratio of commits from external contributors over core team
members in the last 3 months prior to creation of pull request. & \\
\hline
\end{tabularx}
\end{document}
If you wish to adjust the padding further, consider reading up on Column and row padding in tables.

Resources