Skip to content

Instantly share code, notes, and snippets.

@pjohansson
Created June 16, 2017 21:48
Show Gist options
  • Save pjohansson/5f0e1cd7e9c704de5bce604042698cfa to your computer and use it in GitHub Desktop.
Save pjohansson/5f0e1cd7e9c704de5bce604042698cfa to your computer and use it in GitHub Desktop.
Styling which (in a roundabout way) implements the Skolar (PE) typeface for XeLaTeX
\usepackage{mathspec}
\usepackage{adjustbox}
\setmainfont{Skolar PE TEST}
\setmathfont(Digits,Latin,Greek){Skolar PE TEST}
\setsansfont{Skolar Sans Latin}
%%%%%%%%%%%%%%%%%%%%%
% OpenType Features %
%%%%%%%%%%%%%%%%%%%%%
% Macro to set local OpenType Feature
\def\fontfeature#1#2{\addfontfeature{#1} #2}
% Small Caps (SMCP)
\newcommand{\smallcaps}[1]{\fontfeature{Letters=SmallCaps}{#1}}
% Superior and inferiors
% \sup and \inf are for text environments, \msup and \minf for math.
\renewcommand{\sup}[1]{\text{\fontfeature{VerticalPosition=Superior}{#1}}}
\newcommand{\msup}[1]{\text{\fontfeature{VerticalPosition=Numerator}{#1}}}
\renewcommand{\inf}[1]{\fontfeature{VerticalPosition=Inferior}{#1}}
\newcommand{\minf}[1]{\text{\fontfeature{VerticalPosition=ScientificInferior}{#1}}}
%%%%%%%%%%
% Macros %
%%%%%%%%%%
% Pad and use \textrm for an input.
\newcommand{\smallspacedrm}[1]{\, \textrm{#1} \,}
\newcommand{\midspacedrm}[1]{\: \textrm{#1} \:}
\newcommand{\largespacedrm}[1]{\; \textrm{#1} \;}
%%%%%%%%%%%%%%%%%%%%
% Common Operators %
%%%%%%%%%%%%%%%%%%%%
% Macro to relax a mathematics operator before redefining it.
\DeclareRobustCommand{\RenewOperator}[2]{
\let#1\relax
\DeclareMathOperator{#1}{#2}
}
\DeclareRobustCommand{\operatorspace}[1]{\textrm{#1}}
\RenewOperator{\add}{\operatorspace{+}}
\RenewOperator{\sub}{\operatorspace{−}}
\RenewOperator{\times}{\operatorspace{×}}
\RenewOperator{\div}{\operatorspace{÷}}
\DeclareRobustCommand{\slash}{\textrm{/}} % This is used in text, less spacing
\RenewOperator{\pm}{\operatorspace{±}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Equalities and inequalities %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareRobustCommand{\equalityspace}[1]{\, \textrm{#1} \,}
\RenewOperator{\eq}{\equalityspace{=}}
\RenewOperator{\neq}{\equalityspace{≠}}
\RenewOperator{\approx}{\equalityspace{≈}}
\RenewOperator{\sim}{\equalityspace{\~{}}}
\RenewOperator{\lt}{\equalityspace{<}}
\RenewOperator{\gt}{\equalityspace{>}}
\RenewOperator{\leq}{\equalityspace{≤}}
\RenewOperator{\geq}{\equalityspace{≥}}
\RenewOperator{\gg}{\equalityspace{»}}
\RenewOperator{\ll}{\equalityspace{«}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Parenthesis and brackets %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Regular sized
\DeclareRobustCommand{\lpar}{\text{(}}
\DeclareRobustCommand{\rpar}{\text{)}}
\DeclareRobustCommand{\lbra}{\text{[}}
\DeclareRobustCommand{\rbra}{\text{]}}
\DeclareRobustCommand{\lcur}{\text{\{}}
\DeclareRobustCommand{\rcur}{\text{\}}}
% Macros to create bigger sizes
%\newcommand{\setscale}[4]{\adjustbox{
%frame,
%scale={1}{#1},
%min height=#2pt,
%valign=T,
%raise={#3\Height},
%trim=0 0 {0.5\width} 0
%}{#4}
%}
\newcommand{\setscale}[4]{\adjustbox{
%frame,
scale={#2}{#1},
%min height=#2pt,
valign=c,
%raise={#3\Height},
trim=0 0 {0.5\width} 0
}{#4}
}
% These are the scales used
%\DeclareRobustCommand{\bigscale}[1]{\setscale{1.179}{8.5}{1.2}{#1}}
%\DeclareRobustCommand{\Bigscale}[1]{\setscale{1.536}{11.5}{1.3}{#1}}
%\DeclareRobustCommand{\biggscale}[1]{\setscale{1.893}{14.5}{1.3}{#1}}
%\DeclareRobustCommand{\Biggscale}[1]{\setscale{2.036}{17.5}{1.3}{#1}}
\DeclareRobustCommand{\bigscale}[1]{\setscale{1.13333}{1.1}{1.05}{#1}}
\DeclareRobustCommand{\Bigscale}[1]{\setscale{1.7}{1.2}{1.2}{#1}}
\DeclareRobustCommand{\biggscale}[1]{\setscale{2.30}{1.3}{1.3}{#1}}
\DeclareRobustCommand{\Biggscale}[1]{\setscale{2.8}{1.4}{1.3}{#1}}
\DeclareRobustCommand{\biglpar}{\text{\bigscale{(}}}
\DeclareRobustCommand{\Biglpar}{\text{\Bigscale{(}}}
\DeclareRobustCommand{\bigglpar}{\text{\biggscale{(}}}
\DeclareRobustCommand{\Bigglpar}{\text{\Biggscale{(}}}
\DeclareRobustCommand{\bigrpar}{\text{\bigscale{)}}}
\DeclareRobustCommand{\Bigrpar}{\text{\Bigscale{)}}}
\DeclareRobustCommand{\biggrpar}{\text{\biggscale{)}}}
\DeclareRobustCommand{\Biggrpar}{\text{\Biggscale{)}}}
\DeclareRobustCommand{\biglbra}{\text{\bigscale{[}}}
\DeclareRobustCommand{\Biglbra}{\text{\Bigscale{[}}}
\DeclareRobustCommand{\bigglbra}{\text{\biggscale{[}}}
\DeclareRobustCommand{\Bigglbra}{\text{\Biggscale{[}}}
\DeclareRobustCommand{\bigrbra}{\text{\bigscale{]}}}
\DeclareRobustCommand{\Bigrbra}{\text{\Bigscale{]}}}
\DeclareRobustCommand{\biggrbra}{\text{\biggscale{]}}}
\DeclareRobustCommand{\Biggrbra}{\text{\Biggscale{]}}}
\DeclareRobustCommand{\biglcur}{\text{\bigscale{\{}}}
\DeclareRobustCommand{\Biglcur}{\text{\Bigscale{\{}}}
\DeclareRobustCommand{\bigglcur}{\text{\biggscale{\{}}}
\DeclareRobustCommand{\Bigglcur}{\text{\Biggscale{\{}}}
\DeclareRobustCommand{\bigrcur}{\text{\bigscale{\}}}}
\DeclareRobustCommand{\Bigrcur}{\text{\Bigscale{\}}}}
\DeclareRobustCommand{\biggrcur}{\text{\biggscale{\}}}}
\DeclareRobustCommand{\Biggrcur}{\text{\Biggscale{\}}}}
% User macros
\newcommand{\parens}[1]{\lpar #1 \rpar}
\newcommand{\bigparens}[1]{\biglpar #1 \bigrpar}
\newcommand{\Bigparens}[1]{\Biglpar #1 \Bigrpar}
\newcommand{\biggparens}[1]{\bigglpar #1 \biggrpar}
\newcommand{\Biggparens}[1]{\Bigglpar #1 \Biggrpar}
\newcommand{\brackets}[1]{\lbra #1 \rbra}
\newcommand{\bigbrackets}[1]{\biglbra #1 \bigrbra}
\newcommand{\Bigbrackets}[1]{\Biglbra #1 \Bigrbra}
\newcommand{\biggbrackets}[1]{\bigglbra #1 \biggrbra}
\newcommand{\Biggbrackets}[1]{\Bigglbra #1 \Biggrbra}
\newcommand{\curly}[1]{\lcur #1 \rcur}
\newcommand{\bigcurly}[1]{\biglcur #1 \bigrcur}
\newcommand{\Bigcurly}[1]{\Biglcur #1 \Bigrcur}
\newcommand{\biggcurly}[1]{\bigglcur #1 \biggrcur}
\newcommand{\Biggcurly}[1]{\Bigglcur #1 \Biggrcur}
\RenewOperator{\mid}{\text{|}}
\DeclareRobustCommand{\langle}{
\text{
\adjustbox{scale={0.65}{2.3},valign=b,raise=0.1\height}{<}
}
}
\DeclareRobustCommand{\rangle}{
\text{
\adjustbox{scale={0.65}{2.3},valign=b,raise=0.05\height}{>}
}
}
%%%%%%%%%%%%%%%%%%%%%%
% Special characters %
%%%%%%%%%%%%%%%%%%%%%%
% Comma
\DeclareRobustCommand{\cm}{\text{,}\,}
% Partial derivative
\DeclareRobustCommand{\partial}{\text{∂}}
% Hyphen-minus (minus without the spacing)
\DeclareRobustCommand{\neg}{\text{−}}
% Infinity symbol
\DeclareRobustCommand{\infty}{\text{∞}}
% For all: reflect a sans serif `A` along the y axis.
\RenewOperator{\forall}{
\textrm{\setmainfont{Skolar Sans Latin}
\adjustbox{scale={1}{-1},valign=B,trim=0 0 {0.2\width} 0}{A}
}
}
% Exists: mirror and slightly stretch a sans serif `E`
\DeclareRobustCommand{\exists}{
\textrm{\setmainfont{Skolar Sans Latin}
\adjustbox{reflect,trim={0.2\width} 0 0 0,scale={1.1}{1}}{E}
}
}
% Sets
\RenewOperator{\in}{\text{є}}
\RenewOperator{\Re}{\textrm{Re}}
\RenewOperator{\Im}{\textrm{Im}}
% Daggers
\DeclareRobustCommand{\dagger}{\text{†}}
\DeclareRobustCommand{\ddagger}{\text{‡}}
%%%%%%%%%%%%%%%%%%
% Trigonometrics %
%%%%%%%%%%%%%%%%%%
\RenewOperator{\exp}{\textrm{exp}}
\RenewOperator{\cos}{\textrm{cos}}
\RenewOperator{\sin}{\textrm{sin}}
\RenewOperator{\tan}{\textrm{tan}}
\RenewOperator{\cot}{\textrm{cot}}
\RenewOperator{\cosh}{\textrm{cosh}}
\RenewOperator{\sinh}{\textrm{sinh}}
\RenewOperator{\tanh}{\textrm{tanh}}
\RenewOperator{\coth}{\textrm{coth}}
\RenewOperator{\arccos}{\textrm{arccos}}
\RenewOperator{\arcsin}{\textrm{arcsin}}
\RenewOperator{\arctan}{\textrm{arctan}}
\RenewOperator{\arccot}{\textrm{arccot}}
\RenewOperator{\sec}{\textrm{sec}}
\RenewOperator{\csc}{\textrm{csc}}
%%%%%%%%%%
% Arrows %
%%%%%%%%%%
\newcommand{\arrows}[1]{\text{\fontfeature{StylisticSet=6}{#1}}}
\RenewOperator{\leftarrow}{\arrows{<-}}
\RenewOperator{\rightarrow}{\arrows{->}}
\RenewOperator{\leftrightarrow}{\arrows{<->}}
\RenewOperator{\Leftarrow}{\arrows{<=}}
\RenewOperator{\Rightarrow}{\arrows{=>}}
\RenewOperator{\Leftrightarrow}{\arrows{<=>}}
\RenewOperator{\to}{\rightarrow}
\RenewOperator{\gets}{\leftarrow}
\RenewOperator{\iff}{\arrows{==>}}
\RenewOperator{\implies}{\Rightarrow}
\RenewOperator{\mapsto}{\rightarrow}
\RenewOperator{\uparrow}{\text{↑}}
\RenewOperator{\downarrow}{\text{↓}}
\RenewOperator{\updownarrow}{\text{⇅}}
\RenewOperator{\downuparrow}{\text{⇵}}
\RenewOperator{\forwardbackwardarrow}{\text{⇄}}
\RenewOperator{\backwardforwardarrow}{\text{⇆}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment