1
0
mirror of https://github.com/lise-henry/crowbook synced 2024-09-08 03:30:37 +02:00

Add tex.cover option

This commit is contained in:
Lizzie Crowdagger 2024-05-13 04:22:14 +02:00
parent fca4301b90
commit 5cbd8f85d0
6 changed files with 36 additions and 4 deletions

View File

@ -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)
-----------------------

View File

@ -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

View File

@ -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:

View File

@ -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"),

View File

@ -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());

View File

@ -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{<<cover_path>>}
\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}