% \iffalse meta-comment % % Copyright (C) 2019-2023 by Jan Hajer % ----------------------------------- % % This file may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3c % of this license or (at your option) any later version. % The latest version of this license is in: % % http://www.latex-project.org/lppl.txt % % and version 1.3c or later is part of all distributions of LaTeX % version 2005/12/01 or later. % % \fi % % \iffalse % %\NeedsTeXFormat{LaTeX2e}[2005/12/01] %\ProvidesPackage{hep-font}[2024/11/01 v1.3 hep-font] %\ProvidesFile{hep-font-documentation.tex}[2024/11/01 v1.3 hep-font documentation] % %<*documentation> \documentclass{ltxdoc} \renewcommand\theCodelineNo{\rmfamily\tstyle\footnotesize\arabic{CodelineNo}} \AtBeginEnvironment{macrocode}{\renewcommand{\ttdefault}{clmt}} \renewcommand{\MacroFont}{\codestyle} \AtBeginDocument{\DeleteShortVerb{\|}} \AtBeginDocument{\MakeShortVerb{\"}} \EnableCrossrefs \CodelineIndex \RecordChanges \usepackage{hologo} \usepackage[parskip,oldstyle,font=10pt]{hep-paper} \bibliography{bibliography} \acronym{CM}{computer modern} \acronym{LM}{latin modern} \acronym{NFSS}{new font selection scheme} % %<*driver> \expandafter\newif\csname ifshort\endcsname \shortfalse \begin{document} \DocInput{hep-font-implementation.dtx} \end{document} % % % \fi % % \CheckSum{501} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z % Digits \0\1\2\3\4\5\6\7\8\9 % Exclamation \! Double quote \" Hash (number) \# % Dollar \$ Percent \% Ampersand \& % Acute accent \' Left paren \( Right paren \) % Asterisk \* Plus \+ Comma \, % Minus \- Point \. Solidus \/ % Colon \: Semicolon \; Less than \< % Equals \= Greater than \> Question mark \? % Commercial at \@ Left bracket \[ Backslash \\ % Right bracket \] Circumflex \^ Underscore \_ % Grave accent \` Left brace \{ Vertical bar \| % Right brace \} Tilde \~} % % \changes{v1.0}{2021/09/01}{Initial version of the style file.} % \changes{v1.1}{2022/11/01}{Bug fixes.} % \changes{v1.2}{2023/07/01}{Bug fixes.} % \changes{v1.3}{2024/11/01}{Bug fixes.} % % \ifshort %<*documentation> % \fi % \GetFileInfo{hep-font.sty} \title{The \software{hep-font} package\thanks{This document corresponds to \software{hep-font}~\fileversion.}} \subtitle{Latin modern extended by computer modern} \author{Jan Hajer \email{jan.hajer@tecnico.ulisboa.pt}} \date{\filedate} % \ifshort \begin{document} % \fi \newgeometry{vscale=.8, vmarginratio=3:4, includeheadfoot, left=11em, marginparwidth=4.6cm, marginparsep=3mm, right=7em} \maketitle \begin{abstract} The \software{hep-font} package loads standard font packages and extends the usual \glsdesc{LM} implementations by replacing missing fonts with \glsdesc{CM} counterparts. \end{abstract} The package is loaded using "\usepackage{hep-font}". \DescribeMacro{size} The "size="\meta{size} option loads the specified font size. The possible \meta{sizes} are: "8pt", "9pt", "10pt", "11pt", "12pt", "14pt", "17pt", "20pt" and "default" deactivates this switch. The default value is \unit[11]{pt}. \DescribeMacro{sans} The "sans" option switches to sans-serif font instead of serif font. \DescribeMacro{oldstyle} The "oldstyle" option switches to oldstyle numerals such as 123 in text mode instead of lining numerals such as \textl{123}. The \software{fontenc} package \cite{fontenc} with "T1" and "TU" font encoding is loaded for \hologo{pdfTeX} and \hologo{LuaTeX}, respectively. Some restrictions of \CM fonts are lifted with the \software{fixcm} package \cite{fix-cm}. The \software{microtype} \cite{microtype} optimizations are activated. The \hologo{LaTeX} \NFSS is extended with the \software{nfssext-cfr} package \cite{nfssext-cfr}. The \LM font is loaded using the \software{cfr-lm} \cite{cfr-lm} and \software{lmodern} \cite{lmodern} packages for \hologo{pdfTeX} and \hologo{LuaTeX}, respectively. The text companion fonts are loaded \cite{textcomp}. \DescribeMacro{\textsc} Bold \textbf{\textsc{Small Caps}} and a sans serif \textsf{\textsc{Small Caps}} based on the \CM font \cite{cm} is provided, the latter using the \software{sansmathfonts} \cite{sansmathfonts} and \software{hfoldsty} \cite{hfoldsty} packages. \DescribeMacro{\textui} A sans-serif upright italic font is provided using the \software{sansmathfonts} package \cite{sansmathfonts}. Finally the \software{inputenc} package \cite{inputenc} with the "utf8" option is loaded. % \ifshort \printbibliography \end{document} % % % \fi % % \StopEventually{ % \printbibliography % \PrintChanges % } % % \appendix % % \section{Implementation} % %<*package> % % Define a hepfont namespace for the options using the \software{kvoptions} package \cite{kvoptions}. % \begin{macrocode} \RequirePackage{kvoptions} \SetupKeyvalOptions{ family=hepfont, prefix=hepfont@ } % \end{macrocode} % % \begin{macro}{size} % Define the "size" option switching taking the font size as an argument. % \begin{macrocode} \DeclareStringOption[11pt]{size} % \end{macrocode} % \end{macro} % % \begin{macro}{sans} % Define the "sans" option switching to sans serif font. % \begin{macrocode} \DeclareBoolOption[false]{sans} \DeclareComplementaryOption{serif}{sans} % \end{macrocode} % \end{macro} % % \begin{macro}{lining} % Define the "lining" option deactivating the use of text figures in text mode. % \begin{macrocode} \DeclareBoolOption[true]{lining} \DeclareComplementaryOption{oldstyle}{lining} % \end{macrocode} % \end{macro} % % Process options. % \begin{macrocode} \ProcessKeyvalOptions* % \end{macrocode} % % Read font argument from class call. % \begin{macrocode} \def\hepfont@get@class#1.cls#2\relax{\def\hepfont@class{#1}} \def\hepfont@getclass{\expandafter\hepfont@get@class\@filelist\relax} \hepfont@getclass \@ifclasswith{\hepfont@class}{10pt}{\setkeys{hepfont}{size=10pt}}{} \@ifclasswith{\hepfont@class}{11pt}{\setkeys{hepfont}{size=11pt}}{} \@ifclasswith{\hepfont@class}{12pt}{\setkeys{hepfont}{size=12pt}}{} \@ifpackageloaded{jheppub}{\setkeys{hepfont}{size=default}}{} % \end{macrocode} % % \begin{macro}{\ifxetexorluatex} % Load the \software{ifluatex} \cite{ifluatex} and \software{ifxetex} \cite{ifxetex} packages. % Define the "\ifxetexorluatex" conditional checking if the package is executed by \hologo{LuaLaTeX} or \hologo{XeLaTeX}. % \begin{macrocode} \RequirePackage{ifluatex} \RequirePackage{ifxetex} \newif\ifxetexorluatex \ifxetex\xetexorluatextrue \else\ifluatex\xetexorluatextrue \else\xetexorluatexfalse\fi \fi % \end{macrocode} % \end{macro} % % Pick the correct font encoding depending on the engine used and load the \software{fontenc} package \cite{fontenc} with this encoding. % For details of the font encoding see \cite{encguide}. % \begin{macrocode} \def\hepfont@encoding{T\ifxetexorluatex U\else 1\fi} \PassOptionsToPackage{\hepfont@encoding}{fontenc} \RequirePackage{fontenc} % \end{macrocode} % Switch document to sans-serif font if requested using the \software{pdftexcmds} package \cite{pdftexcmds}. % \begin{macrocode} \RequirePackage{pdftexcmds} \ifnum\pdf@strcmp{\hepfont@size}{default}=0\else \def\hepfont@remove@pt#1pt{#1} \edef\hepfont@pt@size{\expandafter\hepfont@remove@pt\hepfont@size} \let\small\relax \let\footnotesize\relax \let\scriptsize\relax \let\tiny\relax \let\large\relax \let\Large\relax \let\LARGE\relax \let\huge\relax \let\Huge\relax \input{size\hepfont@pt@size.clo} \fi % \end{macrocode} % Switch document to sans-serif font if requested. % \begin{macrocode} \ifhepfont@sans \renewcommand{\familydefault}{\sfdefault} \fi % \end{macrocode} % Fix the remaining \CM \cite{cm} fonts using the \software{fix-cm} package \cite{fix-cm} and load the \software{microtype} font optimizations \cite{microtype}. % \begin{macrocode} \RequirePackage{fix-cm} \RequirePackage{microtype} % \end{macrocode} % Switch to the \LM font using the \software{cfr-lm} \cite{cfr-lm} or \software{lmodern} \cite{lmodern} packages depending on the \hologo{TeX} engine. % In both cases the \NFSS is extended using the \software{nfssext-cfr} \cite{nfssext-cfr} package. % \begin{macrocode} \ifxetexorluatex \RequirePackage{nfssext-cfr} \RequirePackage{lmodern} \else \ifhepfont@lining \PassOptionsToPackage{rm={lining},sf={lining},tt={lining}}{cfr-lm} \fi \RequirePackage{cfr-lm} \fi % \end{macrocode} % Ensure that the table of contest uses tabular figures using the \software{xpatch} package \cite{xpatch}. % \begin{macrocode} \RequirePackage{xpatch} \xpretocmd{\@dottedtocline}{\tstyle}{}{} \xpatchcmd{\@dottedtocline}{\normalfont}{\normalfont\tstyle}{}{} \xpretocmd{\l@section}{\tstyle}{}{} \xpretocmd{\l@chapter}{\tstyle}{}{} \xpretocmd{\l@part}{\tstyle}{}{} % \end{macrocode} % Ensure that the "verbatim" environment uses proportional font and provide an inline "\code" macro. % Work around a bug in \software{nfssext-cfr} which defines a global "\set" macro and breaks other macros of the same name. % \begin{macrocode} \newcommand{\codestyle}{\tmstyle\lstyle} \let\verbatim@font\codestyle \RequirePackage{xparse} \ProvideDocumentCommand{\code}{v}{{\codestyle #1}} % \end{macrocode} % Adjust the figures according to the "lining" option and ensure that tables always use lining. % \begin{macrocode} \g@addto@macro\@floatboxreset{\tlstyle} % \g@addto@macro\@subfloatboxreset{\tlstyle} % \end{macrocode} % Adjust the equation such that the number is always table style. % \begin{macrocode} \pretocmd{\theequation}{\tstyle}{}{} % \end{macrocode} % % Load the \software{textcomp} extension \cite{textcomp} and define helper functions. % \begin{macrocode} \RequirePackage{textcomp} \newcommand{\hepfont@sf@shape}[3]{% \DeclareFontShape{\hepfont@encoding}{\sfdefault}{#1}{#2}{#3}{}% } \newcommand{\hepfont@rm@shape}[3]{% \DeclareFontShape{\hepfont@encoding}{\rmdefault}{#1}{#2}{#3}{}% } % \end{macrocode} % % For modern \hologo{TeX} engines define the bold and sans serif small caps font shapes using the \software{fontspec} package \cite{fontspec}. % \begin{macrocode} \ifxetexorluatex \RequirePackage{fontspec} \setmainfont{Latin Modern Roman}[ UprightFeatures={SmallCapsFont={[lmromancaps10-regular.otf]}}, BoldFeatures={ SmallCapsFeatures={Letters=SmallCaps}, SmallCapsFont={[cmunbx.otf]} } ] \hepfont@sf@shape{bx}{sc}{<->cmssbxcsc10}{} \hepfont@sf@shape{b}{sc}{<->cmssbxcsc10}{} \hepfont@sf@shape{m}{scit}{<->cmsscsci10}{} \hepfont@sf@shape{m}{sc}{% <-9>cmsscsc8<9-10>cmsscsc9<10->cmsscsc10% }{} % \end{macrocode} %If \hologo{pdfLaTeX} % \begin{macrocode} \else % \end{macrocode} %For serif fonts % \begin{macrocode} \rmfamily % \end{macrocode} %\begin{macro}{\textsc} %For lining numerals add \CM roman small caps (italic and bold) from the \software{slantsc} package \cite{slantsc}. % \begin{macrocode} \ifhepfont@lining \RequirePackage{slantsc} \hepfont@rm@shape{b}{sc}{<->ssub*cmr/bx/sc}{} \hepfont@rm@shape{bx}{sc}{<->ssub*cmr/bx/sc}{} \hepfont@rm@shape{b}{scsl}{<->ssub*cmr/bx/scsl}{} \hepfont@rm@shape{bx}{scsl}{<->ssub*cmr/bx/scit}{} \hepfont@rm@shape{b}{scit}{<->ssub*cmr/bx/scsl}{} \hepfont@rm@shape{bx}{scit}{<->ssub*cmr/bx/scit}{} % \end{macrocode} %\end{macro} %\begin{macro}{\textsc} %For oldstyle numerals use the fonts from the \software{hfoldsty} package \cite{hfoldsty}. % \begin{macrocode} \else \DeclareFontFamily{\hepfont@encoding}{hfor}{} \DeclareFontShape{\hepfont@encoding}{hfor}{bx}{sc}{ <-6>hfoxc0500<6-7>hfoxc0600<7-8>hfoxc0700<8-9>hfoxc0800 <9-10>hfoxc0900<10-12>hfoxc1000<12-17>hfoxc1200<17->hfoxc1728 }{} \DeclareFontShape{\hepfont@encoding}{hfor}{bx}{scsl}{ <-6>hfooc0500<6-7>hfooc0600<7-8>hfooc0700<8-9>hfooc0800 <9-10>hfooc0900<10-12>hfooc1000<12-17>hfooc1200<17->hfooc1728 }{} \hepfont@rm@shape{b}{sc}{<->ssub*hfor/bx/sc}{} \hepfont@rm@shape{bx}{sc}{<->ssub*hfor/bx/sc}{} \hepfont@rm@shape{bx}{scsl}{<->ssub*hfor/bx/scsl}{} \hepfont@rm@shape{b}{scit}{<->ssub*hfor/bx/scsl}{} \hepfont@rm@shape{bx}{scit}{<->ssub*hfor/bx/scsl}{} \hepfont@rm@shape{b}{scsl}{<->ssub*hfor/bx/scsl}{} \fi % \end{macrocode} %\end{macro} %\begin{macro}{\textsc} %Provide the sans serif small caps font shape using the extended \CM from the \software{sansmathfonts} package \cite{sansmathfonts}. % \begin{macrocode} \sffamily \hepfont@sf@shape{m}{sc}{<->ssub*xcmss/m/sc}{} \hepfont@sf@shape{b}{sc}{<->ssub*xcmss/bx/sc}{} \hepfont@sf@shape{bx}{sc}{<->ssub*xcmss/bx/sc}{} \hepfont@sf@shape{m}{scit}{<->ssub*xcmss/m/scit}{} \hepfont@sf@shape{b}{scit}{<->ssub*xcmss/bx/scit}{} \hepfont@sf@shape{bx}{scit}{<->ssub*xcmss/bx/scit}{} \hepfont@sf@shape{m}{scsl}{<->ssub*xcmss/m/scit}{} \hepfont@sf@shape{b}{scsl}{<->ssub*xcmss/bx/scit}{} \hepfont@sf@shape{bx}{scsl}{<->ssub*xcmss/bx/scit}{} % \end{macrocode} %\end{macro} %\begin{macro}{\textui} %Provide a sans upright italic font. % \begin{macrocode} \hepfont@sf@shape{m}{ui}{<->cmssu10}{} \fi % \end{macrocode} %\end{macro} % % Load the \software{inputenc} package \cite{inputenc} whe using \hologo{pdfLaTeX}. % \begin{macrocode} \ifxetexorluatex\else \PassOptionsToPackage{utf8}{inputenc} \RequirePackage{inputenc} \fi % \end{macrocode} % % \begin{macro}{\unit} % Patch the "\unit" and "\unitfrac" macros to work with lining numerals using the \software{xpatch} package \cite{xpatch} if the \software{units} package \cite{units} is loaded. % TODO implement patch without actually loading the package. % \begin{macrocode} \ifhepfont@lining\else % \AtBeginDocument{ % \@ifpackageloaded{units}{ \RequirePackage{units} \RequirePackage{xpatch} \xpatchcmd{\unit}{\else#1}{% \else\ifthenelse{\boolean{mmode}}{#1}{\textl{#1}}% }{}{} \xpatchcmd{\unitfrac}{\else#1}{% \else\ifthenelse{\boolean{mmode}}{#1}{\textl{#1}}% }{}{} % }{} % } \fi % \end{macrocode} % \end{macro} % % % % \section{Test} % %<*test> % % \begin{macrocode} \documentclass[a4paper]{article} \usepackage[oldstyle]{hep-font} %% \usepackage[oldstyle]{hep-paper} \usepackage[cm]{fullpage} \usepackage{fancyvrb}\DefineShortVerb{\|} \newenvironment{vrb}{\begin{tabular}{@{}p{5.4cm}ll@{}}}{\end{tabular}} \begin{document} \subsection*{Roman} \rmfamily \begin{vrb} |\rmfamily| & {Latin Modern Roman 123} \\ | \sbweight| & {\sbweight Latin Modern Roman Semi Bold 123} \\ | \bfseries| & {\bfseries Latin Modern Roman Bold Extended 123} \\ |\slshape| & {\slshape Latin Modern Roman Oblique 123} \\ | \sbweight| & {\sbweight\slshape Latin Modern Roman Semi Bold Oblique 123} \\ | \bfseries| & {\bfseries\slshape Latin Modern Roman Bold Oblique Extended 123} \\ |\itshape| & {\itshape Latin Modern Roman Italic 123} \\ | \bfseries| & {\bfseries\itshape Latin Modern Roman Bold Italic Extended 123} \\ |\uishape| & {\uishape Latin Modern Roman Upright Italic 123} \\ |\scshape| & {\scshape Latin Modern Roman Small Caps 123} \\ | \bfseries| & {\bfseries\scshape Computer Modern Roman Bold Small Caps 123} \\ | \sishape| & {\scshape\slshape Latin Modern Roman Oblique Small Caps 123} \\ | \bfseries| & {\slshape\bfseries\scshape Computer Modern Roman Bold Small Caps 123} \\ \end{vrb} \subsubsection*{Dunhill} \tistyle \begin{vrb} |\tistyle | & {Latin Modern Dunhill 123} \\ | \slshape| & {\slshape Latin Modern Dunhill Oblique 123} \\ \end{vrb} \subsubsection*{Funny} \fontfamily{cmfr}\selectfont \begin{vrb} |\fontfamily{cmfr}\selectfont | & {Computer Modern Funny 123} \\ | \itshape| & {\itshape Computer Modern Funny Oblique 123} \\ \end{vrb} \subsubsection*{Fib} \fontfamily{cmfib}\selectfont \begin{vrb} |\fontfamily{cmfib}\selectfont | & {Computer Modern Fibonacci 123} \\ | \slshape| & {\slshape Computer Modern Fibonacci Oblique 123} \\ \end{vrb} \subsection*{Sans} \sffamily \begin{vrb} |\sffamily| & {Latin Modern Sans 123} \\ | \fontseries{sbc}\selectfont| & {\fontseries{sbc}\selectfont Latin Modern Sans Demi Condensed 123} \\ | \bfseries| & {\bfseries Latin Modern Sans Bold 123} \\ |\slshape| & {\slshape Latin Modern Sans Oblique 123} \\ | \fontseries{sbc}\selectfont| & {\fontseries{sbc}\selectfont\slshape Latin Modern Sans Demi Condensed Oblique 123} \\ | \bfseries| & {\bfseries\slshape Latin Modern Sans Bold Oblique 123} \\ |\uishape| & {\uishape Computer Modern Sans Upright Italic 123} \\ |\scshape| & {\scshape Computer Modern Sans Small Caps 123} \\ | \bfseries| & {\bfseries\scshape Computer Modern Sans Bold Small Caps 123} \\ | \itshape| & {\itshape\scshape Computer Modern Sans Italic Small Caps 123} \\ | \bfseries| & {\itshape\bfseries\scshape Computer Modern Sans Italic Bold Small Caps 123} \\ \end{vrb} \subsubsection*{Quotation} \qtstyle \begin{vrb} |\qtstyle | & {Latin Modern Sans Extended 123} \\ | \bfseries | & {\bfseries Latin Modern Sans Bold Extended 123} \\ |\slshape | & {\slshape Latin Modern Sans Extended Oblique 123} \\ | \bfseries | & {\bfseries\slshape Latin Modern Sans Bold Extended Oblique 123} \\ \end{vrb} \subsection*{Typewriter} \ttfamily \tvstyle \begin{vrb} |\ttfamily\tvstyle | & {Latin Modern Typewriter Proportional 123} \\ | \bfseries | & {\bfseries Latin Modern Typewriter Proportional Dark 123} \\ | \lgweight | & {\lgweight Latin Modern Typewriter Proportional Light 123} \\ |\slshape | & {\slshape Latin Modern Typewriter Proportional Oblique 123} \\ | \bfseries | & {\bfseries\slshape Latin Modern Typewriter Proportional Dark Oblique 123} \\ | \lgweight | & {\lgweight Latin Modern Typewriter Proportional Light Oblique 123} \\ \end{vrb} \subsubsection*{Fixed-width} \tmstyle \begin{vrb} |\ttfamily\tmstyle | & {Latin Modern Typewriter 123} \\ | \lgweight | & {\lgweight Latin Modern Typewriter Light 123} \\ | \bfseries | & {\bfseries Latin Modern Typewriter Dark 123} \\ | \fontseries{lc}\selectfont | & {\fontseries{lc}\selectfont Latin Modern Typewriter Light Condensed 123} \\ |\slshape | & {\slshape Latin Modern Typewriter Oblique 123} \\ | \lgweight | & {\lgweight\slshape Latin Modern Typewriter Light Oblique 123} \\ | \bfseries | & {\bfseries\slshape Latin Modern Typewriter Dark Oblique 123} \\ | \fontseries{lc} | & {\fontseries{lc}\slshape Latin Modern Typewriter Light Condensed Oblique 123} \\ |\itshape | & {\itshape Latin Modern Typewriter Italic 123} \\ |\scshape | & {\scshape Latin Modern Typewriter Small Caps 123} \\ | \slshape | & {\scshape\slshape Latin Modern Typewriter Oblique Small Caps 123} \\ \end{vrb} \end{document} % \end{macrocode} % % % % \section{Readme} % %<*readme> % % \begin{macrocode} # The `hep-font` package Latin modern extended by computer modern. ## Introduction The `hep-font` package loads standard font packages and extends the usual Latin Modern implementations by replacing missing fonts with Computer Modern counterparts. The package is loaded with `\usepackage{hep-font}`. ## Author Jan Hajer ## License This file may be distributed and/or modified under the conditions of the `LaTeX` Project Public License, either version 1.3c of this license or (at your option) any later version. The latest version of this license is in `http://www.latex-project.org/lppl.txt` and version 1.3c or later is part of all distributions of LaTeX version 2005/12/01 or later. % \end{macrocode} % % % % \Finale \endinput % \PrintIndex % makeindex -s gglo.ist -o hep-font-implementation.gls hep-font-implementation.glo % makeindex -s gglo.ist -o hep-font-implementation.ind hep-font-implementation.idx