2

I'd like to turn a paragraph containing several “subparagraps” into an equivalent inline list. See the following code.

\documentclass{article}
\usepackage{amsthm}
\usepackage{enumitem}
% \usepackage{tikz}

\newlist{description_inline}{description*}{1}
\setlist[description_inline]{format=\myformat}
\newcommand \myformat [1] {\normalfont\emph{#1}}

\newlist{description_inline_fixed}{description*}{1}
\setlist[description_inline_fixed]{format=\myformatfixed, afterlabel=\unskip}
\newcommand \myformatfixed [1] {\normalfont\emph{#1} }

\begin{document}
    \begin{proof}
        \emph{Case A.} We do something to show Case A. \emph{Case B.} Now we proooooooooove Case B.
    \end{proof}
    \begin{proof}
        \begin{description_inline}
            \item[Case A.] We do something to show Case A.
            \item[Case B.] Now we proooooooooove Case B.
        \end{description_inline}
    \end{proof}
    \begin{proof}
        \begin{description_inline_fixed}
            \item[Case A.] We do something to show Case A.
            \item[Case B.] Now we proooooooooove Case B.
        \end{description_inline_fixed}
    \end{proof}
\end{document}

The following proofs are produced: The proofs produced

It seems that there is a stretchable skip after every label, which may cause ugly spaces depending on line break. That's why I put \unskip after every label. But is it the right solution?

And why this problem occurs in the first place? I don't see any benefit of having there the stretchable skip. It feels wrong when I learn about inline lists, try them, and the first thing I get looks like a bug.

Also feel free to suggest any other changes in the code.

Updated: When I tried to use my solution in my thesis, it just didn't work. The ugly spaces appeared no matter of \unskip being used. After some time I found out, that it doesn't work when TikZ is used. What the heck?!

  • Where are those ugly spaces? If I compile you MWE the problem is not obvious to me – daleif Mar 9 '16 at 14:50
  • BTW: from a reading standpoint, having all cases be inline like this might not be the best solution, a reader might loose track of that we are currently dealing with. – daleif Mar 9 '16 at 14:52
  • @campa: I'm putting there a space in \myformat because I want there a normal space, \unskip should destroy the stretching one. – user87690 Mar 9 '16 at 14:56
  • @daleif: In the presented MWE, the problem shoud be fixed by the \unskip, but it is reintroduced if TikZ is used. – user87690 Mar 9 '16 at 14:57
  • 1
    not a good solution: the whitespace comes from an \hfil in the definition of \enit@align@left in enumitem.sty. You could re-define that command or get rid of it by something crazy like \newcommand*\ignorenext[1]{} and \newcommand\myformat[1]{\normalfont\emph{#1.} \ignorenext}. – wrtlprnft Mar 9 '16 at 16:30
2

As I said in my comment, there's an \hfil that gets inserted after the item label to get it to align left. Fortunately, we can change the alignment with the align option and define new alignment types with \SetLabelAlign:

\documentclass{article}
\usepackage{amsthm}
\usepackage{enumitem}
\usepackage{tikz}

\newlist{description_inline}{description*}{1}
\setlist[description_inline]{format=\myformat}
\newcommand \myformat [1] {\normalfont\emph{#1} }

\SetLabelAlign{don't}{#1}
\newlist{description_inline_fixed}{description*}{1}
\setlist[description_inline_fixed]{format=\myformatfixed,align=don't}
\newcommand \myformatfixed [1] {\normalfont\emph{#1}}

\begin{document}
    \begin{proof}
        \emph{Case A.} We do something to show Case A. \emph{Case B.} Now we proooooooooove Case B.
    \end{proof}
    \begin{proof}
        \begin{description_inline}
            \item[Case A.] We do something to show Case A.
            \item[Case B.] Now we proooooooooove Case B.
        \end{description_inline}
    \end{proof}
    \begin{proof}
        \begin{description_inline_fixed}
            \item[Case A.] We do something to show Case A.
            \item[Case B.] Now we proooooooooove Case B.
        \end{description_inline_fixed}
    \end{proof}
\end{document}

output

While I have no idea why enumitem tries to align inline list items in the first place, this option seems safer to me than any method for deleting the \hfil after or before it has been inserted. If the package is ever changed to skip the alignment step, the align option will hopefully safely become a no-op.

  • That's an elegant solution. Thank you very much for your insight. – user87690 Mar 9 '16 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.