Skip to content

Instantly share code, notes, and snippets.

@bsag
Created December 7, 2013 11:02
Show Gist options
  • Save bsag/7839815 to your computer and use it in GitHub Desktop.
Save bsag/7839815 to your computer and use it in GitHub Desktop.
A PDF/XeLaTeX export template for Texts (http://www.texts.io) for a simple article. No section numbering, no title page and plain layout. Put this file in ~/Library/Application Support/Texts. Restart Texts and when you choose `File > Export > Export PDF/Export XeLaTeX` the `Templates` drop down at the bottom of the file chooser should include th…
%% Simple article template
% No section numbering, no title page, plain layout
%
\documentclass[11pt,a4paper,oneside,final,article]{memoir}
\usepackage{polyglossia}
% change the language and variant for your own needs
\setdefaultlanguage[variant=british]{english}
% use standard math symbols
\usepackage{amssymb}
% for \text inside formulas and for \eqref
\usepackage{amsmath}
\usepackage[math-style=ISO]{unicode-math}
\usepackage[svgnames]{xcolor}
% you may not have these fonts on your system to customise this as required
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\newfontfeature{Microtype}{protrusion=default;expansion=default;}
\setmainfont[Microtype,Ligatures=TeX,Numbers=OldStyle]{Minion Pro}
\setsansfont[Microtype,Scale=MatchLowercase,Ligatures=TeX]{Myriad Pro}
\setmonofont[Microtype,Scale=MatchLowercase,Scale=0.9]{Courier New}
% set paragraph spacing
% no indent, one baseline between paragraphs
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
% % Set margins and page layout
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=3cm]{geometry}
% prevent overfull lines
\setlength{\emergencystretch}{3em}
% for \includegraphics
\usepackage{graphicx}
% for exact placement of figures
\usepackage{float}
% for footnotes in tables
\usepackage{longtable}
% for hyperlinks
\usepackage[colorlinks,urlcolor=DarkRed,filecolor=DarkRed,linkcolor=DarkRed,citecolor=black]{hyperref}
\usepackage[all]{hypcap}
\urlstyle{same}
%% Make the style for Chapters and sections
% Used kjh's styles as a starting point:
% https://github.com/kjhealy/latex-custom-kjh/blob/master/needs-memoir/memoir-article-styles.sty
\makechapterstyle{article-sans}{
\setsecheadstyle{\Large\sffamily\bfseries}
\setsubsecheadstyle{\large\sffamily\bfseries}
\setsubsubsecheadstyle{\normalsize\sffamily\itshape}
\renewcommand{\printchaptername}{}
\renewcommand{\chapternamenum}{}
\renewcommand{\chapnumfont}{\chaptitlefont}
\renewcommand{\printchapternum}{\chapnumfont \thechapter\space}
\renewcommand{\afterchapternum}{}
\renewcommand{\printchaptername}{\secheadstyle}
\renewcommand{\cftchapterfont}{\normalfont}
\renewcommand{\cftchapterpagefont}{\normalfont\sffamily}
\renewcommand{\cftchapterpresnum}{\sffamily}
%\renewcommand{\cftchapterleader}{}
%\renewcommand{\cftchapterafterpnum}{\cftparfillskip}
\captiontitlefont{\small}
%\settocdepth{chapter}
\setsecnumdepth{part}
\settocdepth{part}
\counterwithout{section}{chapter}
%% reduce skip after section heading
\setaftersecskip{1.7ex}
%% set name of bibliography to 'references'
%%\renewcommand{\bibname}{\mdseries\Large\sffamily References}
% Titlepage layout
\pretitle{\par\vskip 3em
\begin{center}\Huge\sffamily\bfseries\hrule\vskip 0.5em}
\posttitle{\end{center}\par\vskip 0.5em\hrule}
\preauthor{\begin{center}\Large\vskip 3em}
\postauthor{\end{center}}
\predate{\begin{center}\normalsize}
\postdate{\end{center}}
%% 'abstract' bigger skip from title
\addto\captionsamerican{\renewcommand*{\abstractname}{}}
\renewcommand{\abstractnamefont}{\normalfont\scriptsize}
\renewcommand{\abstracttextfont}{\normalfont\scriptsize}
\abstractrunin
}
% Make figures as wide as the margins
% Determine if the image is too wide for the page.
\makeatletter
\def\ScaleIfNeeded{%
\ifdim\Gin@nat@width>\linewidth
\linewidth
\else
\Gin@nat@width
\fi
}
\makeatother
% Resize figures that are too wide for the page.
\let\oldincludegraphics\includegraphics
\renewcommand\includegraphics[2][]{%
\oldincludegraphics[width=\ScaleIfNeeded]{#2}
}
% use the defined styles for page and chapter
\pagestyle{plain}
\chapterstyle{article-sans}
\tightlists
\begin{document}
$body$
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment