2

NOTE: At first glance, this may appear to duplicate Using the ENTER key as a delimiter in an itemized list. However, that question involved a description-style list (not enumerated) and the solution was to remove the list from the \item world. The below case involves a numbered list, so it seems more likely that a solution will need to remain in the \item world. To keep this question self-contained, I repeat much of the prior question.

Background: My wife is writing a family cookbook. Mostly as a learning exercise for me, I am putting together LaTex code for the project. I would like to make the recipe data entry as simple as possible, with (almost) all the processing code hidden in the back end. My first pass for entering recipe instruction steps is shown below. I use an \InstructionList command that takes a variable number of arguments. As you see, using \SplitList, each numbered instruction is delimited by the [;] character. In an ideal world, my wife could just type the ingredients and use the new paragraph indicator (two consecutive ENTER keys) as the delimiter between numbered instructions. I have tried \cr and \newline and \par as the\SplitList delimiter with no luck.

My Question: Is there a way to set two consecutive ENTER keys as the \SplitList delimiter between a variable length list of recipe instruction items? (Other solutions without \SplitList are also welcome).

I specifically note the answer here: Splitting on new lines using \SplitList by Bruno Le Floch, which appears to allow \SplitList to process arguments at a single ENTER character (probably not ideal for lengthy recipe instructions). I don’t understand that code well enough to know if it can (or should) be modified for my "new paragraph" approach.

\documentclass[11pt]{book}
\usepackage{enumitem, xparse}                                 

\NewDocumentCommand \InstructionList { >{\SplitList{;}} m }{% 
\begin{enumerate}[noitemsep] %
\ProcessList{#1}{\ProcessInstructions}
\end{enumerate}
}
\newcommand\ProcessInstructions[1]{\item #1}

\begin{document}
\InstructionList{
Preheat oven to 350 degrees (325 for convection). Spray baking sheets. ;
In a medium bowl, whisk together flour, cocoa, baking soda/powder and 
salt. Beat the butter and sugar on medium-high speed until light and 
fluffy. Add the eggs one at a time and mix well. Beat in vanilla extract 
and espresso. Add dry ingredients and mix until combined before adding 
nuts and chocolate. Mix just until incorporated. Dough will be stiff and 
sticky. ;
Divide dough into 2 equal pieces. Using as little flour as possible, roll
 each piece into logs that are 18 inches long. Flatten to 2" wide. Brush 
with beaten egg white and sprinkle with sugar. Bake until firm in the 
center, about 20-25 minutes. Cool for about 15 minutes before slicing and
 second bake. ;
With a serrated knife, cut logs into 1/2 inch slices. 
Lay on the baking sheets.  Bake for 10 minutes. 
Turn biscotti over after 5 minutes.
These biscotti harden as they cool, so don't over bake. 
}
\end{document}
2

It's surely possible. 🙂 Just use \par as the delimiter and specify a “long” argument +m.

\documentclass[11pt]{book}
\usepackage{enumitem, xparse}                                 

\NewDocumentCommand{\InstructionList}{ >{\SplitList{\par}} +m }{% 
  \begin{enumerate}[noitemsep]
  \ProcessList{#1}{\ProcessInstructions}
  \end{enumerate}
}
\newcommand\ProcessInstructions[1]{\item #1}

\begin{document}
\InstructionList{
Preheat oven to 350 degrees (325 for convection). Spray baking sheets.

In a medium bowl, whisk together flour, cocoa, baking soda/powder and 
salt. Beat the butter and sugar on medium-high speed until light and 
fluffy. Add the eggs one at a time and mix well. Beat in vanilla extract 
and espresso. Add dry ingredients and mix until combined before adding 
nuts and chocolate. Mix just until incorporated. Dough will be stiff and 
sticky.

Divide dough into 2 equal pieces. Using as little flour as possible, roll
each piece into logs that are 18 inches long. Flatten to 2" wide. Brush 
with beaten egg white and sprinkle with sugar. Bake until firm in the 
center, about 20-25 minutes. Cool for about 15 minutes before slicing and
second bake.

With a serrated knife, cut logs into 1/2 inch slices. 
Lay on the baking sheets.  Bake for 10 minutes. 
Turn biscotti over after 5 minutes.
These biscotti harden as they cool, so don't over bake. 
}

\end{document}

enter image description here

| improve this answer | |

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.