[markdown] How to indent a few lines in Markdown markup?

I want to write a few lines of text. They should be formatted normally except each line should start at the 6th column. I.e. I don't want the code block formatting rule to make this chunk of text look like code as I'll use other formatting like bold face, etc. How to do that in Markdown?

This question is related to markdown

The answer is


One of the problems with starting your line with non-breaking spaces is that if your line is long enough to wrap, then when it spills onto a second line the first character of the overflow line with start hard left instead of starting under the first character of the line above it.

If your system allows you to mix HTML in with your markdown, a cheep and cheerful way of getting an indent is like this:

<ul>
My indented text goes here, and it can be long and wrap if you like.
And you can have multiple lines if you want.
</ul>

Semantically within your HTML it is nonsense (a UL section without any LI items), but all browsers I have used just happily indent what's between those tags.


Okay, with a little HTML in your R code, I did the following code to generate pure text in R Markdown. The <h3 style="text-indent: 15em;"> indents the text 15 spaces. For the original question, change the 15 to 6.

## Option: Du Pont Ratio Concept - (ROE Decomposition)
### (Closed Quotes/Total Premium) = (Closed Quotes/Quotes Issued) X <br>
<h3 style="text-indent: 15em;">
 (Quotes Issued/Renewal Premium) X <br></h3>
<h3 style="text-indent: 15em;">
 (Renewal Premium/Total Premium)</h3>

So the resulting code gives my desired output format. I am using tabs for the Markdown document and was looking to line up the () text which worked.

r output


Please use hard (non-breaking) spaces

Why use another markup language? (I Agree with @c z above).
One goal of Markdown is to make the documents readable even in a plain text editor.

Same result two approaches

The code

Sample code
&nbsp;&nbsp;&nbsp;&nbsp;5th position in an really ugly code  
    5th position in a clear an readable code  
    Again using non-breaking spaces :)

The result

Sample code
    5th position in an really ugly code
    5th position in a clear an readable code
    Again using non-breaking spaces :)

The visual representation of a non-breaking space (or hard space) is usually a normal space " ", however, its Unicode representation is U+00A0.
The Unicode representation of the ordinary space is U+0020 (32 in the ASCII Table).
Thus, text processors may behave differently while the visual representation remains the same.

Insert a hard space

| OS        | Input method                      |
|===========| ==================================|
| macOS     | OPTION+SPACE (ALT+SPACE)          |
| Linux     | Compose Space Space or AltGr+Space|
| Windows   | Alt+0+1+6+0                       |

Some text editor use Ctrl+Shift+Space.

Issue

Some text editors can convert hard spaces to common spaces in copying and pasting operations, so be careful.


do tab, then the + sign, then space, then your content

So

* level one + level two tabbed


If you're working with bullet points, try this:

<ul>
  <li>Coffee</li>
  <li>Tea
    <ul>
      <li>Black tea</li>
      <li>Green tea</li>
    </ul>
  </li>
  <li>Milk</li>
</ul>

This is the method I use when styling markdown.


Use a no-break space directly   (not the same as !).

(You could insert HTML or some esoteric markdown code, but I can think of better reasons to break compatibility with standard markdown.)


For completeness, the deeper bulleted lists:

Nested deeper levels: ---- leave here an empty row * first level A item - no space in front the bullet character * second level Aa item - 1 space is enough * third level Aaa item - 5 spaces min * second level Ab item - 4 spaces possible too * first level B item

Nested deeper levels:

  • first level A item - no space in front the bullet character
    • second level Aa item - 1 space is enough
      • third level Aaa item - 5 spaces min
    • second level Ab item - 4 spaces possible too
  • first level B item

    Nested deeper levels:
     ...Skip a line and indent eight spaces. (as said in the editor-help, just on this page)
    * first level A item - no space in front the bullet character
     * second level Aa item - 1 space is enough
         * third level Aaa item - 5 spaces min
        * second level Ab item - 4 spaces possible too
    * first level B item
    
            And there
            could be even more
            such octets of spaces.
    

