0

I'm trying to create following list(description)-like environment (unfortunately, I don't have any MWE yet...):

    'left' part        'counter'  'right' part

       Some label textA   1.1.    Description of label textA
Some longer label textA           Description of longer label textA
       Some label textB   1.2.    Description of label textB
Some longer label textB           Description of longer label textB

'Counter' is enumerate-like counter, left/right parts are multi-line texts (right/left aligned), where width of 'left' part is fixed. All texts are different and this environment are used many time in document.

I tryied to define such environment using enumitem package, but without much success ;(

Thank you very much in advance for any help or idea!

Best regards,

Lubos

1
  • 1
    This is more like of a table with wrapping content of the cell than a description list, in my point of view
    – user31729
    Commented Mar 29, 2017 at 13:24

1 Answer 1

0

You can do something along the following lines. The definitions below define an environment descenum and a command \descenumitem to be used like this:

\begin{descenum}
\descenumitem{...label1...}{...description1...} 
\descenumitem{...label2...}{...description2...}
...
\end{descenum}

Add the following lines to your preamble.

\newcounter{descenum}
\renewcommand\thedescenum{\arabic{section}.\arabic{descenum}}
\newlength\descenumwidth
\newenvironment{descenum}[1][0.3\linewidth]%
  {\setcounter{descenum}{0}%
   \setlength\descenumwidth{#1}%
   \parindent0mm%
   \medskip
  }%
  {}
\newcommand\descenumitem[2]%
  {\refstepcounter{descenum}%
   \par
   \parbox[t]{\descenumwidth}{\raggedleft#1}%
   \makebox[3em]{\thedescenum}%
   \parbox[t]{\dimexpr\linewidth-\descenumwidth-3em}{#2}%
   \bigskip
   \par
  }

The environment descenum has an optional argument that specifies the width of the left column. The default is 0.3\linewidth. You can also use \label to refer to the items in symbolic form.

enter image description here

\documentclass{article}
\newcounter{descenum}
\renewcommand\thedescenum{\arabic{section}.\arabic{descenum}}
\newlength\descenumwidth
\newenvironment{descenum}[1][0.3\linewidth]%
  {\setcounter{descenum}{0}%
   \setlength\descenumwidth{#1}%
   \parindent0mm%
   \medskip
  }%
  {}
\newcommand\descenumitem[2]%
  {\refstepcounter{descenum}%
   \par
   \parbox[t]{\descenumwidth}{\raggedleft#1}%
   \makebox[3em]{\thedescenum}%
   \parbox[t]{\dimexpr\linewidth-\descenumwidth-3em}{#2}%
   \bigskip
   \par
  }
\usepackage{lipsum}
\begin{document}
\section{First section}
\lipsum[2]
\begin{descenum}
\descenumitem
  {Some label textA\\Some longer label textA%
   \label{xxx}%
  }%
  {Description of label textA\\Description of longer label textA}
\descenumitem
  {Some label textB\\Some longer label textB%
  \label{yyy}%
  }%
  {Description of label textB\\Description of longer label textB}
\end{descenum}
\lipsum[2]
See items \ref{xxx} and \ref{yyy}.

\section{Second section}
\lipsum[2]
\begin{descenum}[0.4\linewidth]
\descenumitem
  {Some label textA\\Some longer label textA}%
  {Description of label textA\\Description of longer label textA}
\descenumitem
  {Some label textB\\Some longer label textB}%
  {Description of label textB\\Description of longer label textB}
\end{descenum}
\end{document}
1
  • Many thanks for excellent reply. That's exactly what I'm looking for! Commented Mar 30, 2017 at 7:51

You must log in to answer this question.

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