Skip to content

Instantly share code, notes, and snippets.

@cormacrelf
Created September 21, 2012 08:45
Show Gist options
  • Save cormacrelf/3760427 to your computer and use it in GitHub Desktop.
Save cormacrelf/3760427 to your computer and use it in GitHub Desktop.
Pandoc Markdown -> latex with syntax highlighting
\documentclass[]{article}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifxetex
\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\newcommand{\euro}{€}
\else
\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\newcommand{\euro}{€}
\else
\usepackage[utf8]{inputenc}
\usepackage{eurosym}
\fi
\fi
\usepackage{color}
\usepackage{fancyvrb}
\DefineShortVerb[commandchars=\\\{\}]{\|}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\newenvironment{Shaded}{}{}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
\newcommand{\RegionMarkerTok}[1]{{#1}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\NormalTok}[1]{{#1}}
\ifxetex
\usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
xetex,
colorlinks=true,
linkcolor=blue]{hyperref}
\else
\usepackage[unicode=true,
colorlinks=true,
linkcolor=blue]{hyperref}
\fi
\hypersetup{breaklinks=true, pdfborder={0 0 0}}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{0}
\EndDefineVerbatimEnvironment{Highlighting}
\begin{document}
\[x=25\sqrt{3}\]
\begin{Shaded}
\begin{Highlighting}
\NormalTok{puts }\StringTok{"string"} \NormalTok{+ }\DecValTok{56}\NormalTok{.hello(thing: }\DecValTok{true}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\[ m g h = \frac{1}{5} m v^2 + \frac{1}{5} m v^2 + heat \]
\end{document}
@jez
Copy link

jez commented Nov 2, 2015

Looks like \EndDefineVerbatimEnvironment{Highlighting} doesn't exist (or has been removed, I'm not sure).

@BaseMax
Copy link

BaseMax commented Jun 7, 2019

Looks like \EndDefineVerbatimEnvironment{Highlighting} doesn't exist (or has been removed, I'm not sure).

Undefined control sequence. \EndDefineVerbatimEnvironment
Missing \begin{document}. \EndDefineVerbatimEnvironment{H

I agree with you. @jez @cormacrelf

screenshot-latex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment