# Use structured template in numbered list

Is there any way to include a structured template (#+Begin/end_SRC) in the middle of a numbered list without ruining the numbering?

Here is a MWE:

1) First question

#+begin_quote
Quote needed for first question
#+end_quote

1) Second question


When I try to export it or update the numbering, the second question is assigned number 1.

Yes, that can be done: do not leave more than one empty line and indent the block properly:

* Questions

1) First question

#+begin_quote
Quote needed for first question
#+end_quote

1) Second question


You can insert the block properly indented by pressing TAB which should indent to the right place (under the F in "First question") and then C-c C-, q (q for quote, but any of the choices will do) to insert the template. After you insert the template, you can add the contents - pressing TAB at the end should indent the contents properly.

Or you can insert the contents properly indented (TAB should work - assuming that the option org-cycle-emulate-tag is set to t, the default - to get the ball rolling: after entering the first line at the right indentation, the rest should indent properly). Then mark the contents as a region and then do C-c C-, q to wrap the region inside the template.

Thanks to @Tobias for the kick to make me get it right (I think and hope it's right, but if there are problems, let me know).

• 1.) Note that single newlines do not break the item sequence but "wrong" indentation does. 2.) I think you missed the question a bit. The OP wants to know how one can insert a correctly indented block using structure templates. But, structure templates are not discussed at all in your answer. – Tobias Apr 27 '20 at 23:39
• @Tobias, I could have sworn that empty lines broke the sequence, so I didn't even test: now that I have, you are right (as usual). Re. 2) I expanded it quite a bit. – NickD Apr 28 '20 at 0:13

If you are using org-tempo you should first indent the line before inserting the template shortcut <q for the quote-block.

That means if you have the input

1. First question

|


where the bar | stands for the cursor position, type TAB to arrive at the indented position as shown in the following code:

1. First question

|


then input the structure template <q:

1. First question

<q|


Now, press TAB for template expansion and you get:

1. first

#+BEGIN_QUOTE
|
#+END_QUOTE


When you place the cursor behind #+END_QUOTE and press M-<RET> you get the next item with number 2:

1. first

#+BEGIN_QUOTE

#+END_QUOTE

2. |


That already indicates that the numbering is fine.

Note that I just corrected org-structtempl.el to obtain a similar behavior with that package.

(org-structtempl.el gives the old structure template behavior back in Org > 9.2 and adds some more features, e.g. expansion of LaTeX environments through key <m).