diff --git a/ChangeLog.md b/ChangeLog.md index d78c5ea..52c0b64 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -10,6 +10,8 @@ ChangeLog * Use rust-i18n for internationalization instead of hackish (and unmaintained) crowbook-intl * HTML: * When hovering a mouse hover a footnote, display its content to the side of the page. +* LaTeX: + * Add `tex.cover` option to embed the cover image in the PDF file 0.16.1 (2023-08-04) ----------------------- diff --git a/lang/lib/en.yml b/lang/lib/en.yml index 730b52c..23a001d 100644 --- a/lang/lib/en.yml +++ b/lang/lib/en.yml @@ -240,6 +240,7 @@ opt: tex_command: LaTeX command to use for generating PDF tex_tmpl: Path of a LaTeX template file tex_tmpl_add: Inline code added in the LaTeX template + tex_cover: "Add cover to the LaTeX/PDF file" tex_class: LaTeX class to use tex_title: If true, generate a title with \\maketitle tex_paper_size: Specifies the size of the page diff --git a/lang/lib/fr.yml b/lang/lib/fr.yml index 20b2b76..31977c5 100644 --- a/lang/lib/fr.yml +++ b/lang/lib/fr.yml @@ -6,11 +6,11 @@ ui: waiting: "en attente..." options: "mise en place des options" chapters: "Analyse des chapitres" - processing: Analyse... + processing: "Analyse..." processing_file: "Analyse de %{file} en cours..." finished: "Terminé" generated: "généré %{path}" - error: ERREUR + error: "ERREUR" error: markdown: "Erreur dans l'analyse du Markdown : %{error}" config: "Erreur dans l'analyse du fichier de configuration : " @@ -81,7 +81,7 @@ format: debug: yaml_replace: "Inline YAML block replaced %{key} previously set to %{old_val} to %{new_val}" yaml_set: "Inline YAML block set %{key} to %{value}" - yaml_ignore: "Ignoring YAML block:\n%{block}" + yaml_ignore: "Bloc YAML ignoré:\n%{block}" found_yaml_block: "Found something that looked like a YAML block:\n%{block}" found_yaml_block2: "... but it didn't parse correctly as YAML('%{error}'), so treating it like Markdown." msg: diff --git a/src/lib/bookoptions.rs b/src/lib/bookoptions.rs index 3115516..10a8cc4 100644 --- a/src/lib/bookoptions.rs +++ b/src/lib/bookoptions.rs @@ -101,6 +101,7 @@ epub.toc.extras:bool:true # {epub_toc} epub.escape_nb_spaces:bool:true # {nb_spaces} # {tex_opt} +tex.cover:bool:false # {tex_cover} tex.highlight.theme:str # {tex_theme} tex.links_as_footnotes:bool:true # {tex_links} tex.command:str:xelatex # {tex_command} @@ -291,6 +292,7 @@ output.odt:path # {removed} titlepage_xhtml = t!("opt.titlepage_xhtml"), epub_toc = t!("opt.epub_toc"), + tex_cover = t!("opt.tex_cover"), tex_links = t!("opt.tex_links"), tex_command = t!("opt.tex_command"), tex_tmpl = t!("opt.tex_tmpl"), diff --git a/src/lib/latex.rs b/src/lib/latex.rs index 83693d5..92fc5b9 100644 --- a/src/lib/latex.rs +++ b/src/lib/latex.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2020 Élisabeth HENRY. +// Copyright (C) 2016-2024 Élisabeth HENRY. // // This file is part of Crowbook. // @@ -228,6 +228,7 @@ impl<'a> LatexRenderer<'a> { data.insert("tex_title".into(), self.book.options.get_bool("tex.title").unwrap().into()); data.insert("papersize".into(), self.book.options.get_str("tex.paper.size").unwrap().into()); data.insert("stdpage".into(), self.book.options.get_bool("tex.stdpage").unwrap().into()); + data.insert("use_url".into(), self.book.features.url.into()); data.insert("use_taskitem".into(), self.book.features.taskitem.into()); data.insert("use_tables".into(), self.book.features.table.into()); @@ -237,6 +238,17 @@ impl<'a> LatexRenderer<'a> { data.insert("tex_lang".into(), tex_lang.into()); let tex_tmpl_add = self.book.options.get_str("tex.template.add").unwrap_or("".into()); data.insert("additional_code".into(), tex_tmpl_add.into()); + let mut use_cover = false; + if self.book.options.get_bool("tex.cover").unwrap() { + if let Ok(cover_path) = self.book.options.get_path("cover") { + if !cover_path.is_empty() { + use_cover = true; + data.insert("cover_path".into(), cover_path.into()); + } + } + } + data.insert("use_cover".into(), use_cover.into()); + if let Ok(tex_font_size) = self.book.options.get_i32("tex.font.size") { data.insert("has_tex_size".into(), true.into()); diff --git a/templates/latex/template.tex b/templates/latex/template.tex index d7af5fa..a809e4c 100644 --- a/templates/latex/template.tex +++ b/templates/latex/template.tex @@ -69,6 +69,16 @@ <# if book #> % Redefine the \maketitle command, only for book class (not used if stdpage option is set to true) \renewcommand{\maketitle}{ + <# if use_cover #> + % cover + \includepdf{<>} + \newpage + % Empty left page + \thispagestyle{empty} + \cleardoublepage + + <# endif #> + % First page with only the title \thispagestyle{empty} \vspace*{\stretch{1}} @@ -202,6 +212,11 @@ } <# endif #> +<# if use_cover #> +% Only included if tex.cover is set to true +\usepackage{pdfpages} +<# endif #> + <# if use_images #> % Only included if document contains images \usepackage{graphicx}