4

I am inserting the following text inside the cell of a table

\documentclass[a4paper]{book}
\usepackage[latin1]{inputenc}
\usepackage[pdftex, final]{graphicx}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage{color}
\usepackage{marvosym} 
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{color}

\setlength{\tabcolsep}{3pt}

\definecolor{female}{rgb}{1.0,0.2,0.2}
\definecolor{male} {rgb}{0.2,0.2,1.0}

\newcommand{\hgF}[1]{
\begin{description} \parskip0pt \parsep0pt 
\itemsep0pt \partopsep0pt
\item[{\color{female}{\Female}}]%
{\color{female}{{\Large {\bf #1}}}}%
\end{description}%
}

\begin{document}

\begin{landscape}
\begin{longtable}{| p{0.4cm} | p{3.5cm} | p{1.8cm} | p{3.2cm} | p{3.5cm} | p{1.8cm} | p{3.2cm} | p{1.8cm} | p{3.2cm} |}
\hline 
1 & \hgF{Louise Get} & 01/01/1847 & Revel (Haute-Garonne) & \hgF{Alphonse Martin} & 20/03/1865 & Revel (Haute-Garonne) & 07/10/1951 & Revel (Haute-Garonne) \\ [5pt]
\hline 
\end{longtable}
\end{landscape}

\end{document}

I end up with way too much white space before and after the "FirstName LastName" text. Which are the dimensions controlling this additional spacing?

Secondary question, how do I (simply) avoid stretching the other text across the column width (hence the \flushleft command I had earlier!!).

Thanks for your help

  • 1
    Can you show a complete MWE? – egreg Feb 24 '15 at 13:43
  • what are you trying to achieve with the flushleft (which isn't doing much other than affecting the vertical space) – David Carlisle Feb 24 '15 at 13:57
  • removed the \flushleft (left-over from previous trial and error). Spacing before and after still excessive! – Henri Feb 24 '15 at 14:02
6

\Large is a switch, \bf is deprecated and \color{female} doesn't take an argument too. So you need

\newcommand{\hgF}[1]{%
\begin{description} [nosep,labelwidth=0.75em,leftmargin=\dimexpr\labelwidth+\labelsep,
                           before=\vspace{-0.7\baselineskip},after=\vspace{-\baselineskip}]
\item[\color{female}\Female]%
{\color{female}\Large\bfseries#1}%
\end{description}%
}

Further, you may need to have \raggedright columns with

\usepackage{array}
\usepackage{ragged2e}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}

With this we have:

\documentclass[a4paper]{book}
\usepackage[latin1]{inputenc}
\usepackage[pdftex, final]{graphicx}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage{color}
\usepackage{marvosym}
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{color}
\usepackage{enumitem}

\setlength{\tabcolsep}{3pt}

\definecolor{female}{rgb}{1.0,0.2,0.2}
\definecolor{male} {rgb}{0.2,0.2,1.0}

\newcommand{\hgF}[1]{%
\begin{description} [nosep,labelwidth=0.75em,leftmargin=\dimexpr\labelwidth+\labelsep,
                                 before=\vspace{-0.7\baselineskip},after=\vspace{-\baselineskip}]
\item[\color{female}\Female]%
{\color{female}\Large\bfseries#1}%
\end{description}%
}

\usepackage{array}
\usepackage{ragged2e}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}

\begin{document}

\begin{landscape}
\begin{longtable}{| P{0.4cm} | P{3.5cm} | P{1.8cm} | P{3.2cm} | P{3.5cm} | P{1.8cm} | P{3.2cm} | P{1.8cm} | P{3.2cm} |}
\hline
1 & \hgF{Louise Get} & 01/01/1847 & Revel (Haute-Garonne) & \hgF{Alphonse Martin} & 20/03/1865 & Revel (Haute-Garonne) & 07/10/1951 & Revel (Haute-Garonne) \\ [5pt]
\hline
\end{longtable}
\end{landscape}

\end{document}

enter image description here

  • Thanks, progress, but I still would like to reduce significantly the space above and below the "Louise Get" and Alphonse Martin" cells. This is part of a long table which would stretch way too much with those settings. – Henri Feb 24 '15 at 14:40
  • Yes, just like that. I now need to "understand" the logic behind these parameters. I guess this is a classical case of RTFM!! Thanks anyway!! – Henri Feb 24 '15 at 15:41
  • One last question : how do I get the "Martin" to align with the "Alphonse". I tried several things redefining a new environment and resetting \leftmargin to no avail!! Thanks – Henri Feb 24 '15 at 17:31
  • @Henri You have to adjust labelwidth=0.75em,leftmargin=\dimexpr\labelwidth+\labelsep. See the edit. – user11232 Feb 24 '15 at 23:03

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.