1

I am using LaTeX inside a graphical editor (IPE) for presentations and would like to speed up creating itemize environments, as I use them very frequently. I have different text fields for each item and they all get compiled individually by the editor, so I basically need to re-create the itemize environment for every text field. This is what I currently use:

\newcommand{\e}[1]{\begin{itemize}\item #1\end{itemize}}
\newcommand{\ee}[1]{\begin{itemize}\begin{itemize}\item #1\end{itemize}\end{itemize}}
\newcommand{\eee}[1]{\begin{itemize}\begin{itemize}\begin{itemize}\item #1\end{itemize}\end{itemize}\end{itemize}}

\newcommand{\w}[2][1.]{\begin{enumerate}\item[#1] #2\end{enumerate}} \newcommand{\ww}[2][(a)]{\begin{enumerate}\begin{enumerate}\item[#1] #2\end{enumerate}\end{enumerate}} \newcommand{\www}[2][i.]{\begin{enumerate}\begin{enumerate}\begin{enumerate}\item[#1] #2\end{enumerate}\end{enumerate}\end{enumerate}}

This way I can simply use \e{some text} and \ee{more text} for individual levels of itemize (and enumerate).

Now the question: I'd rather like to use \e some text and \ee more text as this is much simpler to handle. Especially when editing stuff I often have to de-select the braces in order to not overwrite them. But LaTeX only takes a single token as argument when you omit the braces, so I get an annoying line break after the first character.

I could think of multiple solutions:

  • Is it possible to tell LaTeX to use the entire remainder of the line as #1 argument?
  • Is it possible to replicate the behavior of itemize (the symbol of \item, the font size of the three layers, the indentation especially after a line break) without the environment?
  • Is it possible to prevent the line break after \end{itemize} and just continue typing on your \item? This should however still result in correct indentation after a natural line break occurs.

Thank you in advance!

Edit:

Willie Wong provided me with this link that did the trick for itemize. Thank you!

  • 1
    Welcome to TeX.SE! Such shortness on the first sight seems to make code shorter, less time consuming at writing and even easy to understand etc. However, after a while you will recognize that this not a case. Even worse, no one except you will understand what the code means. I would discourage you to do this., – Zarko Feb 27 '20 at 20:19
  • The very first "solution" is possible; instead of using \newcommand it is possible to use \def with the end of line as one of the delimiters of input. Doing so is however slightly tricky, and probably for other reasons not a great idea. – Willie Wong Feb 27 '20 at 20:39
  • Your second and third solutions would make the syntax a lot less like TeX and a lot more like troff. (Unfortunately given your preambled it appears you are constrained to use TeX.) – Willie Wong Feb 27 '20 at 20:53
  • @WillieWong Thank you for the link, that did the trick for itemize. I left enumerate as it is, since I am rarely using it and it relies on an optional argument. Whatever the reasons for not using it may be, it probably does not matter in my situation - I just won't do anything fancy inside my macro. :) I am not producing entire documents with it, but I am separately typesetting individual pieces of text inside a GUI editor. If you'd like to post it as an actual answer, I could mark it as the solution. – Alexej G Feb 28 '20 at 00:50

0 Answers0