Related questions:
I am looking to create an environment which groups definitions for better legibility. Example:
\begin{gdefi}
\defi{Ring}{Some long description}
\defi{Homomorphism}{Some long description}
\end{gdefi}
The first argument to defi should create a column of uniform width (of the longest argument), with the remaining page-width taken up by the second argument.
I would also like for this environment to break across pages for longer groups of definitions.
Implementations I have tried:
- Create a two-column
ltablex, as suggested here, but have been unable to get my document to compile. See below for a non-page-breaking version usingtabularx. - Create a
descriptionenvironment which, however, does not use visually separated columns. Usingenumitem, I was able to tweak this somewhat by manually setting a fixed width for the left column. See below for a version usingenumitemand a manually-specified width of the left column.
I much prefer approach #1, as it appears to be more more easily extendible. One extension I have in mind is creating different definition commands, each with its own formatting.
Example 1: A non-page-breaking version using tabularx
\documentclass[parskip=half-, DIV=12]{scrartcl}
\usepackage{xparse}
\usepackage{tabularx}
\usepackage{lipsum}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newif\ifingdefi
\newcommand{\defi}[2]{%
\ifingdefi%
\textbf{#1}:~\\
\else%
\begin{tabularx}{\textwidth}{@{}l@{~}L@{}}
\textbf{#1}:~\\%
\end{tabularx}%
\fi
}
\DeclareDocumentEnvironment{gdefi}{o}
{%
\ingdefitrue%
\tabularx{\textwidth}{@{}l@{~}L@{}}
}
{%
\endtabularx%
\ingdefifalse%
}
\begin{document}
% This environment should break across two pages
\begin{gdefi}
\defi{Def. 1}{\lipsum[1]}
\defi{Definition 2}{\lipsum[1]}
\defi{Definition 3}{\lipsum[1]}
\defi{Definition 4}{\lipsum[1]}
\defi{Definition 5}{\lipsum[1]}
\end{gdefi}
\end{document}
Example 2: An implementation using enumitem, which only works when manually specifying the width of the first column.
\documentclass[parskip=half-, DIV=12]{scrartcl}
\usepackage{xparse}
\usepackage{lipsum}
\newif\ifingdefi
\newcommand{\defi}[2]{%
\ifingdefi%
\item[#1] #2
\else%
\begin{description}
\item[#1] #2
\end{description}%
\fi
}
\DeclareDocumentEnvironment{gdefi}{o}
{%
\ingdefitrue%
\IfNoValueTF{#1}{%
\begin{description}
}{%
\begin{description}[#1]
}
}
{%
\end{description}
\ingdefifalse%
}
\usepackage{enumitem}
\begin{document}
\begin{gdefi}[leftmargin=10em,style=nextline]
\defi{Def. 1}{\lipsum[1]}
\defi{Definition 2}{\lipsum[1]}
\defi{Definition 3}{\lipsum[1]}
\defi{Definition 4}{\lipsum[1]}
\defi{Definition 5}{\lipsum[1]}
\end{gdefi}
\end{document}

xltabular? Did you already try with this package? – leandriis Jan 03 '20 at 10:09longtable-like approach (for example withxltabular) will only introduce page breaks inbetween two Definitions, not within the text of one definition. Depending on the length of the corresponding texts, this might lead to quite large white spaces. Depending on the length of the longest term in the first column compared to the other term, there will be huge amounts of white space and a large separation between the term and its definition text. – leandriis Jan 03 '20 at 10:16description-like approach would on the other hand enable page breaks within description texts. Personally, I would stick to a standarddefinitionenvironment only slightly indenting the second an dfollowing lines of the respective definition. To add more visual separation between consecutive items, you could also introduce a small vertical white space between them using theitemsepoption. – leandriis Jan 03 '20 at 10:17xltabularindeed works the way I want it to. I will also look into your suggestion of a customizeddescriptionenvironment, I certainly see the appeal of this approach. – Julian Jan 03 '20 at 18:43