0

how can I justify the text in a column in a longtable? I have a table like this but I do not know how to justify the text or set the text to adjust to the column width

\documentclass[12pt,a4paper,oneside]{report}
\usepackage{longtable} %Long tables
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
\begin{longtable}[H]{|c|c|l|c|l|c|c|}
\hline
    &&\begin{tabular}[c]{@{}l@{}}Staff poorly or\\not trained in\\the 
    archiving of the\\reports\end{tabular}&3&\begin{tabular}[c]
   {@{}l@{}}Implementation of training programs at the\\start of the trial, during the trial\\and when new staff members are recruited\\and define clearly in a written document\\the require skills and experience\\to be part of the trial staff.\\The requirements should be defined by\\a member of the staff with enough\\experience. Monitorise through audit\\its accomplishment\end{tabular}&1&9\\
    \hline
   \end{longtable}
   \end{landscape}
   \end{document}
1

Use the p{<width>} column type to get text justified within that <width>. If you need also vertical centering use m{<width>} (requires array package). Finally to prevent ugly word hyphenations (as a result of justification), precede the m columns with >{\raggedright}.

\documentclass[12pt,a4paper,oneside]{report}
\usepackage{longtable} %Long tables
\usepackage{pdflscape,array}
\begin{document}
\begin{landscape}
\begin{longtable}{|c|c|>{\raggedright}m{4cm}|c|>{\raggedright}m{7cm}|c|c|}
\hline
 & & Staff poorly or not trained in the archiving of the reports & 3 & 
 Implementation of training programs at the start of the trial, during the trial and when new staff members are recruited and define clearly in a written document the require skills and experience to be part of the trial staff. The requirements should be defined by a member of the staff with enough experience. Monitorise through audit its accomplishment & 1 & 9 \\
 \hline
\end{longtable}
\end{landscape}

\end{document}
2
  • Thanks! that really helped me, I have the text to adjust to the width but is not aligned on the right, just on the left. Is there a way to do that? – user141098 Aug 22 '17 at 14:22
  • @user141098 - Yes, >{\raggedright} is responsible for this, if you don't like the left-alignment, just remove these two >{\raggedright} before m{..}. – AboAmmar Aug 22 '17 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.