From 57dc61cf3e34d3acd054383842be40b974e2e2cf Mon Sep 17 00:00:00 2001 From: Marcin Koziej Date: Mon, 28 Nov 2011 15:35:09 +0100 Subject: [PATCH] wl style for XeLaTeX is now a class. Accepts several parameters affecting output pdf. --- librarian/pdf.py | 4 +- librarian/pdf/{wl.sty => wl.cls} | 85 +++++++++++++++++++++++++++++--- 2 files changed, 79 insertions(+), 10 deletions(-) rename librarian/pdf/{wl.sty => wl.cls} (75%) diff --git a/librarian/pdf.py b/librarian/pdf.py index 476fbee..b3725b4 100644 --- a/librarian/pdf.py +++ b/librarian/pdf.py @@ -152,7 +152,7 @@ def package_available(package, args='', verbose=False): fpath = os.path.join(tempdir, 'test.tex') f = open(fpath, 'w') f.write(r""" - \documentclass{book} + \documentclass{wl} \usepackage[%s]{%s} \begin{document} \end{document} @@ -245,7 +245,7 @@ def transform(provider, slug=None, file_path=None, shutil.copy(tex_path, save_tex) # LaTeX -> PDF - shutil.copy(get_resource('pdf/wl.sty'), temp) + shutil.copy(get_resource('pdf/wl.cls'), temp) shutil.copy(get_resource('res/wl-logo.png'), temp) cwd = os.getcwd() diff --git a/librarian/pdf/wl.sty b/librarian/pdf/wl.cls similarity index 75% rename from librarian/pdf/wl.sty rename to librarian/pdf/wl.cls index 28a23a5..415e14a 100644 --- a/librarian/pdf/wl.sty +++ b/librarian/pdf/wl.cls @@ -1,4 +1,63 @@ % -*- coding: utf-8 -*- +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{wl}[2011/11/28 wolnelektury.pl book style] + +% PDF customizations +% +% nofootnotes - disable generation of footnotes +% nothemes - disable generation of themes +% onehalfleading - leading of 1.5 (interlinia) +% doubleleading - double leading (interlinia) +% a4paper,... - paper size as required by LaTeX +% nowlfont - don't use customized WL font + +%\usepackage{setspace} + +\RequirePackage{type1cm} +\DeclareOption{13pt}{% +\AtEndOfClass{% +% font size definitions, similar to ones in /usr/share/texmf-texlive/tex/latex/base/ +\renewcommand\normalsize{% + \@setfontsize\normalsize{13pt}{14.5pt}% + \abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@ + \abovedisplayshortskip \z@ \@plus3\p@ + \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@ + \belowdisplayskip \abovedisplayskip + \let\@listi\@listI}\normalsize% +\renewcommand\footnotesize{% + \@setfontsize\footnotesize\@xpt\@xiipt + \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@ + \abovedisplayshortskip \z@ \@plus3\p@ + \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@ + \def\@listi{\leftmargin\leftmargini + \topsep 6\p@ \@plus2\p@ \@minus2\p@ + \parsep 3\p@ \@plus2\p@ \@minus\p@ + \itemsep \parsep}% + \belowdisplayskip \abovedisplayskip +}% +}% +} + +%% \DeclareOption{14pt}{\renewcommand{\normalsize}{\AtEndOfClass{\fontsize{14}{17}\selectfont}}} + +\DeclareOption{doubleleading}{\AtBeginDocument{\doublespacing}}%\setlength{\leading}{1em plus 0.5ex minus 0.2ex}} +\DeclareOption{onehalfleading}{\AtBeginDocument{\onehalfspacing}}%\setlength{\leading}{1em plus 0.5ex minus 0.2ex}} + +\newif\ifshowfootnotes \showfootnotestrue +\DeclareOption{nofootnotes}{\showfootnotesfalse} + +\newif\ifshowthemes \showthemestrue +\DeclareOption{nothemes}{\showthemesfalse} + +\newif\ifenablewlfont \enablewlfonttrue +\DeclareOption{nowlfont}{\enablewlfontfalse} + +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}} +\ProcessOptions\relax +\LoadClass[a4paper,oneside]{book} + + +\usepackage{trace} \usepackage[MeX]{polski} @@ -11,6 +70,7 @@ \usepackage{scalefnt} \usepackage[colorlinks=true,linkcolor=black,setpagesize=false,urlcolor=black,xetex]{hyperref} +\ifenablewlfont \setmainfont [ %ExternalLocation, UprightFont = JunicodeWL-Regular, @@ -34,7 +94,7 @@ LetterSpace=-1.0 \defaultfontfeatures{ SizeFeatures={ - {Size={-10}, FakeStretch=1.02, LetterSpace=2.0 }, + {Size={-10.5}, FakeStretch=1.02, LetterSpace=2.0 }, {Size={10.5-12}, FakeStretch=2.00, LetterSpace=0.0 }, {Size={12-}, FakeStretch=0.98, LetterSpace=-2.0 } } @@ -43,7 +103,7 @@ SizeFeatures={ \renewcommand{\textsc}[1]{% {\addfontfeature{ SizeFeatures={ - {Size={-10}, Scale=1.2, FakeStretch=1.02, LetterSpace=8.0 }, + {Size={-10.5}, Scale=1.2, FakeStretch=1.02, LetterSpace=8.0 }, {Size={10.5-12}, Scale=1.2, FakeStretch=1.02, LetterSpace=8.0 }, {Size={12-}, FakeStretch=1.0, LetterSpace=8.0 } }, @@ -51,8 +111,9 @@ Letters={SmallCaps,UppercaseSmallCaps} } #1} } +\fi% enablewlfont -%{\itshape JunicodeWL-Italic.ttf } +%{\Itshape JunicodeWL-Italic.ttf } %{\bfseries Junicode-Bold.ttf } %{\bfseries\itshape Junicode-BoldItalic.ttf } @@ -358,11 +419,17 @@ Letters={Uppercase} \hspace*{#1}#2% } - -\newcommand{\pa}[1]{\NoCaseChange{\footnote{#1 [przypis autorski]}}} -\newcommand{\pe}[1]{\NoCaseChange{\footnote{#1}}} -\newcommand{\pr}[1]{\NoCaseChange{\footnote{#1}}} -\newcommand{\pt}[1]{\NoCaseChange{\footnote{#1}}} +\ifshowfootnotes + \newcommand{\pa}[1]{\NoCaseChange{\footnote{#1 [przypis autorski]}}} + \newcommand{\pe}[1]{\NoCaseChange{\footnote{#1}}} + \newcommand{\pr}[1]{\NoCaseChange{\footnote{#1}}} + \newcommand{\pt}[1]{\NoCaseChange{\footnote{#1}}} +\else + \newcommand{\pa}[1]{} + \newcommand{\pe}[1]{} + \newcommand{\pr}[1]{} + \newcommand{\pt}[1]{} +\fi \newcommand{\mat}[1]{$#1$} @@ -401,6 +468,7 @@ Letters={Uppercase} } \newcommand{\motyw}[2][0]{% +\ifshowthemes \mbox{}% \marginpar{% \vspace{-8pt}% @@ -409,5 +477,6 @@ Letters={Uppercase} \footnotesize{\color{theme}{#2}}}% \vspace{\baselineskip}% }% +\fi } -- 2.20.1