Skip to content

Instantly share code, notes, and snippets.

@sofadesign
Created July 16, 2011 12:56
Show Gist options
  • Save sofadesign/1086335 to your computer and use it in GitHub Desktop.
Save sofadesign/1086335 to your computer and use it in GitHub Desktop.
Custom xetex template used with pandoc and md2pdf script https://gist.github.com/1086335
%!TEX encoding = UTF-8 encoding
$if(legacy-header)$
$legacy-header$
$else$
% \documentclass[$columns$,$fontsize$]{memoir}
% \documentclass[$columns$,$fontsize$]{article}
% \documentclass[$columns$,$fontsize$]{report}
\documentclass[$columns$,$fontsize$]{report}
\usepackage{amsmath}
\usepackage[$language$]{babel}
\usepackage{ifxetex}
\usepackage[$geometry$,paper=$paper$,hmargin=$hmargin$,vmargin=$vmargin$]{geometry}
\ifxetex
\XeTeXdefaultencoding utf-8
\usepackage{fontspec,xltxtra,xunicode}
% \defaultfontfeatures options must be set before \setmainfont http://groups.google.com/group/pandoc-discuss/browse_frm/thread/be16e14fc8d6f517/b34133f09b92f013?#b34133f09b92f013
\defaultfontfeatures{Scale=MatchLowercase}
\setmainfont[Mapping=tex-text]{$mainfont$}
\setsansfont[Mapping=tex-text]{$sansfont$}
% no Mapping=tex-text option to keep straight quotes instead of curly quotes
\setmonofont{$monofont$}
\else
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
\fi
$if(lhs)$
\usepackage{listings}
\lstnewenvironment{code}{\lstset{language=Ruby,basicstyle=\small\ttfamily}}{}
$endif$
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
$endif$
$if(verbatim-in-note)$
\usepackage{fancyvrb}
$endif$
$if(fancy-enums)$
\usepackage{enumerate}
$endif$
$if(tables)$
\usepackage{array}
% This is needed because raggedright in table elements redefines \\:
\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
\let\PBS=\PreserveBackslash
$endif$
$if(strikeout)$
\usepackage[normalem]{ulem}
$endif$
$if(subscript)$
\newcommand{\textsubscr}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}}
$endif$
$if(links)$
\usepackage[usenames,dvipsnames]{color}
\definecolor{orange}{RGB}{255,90,0}
\usepackage[breaklinks=true,unicode=true]{hyperref}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\hypersetup{colorlinks,%
citecolor=orange,%
filecolor=orange,%
linkcolor=orange,%
urlcolor=orange,%
pdftex}
}
$endif$
$if(url)$
\usepackage{url}
$endif$
$if(graphics)$
\usepackage{graphicx}
% We will generate all images so they have a width \maxwidth. This means
% that they will get their normal width if they fit onto the page, but
% are scaled down if they would overflow the margins.
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
\else\Gin@nat@width\fi}
\makeatother
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}
$endif$
$if(numbersections)$
$else$
\setcounter{secnumdepth}{0}
$endif$
$if(verbatim-in-note)$
\VerbatimFootnotes % allows verbatim text in footnotes
$endif$
$for(header-includes)$
$header-includes$
$endfor$
$if(title)$
\title{$title$}
$endif$
\author{$for(author)$$author$$sep$\\$endfor$}
$if(date)$
\date{$date$}
$endif$
\begin{document}
$if(title)$
\maketitle
$endif$
$if(toc)$
\tableofcontents
$endif$
$if(alignment)$
\begin{$alignment$}
$endif$
$body$
$if(alignment)$
\end{$alignment$}
$endif$
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment