4

I am currently working on a very math-heavy document with a lot of lists. Is it possible to define an \item that automatically puts its content in math mode to avoid having to write \item $ $ all the time? I imagine something like this:

\begin{itemize}
    \mathitem some math
    \item some text
\end{itemize}

I know you can make a math version of the entire itemize environment, but that does not really help since there are many lists with both math and text entries.

1
  • 1
    Welcome to tex.sx. This can undoubtedly be done, but since \item is only started, not ended, the text would probably be best entered between braces -- \mathitem{...} -- which isn't really an improvement. Nov 10, 2019 at 18:29

1 Answer 1

2

The following solution could be useful for you. But you have to avoid (at least) two things:

  1. avoid empty arguments of \mathitem,
  2. the content of \mathitem must be placed within one line (in fact, the end of the line is the argument separator of \mathitem).

enter image description here

Here is the code...

\documentclass{article}


% https://tex.stackexchange.com/questions/125549/using-end-of-line-delimiter-in-plain-tex-macro
% (OPmac-solution)
% ------------------
\def\eoldef#1{%
    \def#1{\begingroup \catcode`\^^M=12 \eoldefA#1}%
        \expandafter\def\csname\string#1:M\endcsname}
{\catcode`\^^M=12
    \gdef\eoldefA#1#2^^M{\endgroup\csname\string#1:M\endcsname{#2}}}

% definition of \mathitem (avoid empty arguments)
\eoldef\mathitem #1{%
    \item $#1$}

\begin{document}
  \begin{itemize}
  \item first item
  \item second item
  \mathitem 4x^2\cdot\sinh (x)
  \item third one
  \mathitem \zeta ^\star (2,1)=2\zeta (3)
  \end{itemize}
\end{document}
2
  • Although paragraph breaks are not permitted within a math environment, I can envision such an item that should be more than one "paragraph". I guess it could be handled as \mathitem ...$\endgraf$... Nov 10, 2019 at 18:56
  • Dearest Marian, always thank you for your attention to me. +1
    – Sebastiano
    Jan 3, 2022 at 16:32

You must log in to answer this question.

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