How to indent text inside literal string?

Viewed 71

I would like to get literal output with a line break, and then an indentation, so that the result would look like this:

int write(const std::string sFileName, int iStep, float fStartTime,
          const std::string sInfoString, int iWhat

But when i use this

| ``int write(const std::string sFileName, int iStep, float fStartTime,
| ``          const std::string sInfoString, int iWhat,``

i get

int write(const std::string sFileName, int iStep, float fStartTime,
`` const std::string sInfoString, int iWhat,``

I also tried a unicode substitution for non-breaking space:

 .. |xx| unicode:: U+00A0

But this is not being substituted:

| ``int write(const std::string sFileName, int iStep, float fStartTime,
| ``|xx||xx||xx|const std::string sInfoString, int iWhat,``

results in

int write(const std::string sFileName, int iStep, float fStartTime,
|xx||xx||xx|const std::string sInfoString, int iWhat

How can achieve the indentation i want between the double back-quotes?

1 Answers

I would suggest using the code-block directive. Indentation will be rendered relative to the first line of code.

.. code-block:: c++

    int write(const std::string sFileName, int iStep, float fStartTime,
              const std::string sInfoString, int iWhat

Also I don't know what language you use, but you can substitute the proper lexer for mylang by looking it up on the Pygments lexers page.

Edit

Updated to use the lexer c++.

Related