[Tex/LaTex] Pandoc (md to pdf), code block with own line spacing

line-spacingpandocxetex

I've been rendering my PhD thesis with pandoc using this template. The text has line spacing of 1.5, however there are some code blocks within, that I have been writing with the following command:

```{.R .numberLines}
measurementInvariance(semModelMIMICraw, data = semWellComb, group = "caso",
                      estimator = "MLM")
```

It looks OK, but the line spacing of 1.5 is also respected within the block.

  • Are there any parameters that I could send within the curly brackets that could make the block have a line spacing smaller than the rest of the text. Like 1, for instance?

  • Or are there any other options to achieve this goal?

Best Answer

Something like this works for me:

```
{.R .numberLines basicstyle="\linespread{0.8}\normalsize"}
measurementInvariance(semModelMIMICraw, data = semWellComb, group = "caso",
                      estimator = "MLM")
```

Basically, since you're going to LaTeX, you can use any attributes from the listings package. Refer, also, to this post. Note that you'll probably have to replace \normalsize with the desired font setting for your code. I was not able to get this to work with JUST using basicstyle="\linespread{0.8}".