2

One of my favorite things in Org mode in Emacs or Markdown is that I can quickly build lists by just doing:

- Something
- Foo
- Bar

and it would automatically recognize that as an actual list.

In LaTeX, I often find myself having to type:

\begin{itemize}
    \item Something
    \item Foo
    \item Bar
\end{itemize}

which is unfortunately a lot more typing. This isn't a blocker obviously, but it makes it more difficult to use LaTeX to add / track notes with the power of still harnessing everything else it has to offer.

Moreover, if I copy a list from another document (e.g. Org / markdown or even other formats), chances are that they also use - (or a similar single character) to designate each item in the list.

Easy lists

Is there a way in LaTeX to build "itemize-like" "lists" where each item is defined with a similarly single character (knowing that it's either placed at the beginning of a line or preceded with only space in the line)?

E.g. something like:

\begin{my_list}
- Something
- Foo
- Bar
\end{my_list}

In case it helps others, often times IDEs have macros to help with typing, and that's actually my case - I'm in VSCode, so I can use snippets (~ IDE macros) like bit in Latex-Workshop which expands the word bit to an itemize environment. However that still requires me to do a lot of typing, and I can't even convert (copy) existing lists either (see this issue I reported).

In other words, IDE macros alone could theoretically help, but it would be nice if one could easily do this in LaTeX itself.

9
  • most editors with any kind of tex support at all will let you enter an itemize list with hardly any more keystrokes than the org mode syntax that you show which is generally more robust than doing this in latex (making - \item` would be easy enough, but catching the start and end of the list is likely to be fragile) Nov 27 '19 at 22:35
  • in emacs for example three keystroke C-c e <return> adds \begin{itemize}\item \end{itemize} with the cursor after \item, then after typing the item a single keystroke M-return adds newline space \item space ready for the next item so that is less keystrokes than typing newline space - space by hand, Nov 27 '19 at 22:40
  • Thanks that's the same thing with bit above @DavidCarlisle -- but e.g. I have lists in other documents that I'd like to bring to LaTeX and they are formatted with simple bullets. Also, if I want to say, re-organize or merge my items, I end up having to delete or reinsert \item (a whole word). I know in Emacs there are also "word delete" commands (as in VSCode), and I use them of course, but it's just more verbose to have to manage \item's or insert them (replacing, e.g. -) when I bring lists from any source. Nov 27 '19 at 22:44
  • but what exactly do you want the syntax to be, for example you could make - active and defined to be \item which would do the case you give here but would mean you can't do x-ray without special precautions, or you could make the definition more fragile that tries to do \item sometimes and a hyphen or math mode minus in others, that's possible but fragile and likely to clash with other packages used Nov 27 '19 at 22:47
  • if you want to detect - at beginning of line then you have to turn off tex's normal interpretation of a line end as a space (which is again possible but likely to have other effects) simplest would be if you had a blank line between each item as then you just need to detect a - at the start of a paragraph which is simple to detect and very unlikely to occur in natural text so safe to redefine. Nov 27 '19 at 22:51
1

Just for interesting. You are asking for thinks which are default in OpTeX format:

\begitems
* Something
* Foo
* Bar
\enditems

And the feature mentioned in the package easylist in the answer above is implemented as OpTeX trick 0048

0

Found a good solution for this problem using the markdown package. As long as you don't need to use other LaTeX commands inside the list, it works great.

Here's an example:

\documentclass{article}
\usepackage{markdown}

\usepackage{lipsum}  

\begin{document}

\lipsum[66]

\begin{markdown}
Here is a Markdown list:

* Create a list by starting a line with `+`, `-`, or `*`
* Sub-lists are made by indenting 2 spaces:
  - Marker character change forces new list start:
    * Ac tristique libero volutpat at
    + Facilisis in pretium nisl aliquet
    - Nulla volutpat aliquam velit
+ Very easy!

\end{markdown}

\lipsum[75]

\end{document}

Result

0

As noted in the comments, the easylist package can be used here. This package also supports itemize style unnumbered lists.

MWE:

\documentclass{article}
\usepackage[sharp]{easylist}

\begin{document}

Here is an Easylist list:
\begin{easylist}[itemize]
# Create a list by starting a line with \#
# Sub-lists are made by adding extra list symbols:
  ## Level two
## Indentation optional
    ## \LaTeX\ symbols possible: $\sum_\infty$
    ### Level 3
# Very easy!
\end{easylist}
\end{document}

Result:

enter image description here

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.