On gitlab.com a single en space (U+2002) followed by a single em space (U+2003) works decently.

Presumably other repetitions or combinations of not-exactly-accounted-for space characters would also suffice.


What about place a determined space in the start of paragraph using the math environment as like:

$\qquad$ My line of text ...

This works for me and hope work for you too.


This is an old thread, but I would have thought markdown's blockquotes ('> ') would be best for this:


For quoted/indented paragraphs this hack might work (depending on render engine):

| | | |
|-|-|-|
|  | _"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."_ | |
|

which renders as:

enter image description here


Check if you can use HTML with your markdown. Maybe this works out for you:

  • List entry one<br/>
    Indented line<br/>
    <br/>
    And some more..
  • Second entry
    • Subentry<br/>
      Hello there!

To answer MengLu and @lifebalance's questions in response to SColvin's answer (which I much prefer to the accepted answer for the control it provides), it seems as though you could just target a parent element of the lists when setting the display to none, adding a surrounding element if necessary. So if we suppose we're doing this for a table of contents, we can extend SColvin's answer:

HTML

<nav class="table-of-contents">
  this is a normal line of text
  * this is the first level of bullet points, made up of <space><space>*<space>
    * this is more indented, composed of <space><space><space><space>*<space>
</nav>

CSS

.table-of-contents ul {
  list-style-type: none;
}

As pointed out by @AlexDupuy in the comments, definition lists can be used for this.

This is not supported by all markdown processors, but is widely available: Markdown Guide - Definition Lists

Term 1
: definition 1
: definition 2

Term 2
: definition 1
: definition 2

Renders as (html):

<dl>
    <dt>Term 1</dt>
    <dd>definition 1</dd>
    <dd>definition 2</dd>
    <dt>Term 2</dt>
    <dd>definition 1</dd>
    <dd>definition 2</dd>
</dl>

Typically the DT is rendered in a heading-like format, and each DD is rendered as indented text beneath this.

If you don't want a heading/term, just use a non-breaking space in place of the definition term:

&nbsp;
: This is the text that I want indented.  All text on the same line as the preceding colon will be included in this definition.
: If you include a second definition you'll get a new line; potentially separated by a space. <br />Some inline HTML may be supported within this too, allowing you to create new lines without spaces.
: Support for other markdown syntax varies; e.g. we can add a bullet list, but each one's wrapped in a separate definition term, so the spacing may be out.
: - item 1
: - item 2
: - item 3

You can see this in action by copy-pasting the above examples to this site: Stack Edit Markdown Editor

Screenshot of DL rendering in Stack Edit


I would use &emsp; is a lot cleaner in my opinion.


Suprisingly nobody came up with the idea of just using a div with paddingyet, so here you go:

<div style="padding-left: 30px;">
My text
</div>

See if this ">" helps:

Line 1
> line 2 
>> line 3

If you really must use tabs, and you don't mind the grey background-color and padding, <pre> tags might work (if supported):

<pre>
This        That        And             This
That        This        And             That    
</pre>
This        That        And             This
That        This        And             That    

Another alternative is to use a markdown editor like StackEdit. It converts html (or text) into markdown in a WYSIWYG editor. You can create indents, titles, lists in the editor, and it will show you the corresponding text in markdown format. You can then save, publish, share, or download the file. You can access it on their website - no downloads required!


One way to do it is to use bullet points, which allows you specify multiple levels of indentation. Bullet points are inserted using multiples of two spaces, star, another space Eg.:

this is a normal line of text
  * this is the first level of bullet points, made up of <space><space>*<space>
    * this is more indented, composed of <space><space><space><space>*<space>

This method has the great advantage that it also makes sense when you view the raw text.

If you care about not seeing the bullet points themselves, you should (depending on where you're using markdown) to be able to add li {list-style-type: none;} to the css for the whole mark down area.


Some Markdown implementations seem to use the ~ character for indentation.