3

current output:

Desc 1 Bla 1

wanted output:

Desc 1: Bla 1


MWEs:

current output:

\documentclass[oneside,12pt]{scrartcl}
\usepackage{polyglossia}
\setdefaultlanguage{german}
\usepackage{fontspec}
\begin{document}
\begin{description}
\item[Desc 1] Bla 1
\end{description}
\end{document}

wanted output:

\documentclass[oneside,12pt]{scrartcl}
\usepackage{polyglossia}
\setdefaultlanguage{german}
\usepackage{fontspec}
\begin{document}
\begin{description}
\item[Desc 1:] Bla 1
\end{description}
\end{document}

of course I know I could do it by regex replace... but i'm pretty sure there is an easier and more elegant way. and also i'm looking for a solution for the case where i have >100 items

rapus95
  • 93

2 Answers2

3

Redefine \descriptionlabel to add the colon:

\documentclass[oneside,12pt]{scrartcl}
\usepackage{polyglossia}
\setdefaultlanguage{german}
\usepackage{fontspec}

\renewcommand*{\descriptionlabel}[1]{\hspace{\labelsep}\descfont #1:}

\begin{document}
\begin{description}
\item[Desc 1] Bla 1
\item[Desc 2] Bla 2
\item[Desc 3] Bla 3
\end{description}
\end{document}

The result:

enter image description here

I didn't make any prevision in the case in which the optional argument of \item isn't used, since this wouldn't make sense in the first place in a description.

Gonzalo Medina
  • 505,128
0

This redefines \item, but will give default behavior (omit the colon) when no optional argument is specified.

\documentclass[oneside,12pt]{scrartcl}
%\usepackage{polyglossia}
%\setdefaultlanguage{german}
%\usepackage{fontspec}
\let\svitem\item
\renewcommand\item[1][\relax]{\ifx\relax#1\svitem\else\svitem[#1:]\fi}
\begin{document}
\begin{description}
\item[Desc 1] Bla 1
\item Default empty tag
\end{description}
\end{document}

enter image description here

Because it redefines \item, the above MWE will affect other list types. However, that can be avoided with the following MWE, which will only affect the description environment.

\documentclass[oneside,12pt]{scrartcl}
%\usepackage{polyglossia}
%\setdefaultlanguage{german}
%\usepackage{fontspec}
\let\svitem\item
\newcommand\altitem[1][\relax]{\ifx\relax#1\svitem\else\svitem[#1:]\fi}
\let\svdescription\description
\def\description{\let\item\altitem\svdescription}
\begin{document}
\begin{description}
\item[Desc 1] Bla 1
\item Default empty tag
\end{description}
\begin{itemize}
\item[Desc 1] Bla 1
\item Default empty tag
\end{itemize}
\end{document}