Text FormattingSpecific Paragraph Spacing in Parts of a Document

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
heavytull
Posts: 16
Joined: Wed Feb 08, 2012 9:38 pm

Specific Paragraph Spacing in Parts of a Document

Post by heavytull »

I have two commands in a .sty file as following:

Code: Select all

\newcommand{\tabitem}[3][.25em]{%
  \begin{tabular}{@{}p{2em}@{\hspace{.2em}}p{\textwidth}@{}}%
    \ifthenelse{\equal{#2}{}}{}{\raggedleft\hintstyle{#2}} & {#3}%
  \end{tabular}%
  \par\addvspace{#1}}

\newcommand{\entrydefinition}[2]{\tabitem{}{\bfseries{#1}\newline#2}}
In the .tex file when the command is used while the first argument is a short title the second argument can eat pages. So It will be structured into paragraphs. But I would like the vertical space value between paragraphs to be set in the command definition in the .sty file. I tried something like that:

Code: Select all

\newcommand{\entrydefinition}[2]{\bfseries{#1}\newline{\parskip{6pt}#2}}
or

Code: Select all

\newcommand{\entrydefinition}[2]{\bfseries{#1}\newline{\setlength{\parskip}{6pt}#2}}
but no one works (certainly because of the tabular environment).

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

heavytull
Posts: 16
Joined: Wed Feb 08, 2012 9:38 pm

Re: Specific Paragraph Spacing in Parts of a Document

Post by heavytull »

I forgot that the \newcommand macro I was actually using was the starred one. The starred one won't allow the use of '\par' in its argument.
heavytull
Posts: 16
Joined: Wed Feb 08, 2012 9:38 pm

Specific Paragraph Spacing in Parts of a Document

Post by heavytull »

I would like some portions of my document to have different paragraphs spacing. For that I put those portions into brackets (some people say groups) and add at the beginning of each portion \setlength{\parskip}{XXpt}. When paragraphs are ended with \par this technique works almost. It indeed adjust the spacing as set in the group but even for the last spacing before the group. And amazingly the spacing after the last paragraph into the group is not adjusted. Below is a compilable example.

Code: Select all

\documentclass{article}
\usepackage{ifthen}
     
\newcommand*{\tabitem}[3][.25em]{%
  \begin{tabular}{@{}p{2em}@{\hspace{.2em}}p{\textwidth}@{}}%
        \ifthenelse{\equal{#2}{}}{}{\raggedleft\textit{#2}} & {#3}%
  \end{tabular}%
  \par\addvspace{#1}%
}
     
\newcommand*{\entrydescription}[2][.25em]{\tabitem[#1]{}{%
  {\bfseries#2}}}
     
\begin{document}
  \noindent{%
  This\par is\par a\par}
  \noindent
  \entrydescription{TEST}
  {\setlength{\parskip}{10pt}%
  This\par is\par a\par test}
\end{document}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Specific Paragraph Spacing in Parts of a Document

Post by localghost »

Just for information to other users to be aware of possibly already existing solutions. The question has also been posted to comp.text.tex (ctt).
Post Reply