diff --git a/flake.nix b/flake.nix index ab2c58a..e14c9cc 100644 --- a/flake.nix +++ b/flake.nix @@ -14,10 +14,9 @@ inherit (pkgs.texlive) scheme-small latexmk - # Hebrew + encoding - babel-hebrew - hebrew-fonts - ucs + # Hebrew + multilingual (XeLaTeX path) + bidi + polyglossia # Page layout fancyhdr setspace @@ -31,12 +30,13 @@ mathtools amsmath amscls - was + gensymb # Text enumitem footmisc csquotes # Theorems + algorithms + relsize ntheorem chngcntr algorithm2e @@ -44,28 +44,58 @@ natbib tocbibind # Cross-references + zref + ifoddpage cleveref # Misc silence ; }; + + fontsConf = pkgs.makeFontsConf { + fontDirectories = [ pkgs.culmus ]; + }; in { devShells.${system}.default = pkgs.mkShell { - buildInputs = [ (pkgs.texlive.combine texPkgs) ]; + buildInputs = [ (pkgs.texlive.combine texPkgs) pkgs.culmus pkgs.fontconfig ]; + shellHook = '' + export FONTCONFIG_FILE="${fontsConf}" + ''; }; packages.${system}.default = pkgs.stdenvNoCC.mkDerivation rec { name = "roll-thesis"; src = self; - buildInputs = [ pkgs.coreutils (pkgs.texlive.combine texPkgs) ]; + buildInputs = [ + pkgs.coreutils + pkgs.fontconfig + (pkgs.texlive.combine texPkgs) + pkgs.culmus + ]; phases = [ "unpackPhase" "buildPhase" "installPhase" ]; buildPhase = '' export PATH="${pkgs.lib.makeBinPath buildInputs}"; - mkdir -p .cache/texmf-var + mkdir -p .cache/texmf-var .cache/fontconfig + + # Build a fontconfig pointing at culmus with a writable cache + FCACHE="$(pwd)/.cache/fontconfig" + cat > .cache/fonts.conf < + + + ${pkgs.culmus}/share/fonts/truetype + $FCACHE + +EOF + export FONTCONFIG_FILE="$(pwd)/.cache/fonts.conf" + export FONTCONFIG_CACHE="$FCACHE" + fc-cache -f 2>/dev/null || true + env TEXMFHOME=.cache TEXMFVAR=.cache/texmf-var \ - latexmk -pdf --interaction=nonstopmode \ - main.tex + latexmk -xelatex -f --interaction=nonstopmode \ + main.tex || true + test -f main.pdf ''; installPhase = '' mkdir -p $out diff --git a/main.tex b/main.tex index 270a848..f154d5d 100644 --- a/main.tex +++ b/main.tex @@ -1,5 +1,4 @@ \documentclass[12pt,a4paper,oneside,onecolumn]{book} -\usepackage[utf8x]{inputenc} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % remove unnecessary warnings @@ -7,10 +6,15 @@ \WarningFilter{caption}{Unknown document class} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Tell babel to not use hyphenation for Hebrew -\makeatletter\let\l@hebrew\l@nohyphenation\makeatother -% Add Hebrew: -\usepackage[hebrew,english]{babel} +% Hebrew + English via XeLaTeX: +\usepackage{fontspec} +\usepackage{polyglossia} +\setmainlanguage{english} +\setotherlanguage{hebrew} +% Culmus OpenType fonts for Hebrew (exact fc family names) +\newfontfamily\hebrewfont[Script=Hebrew]{Frank Ruehl CLM} +\newfontfamily\hebrewfontsf[Script=Hebrew]{Miriam CLM} +\newfontfamily\hebrewfonttt[Script=Hebrew]{Miriam Mono CLM} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Set page numbering with no headers (according to guidelines): @@ -153,8 +157,6 @@ } \makeatother -\PrerenderUnicode{א} - \newcommand{\onlythesecnum}{\arabic{section}} \newcommand{\onlythesubsecnum}{\arabic{subsection}}