21

I've created custom environment with these commands:

\usepackage{relsize}
\newcounter{annotation}
\def\theannotation{\arabic{annotation}}
\newenvironment{annotation}
    {\refstepcounter{annotation}\noindent\begin{smaller}
        \makebox[1.5cm][l]{NOTE \theannotation}}
    {\end{smaller}}

One thing is still missing here - vertical spaces before, and after it. I can add \vspace, but using two consecutive annotations doubles \vspace (after first and before second annotation).

So my question is: how to create vertical space before and after custom environment, so that it doesn't double itself when using with other vertically spaced environments (e.g. description).

Example usage:

\begin{annotation}
    \lipsum[1]
\end{annotation}
\begin{description}
    \item[aaa] asdfasdfasdf
\end{description}
\begin{annotation}
    \lipsum[1]
\end{annotation}

1 Answer 1

27

You are looking for \addvspace.

\documentclass{article}

\usepackage{relsize}
\newcounter{annotation}
% \def\theannotation{\arabic{annotation}}% superfluous with \newcounter
\newenvironment{annotation}
    {\par\addvspace{\baselineskip}\refstepcounter{annotation}\noindent\begin{smaller}
        \makebox[1.5cm][l]{NOTE \theannotation}}
    {\end{smaller}\par\addvspace{\baselineskip}}

\usepackage{lipsum}

\begin{document}

\begin{annotation}
    \lipsum[1]
\end{annotation}
\begin{description}
    \item[aaa] asdfasdfasdf
\end{description}
\begin{annotation}
    \lipsum[1]
\end{annotation}

\end{document}

enter image description here

EDIT: Added missing \par before \addvspace.

1
  • 1
    works, thanks again, I solved second problem by adding \par before \addvspace{\baselineskip} Feb 15, 2012 at 11:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .