[Tex/LaTex] \usepackage{parskip} and \tabular

parskipspacingtables

As I had issue with line breaks, How should I do manual line breaks?, I used \usepackage{parskip}.

This worked fine.

But, when I have a tabular environment, there is a lot of vertical spacing before and after the enviroment.

Code:

\documentclass{article}
\usepackage{tabto}
\usepackage{parskip}

\newcommand{\inlinecode}[1]{\texttt{\small\color{blue}{#1}}}
\newcommand{\n}[0]{\\[3mm]}

\begin{document}

This is a line.

This a new paragraph.

\subsubsection{Closing Windows}
\begin{flushright}
\begin{tabular}{p{10mm}p{40mm}p{80mm}}
1 & dskhkdfahsk & khskdahfkhk\n
2 & two & three\n
\end{tabular}
\end{flushright}

Hello1

Hello2

\end{document}

Is there any way I can disable parskip for tabular alone?

Best Answer

The main problem with your example comes from the width of the tabular. For illustration consider the following sequence of flushright environments:

\documentclass{article}

\begin{document}
\begin{flushright}
  \rule{2cm}{0.4pt}
\end{flushright}
\begin{flushright}
  \rule{5cm}{0.4pt}
\end{flushright}
\begin{flushright}
  \rule{10cm}{0.4pt}
\end{flushright}
\begin{flushright}
  \rule{15cm}{0.4pt}
\end{flushright}
\begin{flushright}
  \rule{2cm}{0.4pt}
\end{flushright}
\end{document}

producing

Sample rule outputs

You'll see that there is extra vertical space before the line that is wider than text width.

In your example, the tabular has width 130mm plus the intercolumn spacing and the log file tells you that the line is overfull by 60.8858pt. Reducing the dimension of say the last column, the anomolous spacing disappears:

\documentclass{article}
\usepackage{tabto}
\usepackage{parskip}

\newcommand{\inlinecode}[1]{\texttt{\small\color{blue}{#1}}}
\newcommand{\n}[0]{\\[3mm]}

\begin{document}

This is a line.

This a new paragraph.

\subsubsection{Closing Windows}

\begin{flushright}
  \begin{tabular}{p{10mm}p{40mm}p{30mm}}
    1 & dskhkdfahsk & khskdahfkhk\n
    2 & two & three\n
  \end{tabular}
\end{flushright}

Hello1

Hello2

\end{document}

Sample output

flushright adds some extra vertical spacing (\topsep, standard value 8pt plus 2pt minus 4t, but set to 0pt by the parskip package), but this on its own is not as dramitic as what you were seeing, unless the contents are overwide.

flushright acts like this because it is defined as

\trivlist \raggedleft\item\relax

which creates something akin to

\hfill\strut\hskip 0pt

on the first line. LaTeX then finds an allowable break point at the \hskip, and when the line is overfull, can choose to break there.

Related Question