I know there has been questions similar to this previously but none of the proposed solutions seem to work for me.
I have a few custom environments I am using in LaTeX. Below is the code for a "licenses" environment. This environment is basically a table and I use the "license" command to specify each row of the table.
\newenvironment{licenses}
{%
\def\lwidth{0.25\textwidth}%
\def\rwidth{0.69\textwidth}%
%
\newcommand\license[3]{%
\ifdef{\separator}{\separator}{}%
##1 & ##3 %
\def\separator{\\}%
}%
%
\begin{longtable}{>{\bfseries}L{\lwidth}!{\VRule}R{\rwidth}}%
}
{\end{longtable}}
I then use the environment as follows... however I have a problem in that the whitespace between each \license
command affect the output.
\begin{licenses}
\license{...}{...}
\license{...}{...}
\license{...}{...}
\end{licenses}
I have tried the \ignorespaces
command and also commands similar to \catcode32=9\relax
, but none of these seem to work in my case.
Here is a minimum working example:
\documentclass[10pt]{article}
\usepackage{etoolbox} % for ifdef
\usepackage{longtable} % for tables that span more than one page
\usepackage{tabularx} % for newcolumntype
\usepackage{xcolor} % for colours
\definecolor{lightgray}{gray}{0.8}
\newcolumntype{L}[1]{>{\raggedleft}p{#1}}
\newcolumntype{R}[1]{p{#1}}
\newcommand\VRule{\color{lightgray}\vrule width 0.5pt}
\newenvironment{licenses}
{%
\def\lwidth{0.25\textwidth}%
\def\rwidth{0.69\textwidth}%
%
\newcommand\license[3]{%
\ifdef{\separator}{\separator}{}%
##1 & ##3 %
\def\separator{\\}%
}%
%
\begin{longtable}{>{\bfseries}L{\lwidth}!{\VRule}R{\rwidth}}
}
{\end{longtable}}
\begin{document}
\section*{Licenses}
\begin{licenses}
\license{Test1}{Test1}{Test1}
\license{Test2}{Test2}{Test2}
\license{Test3}{Test3}{Test3}
\end{licenses}
\end{document}
\documentclass
and the appropriate packages so that those trying to help don't have to recreate it.#2
? but your use of \license only shows two arguments. Please post a complete document that shows the problem.\license
in that way? A simple\newcommand{\license}[3]{#1\\}
outside the definition oflicenses
(or even inside it, with double##
) will do, avoiding the blank lines.