phd_thesis_markdown icon indicating copy to clipboard operation
phd_thesis_markdown copied to clipboard

how to change font size & line spacing of code blocks?

Open tobiasbueschel opened this issue 8 years ago • 1 comments

Hi,

Is there a possibility to change the font size and line spacing of code blocks when generating them through markdown?


Thanks & best, Tobias

tobiasbueschel avatar Sep 08 '16 06:09 tobiasbueschel

For the moment, one may also use LaTeX to generate code listings:

Add this to preamble.tex:
% CODE BLOCKS
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage{color}

\lstdefinestyle{inText}{
    language=c,
    basicstyle=\small\ttfamily,
    %   basicstyle=\linespread{0.8}\small\ttfamily,
    upquote=true,
    stepnumber=1,
    numbersep=8pt,
    showstringspaces=false,
    breaklines=true,
    frame=top,
    frame=bottom,
    aboveskip=1.5em,
    belowskip=1.5em,
    captionpos=b
}
Generate your code block using:
\begin{lstlisting}[style=mystyle, caption=text]
printf("hello, world");
\end{lstlisting}
Add all code listings to Table of Listings
  • create a new file called listings.md with the following code:
\addcontentsline{toc}{chapter}{Listings}
\lstlistoflistings
\newpage

tobiasbueschel avatar Sep 12 '16 21:09 tobiasbueschel