Integrate with minted for source code highlighting

This commit is contained in:
Gergely Meszaros 2021-08-21 14:14:17 +02:00
parent 5377734a4b
commit 525f06716c
4 changed files with 66 additions and 2 deletions

View File

@ -9,4 +9,7 @@ jobs:
- name: Compile LaTeX document
uses: xu-cheng/latex-action@master
with:
root_file: thesis.tex
root_file: |
thesis.tex
minted-integration.tex
latexmk_shell_escape: true

View File

@ -426,7 +426,7 @@
breaklines=true,
breakatwhitespace=false,
float,
frame=linesc,
frame=lines,
captionpos=b
}
% Forráskód elnevezése
@ -531,3 +531,27 @@
\setcounter{page}{1}
}
% ------------------------------
\AtBeginDocument{
% If the minted package is loaded, then provide a default for the formatting,
% and set the labels for the listings
\@ifpackageloaded{minted}{
\setminted{
style=tango,
numbers=left,
stepnumber=1,
firstnumber=1,
numbersep=5pt,
showspaces=false,
showtabs=false,
tabsize=2,
breaklines=true,
frame=lines,
bgcolor=codebackg,
}
\SetupFloatingEnvironment{listing}{
name=\codelabel, % Forráskód elnevezése
listname=\lstcodelabel, % Forráskódjegyzék elnevezése
}
}
}

33
minted-integration.tex Normal file
View File

@ -0,0 +1,33 @@
\documentclass{elteikthesis}[2020/11/23]
\usepackage[newfloat]{minted}
\begin{document}
\documentlang{magyar}
\chapter{Minted forráskód}
\label{ch:chapter}
\begin{listing}[H]
\begin{minted}{cpp}
#include <stdio>
int main()
{
int c;
std::cout << "Hello World!" << std::endl;
std::cout << "Press any key to exit." << std::endl;
std::cin >> c;
return 0;
}
\end{minted}
\caption{Hello World in C++}
\end{listing}
\phantomsection
\addcontentsline{toc}{chapter}{\lstcodelabel}
\listoflistings
\end{document}

View File

@ -7,6 +7,10 @@
%final, % Teendők elrejtése / Set final to hide todos
]{elteikthesis}[2020/11/23]
% A minted csomag támogatva van forráskódok szedésére
% The minted package is also supported for source higlighting
%\usepackage[newfloat]{minted}
% Dolgozat metaadatai
% Document's metadata
\title{Dolgozat címe} % cím / title