4

This question already has an answer here:

When I have a list like:

  1. one
  2. two

    and immediately afterwards code

It does not render the code correctly.

Here's what the edit-view of this post looks like enter image description here

marked as duplicate by Werner, Henri Menke, AndréC, Raaja, CarLaTeX Mar 6 at 6:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Just insert a line to correct this with 5 successive stars ***** – AndréC Mar 5 at 10:40
  • I just used en empty link [](), as this does not even affect the rendering. Is this the official solution though? – sheß Mar 5 at 10:40
  • 1
    I don't know, that's how I do it in this case to fix this problem. – AndréC Mar 5 at 10:42
  • 1
    I doubt that this is a bug. More likely an unfortunate limitation. – barbara beeton Mar 5 at 17:49
9

Multi-paragraph items in a list

Look at this example

  1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae lectus urna. In scelerisque quam et urna varius elementum. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum quis turpis lectus. In vitae viverra dui. Vivamus libero massa, dictum vitae metus eu, porta viverra metus.

    Nam metus turpis, varius sed faucibus quis, vestibulum sed elit. Suspendisse accumsan augue eros. Nam eu justo sit amet purus iaculis bibendum quis quis arcu. Aliquam faucibus ex mi, eget dapibus augue placerat ut. Suspendisse nec purus sed turpis laoreet scelerisque non et neque.

  2. Morbi lacinia, tortor feugiat mattis sodales, urna odio porta sapien, id finibus purus purus volutpat leo. Vivamus venenatis, orci et ultricies vestibulum, nisi urna venenatis nisi, vel pellentesque tellus eros ut justo. Vestibulum dolor eros, mollis ullamcorper varius vel, aliquet et purus. Vestibulum non orci turpis.

with the following code

1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae
lectus urna. In scelerisque quam et urna varius elementum. Orci varius 
natoque penatibus et magnis dis parturient montes, nascetur ridiculus 
mus. Vestibulum quis turpis lectus. In vitae viverra dui. Vivamus 
libero massa, dictum vitae metus eu, porta viverra metus.

 Nam metus turpis, varius sed faucibus quis, vestibulum sed elit. 
Suspendisse accumsan augue eros. Nam eu justo sit amet purus iaculis 
bibendum quis quis arcu. Aliquam faucibus ex mi, eget dapibus augue 
placerat ut. Suspendisse nec purus sed turpis laoreet scelerisque non 
et neque.

2. Morbi lacinia, tortor feugiat mattis sodales, urna odio porta sapien, 
id finibus purus purus volutpat leo. Vivamus venenatis, orci et 
ultricies vestibulum, nisi urna venenatis nisi, vel pellentesque tellus 
eros ut justo. Vestibulum dolor eros, mollis ullamcorper varius vel, 
aliquet et purus. Vestibulum non orci turpis.

We can see that item 1 consists of 2 paragraphs, and this is normal, right?

There are no standard solution, but there are tricky ways

Now consider using

1.-one
2.-two



----\documentclass{article}

[the dashes are spaces]

Now that you haven't told the "enumerate" environment in Markdown that the list has now ended (the blank lines do nothing here — as far as I know, three blank lines are considered to be only one blank line by Markdown). Therefore, the code piece will be considered as a part of the list, in a multi-paragraph item. Now Markdown will count the number of spaces in front of the code. Four spaces are already for the list, therefore there are no spaces left for the code, which means your "code" will not be formatted as code. If you add another 4 spaces, you will get something like

  1. one

    hello world
    

That is the reason of the "bug". Now, how to solve it? You have to tell Markdown that the list has ended. The usual way is to use a paragraph of normal text

1. one

Loren lipsum

    hello world
  1. one

Loren lipsum

hello world

However, in your case, no normal paragraph will be added. Therefore, you have to add a \end{enumerate} in Markdown. Unfortunately, as you can read here1 or here2, there are no standard solutions. However, in the links I provided, there are some hacky solutions. You can add a HTML comment

<!-- -->

or a HTML tag which doesn't output anything visible

<b> </b>

or as Herr Professor Paulinho van Duck said in her article, we only need three characters

<!>

Now you have

1. one
2. two

<!-- Hello -->

    some code here
  1. one
  2. two

some code here

1 This question is answered by Jeff Atwood.
2 This question is answered by a moderator.

  • 3
    <!> is enough, see here: tug.org/TUGboat/tb39-3/tb123duck-format.pdf, page 180. – CarLaTeX Mar 5 at 18:26
  • @CarLaTeX Thanks! Added :) – user156344 Mar 6 at 4:50
  • 1
    Prof. van Duck says you're welcome :) – CarLaTeX Mar 6 at 6:56
  • @CarLaTeX Please send my thanks to her! – user156344 Mar 6 at 8:43
  • Prof. van Duck is a drake :) – CarLaTeX Mar 6 at 8:45

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