From d97654d95b269eb9f6de8105e2eb01ca5566ae14 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Fri, 10 May 2024 20:52:40 +0200 Subject: New customisation properties in the Makefile --- common/Makefile.common | 23 +++++++++++--- model_7/Makefile | 2 ++ model_7/resources/00_preamble.tex | 6 ++-- model_7/resources/10_decoration.tex | 2 +- model_7/resources/99_begin.tex | 3 +- model_7/resources/modules | 11 ++----- readme.rst | 61 +++++++++++++++++++++++++++++++++++++ 7 files changed, 88 insertions(+), 20 deletions(-) diff --git a/common/Makefile.common b/common/Makefile.common index 460bdc7..311db70 100644 --- a/common/Makefile.common +++ b/common/Makefile.common @@ -13,7 +13,11 @@ all: $(PDFS) BIBS =$(wildcard *.bib) DIR = $(sort $(shell find $(SOURCE) -name '*.rst' -print)) -SOURCES := $(sort $(wildcard $(MODEL)/resources/*.tex) ) +SOURCES = $(sort $(filter-out $(FILTERS), $(wildcard $(MODEL)/resources/*.tex) )) + +# Sources comming from extra styles. +# Used in the target regeneration. +EXT_SOURCES = $(filter %.tex, $(EXTRA_STYLES) ) null := space := $(null) # @@ -35,8 +39,12 @@ PACKAGES = $(subst $(space),$(comma),$(strip $(PACK))) tmp: mkdir tmp +# Hack used to identify the path to the shared configuration in latex. +tmp/model.tex: | tmp + $(file >$@,\def\commonPath{$(MODEL)/../common/}) + # Generate the latex file from rst -tmp/%.tex: %.rst $(INCLUDED_PDF) $(SOURCES)| tmp +tmp/%.tex: %.rst $(INCLUDED_PDF) $(SOURCES) $(EXT_SOURCES) | tmp $$(command -v rst2latex rst2latex.py | head -n 1) \ --no-section-subtitles \ --table-style=borderless \ @@ -46,15 +54,18 @@ tmp/%.tex: %.rst $(INCLUDED_PDF) $(SOURCES)| tmp --documentoption=12pt,A4,table \ --syntax-highlight=short \ $(EXTRA_RST_OPTIONS) \ - --stylesheet=$(PACKAGES),$(EXTRA_STYLES),$(TEX_STYLE) $< $@ + --stylesheet=tmp/model.tex,$(PACKAGES),$(subst $(space),$(comma),\$(EXTRA_STYLES)),$(TEX_STYLE) $< $@ sed -i -e 's/continued on next page/suite sur la page suivante/;s|^%$$||' $@ sed -i -e 's/admonition-/admonition/g' $@ # Generate each pdf with latex -tmp/%.pdf: tmp/%.tex $(BIBS) | tmp +tmp/%.pdf: tmp/%.tex tmp/model.tex $(BIBS) | tmp + set TEXINPUTS=.:$(MODEL):$$(TEXINPUTS) $(TEX) -output-directory tmp $< #bibtex tmp/$*.aux && $(TEX) -output-directory tmp $< || echo "no bib" - while grep 'Rerun to get ' tmp/$*.log ; do $(TEX) -output-directory tmp $< ; done + while grep 'Rerun to get ' tmp/$*.log ; do \ + $(TEX) --halt-on-error -output-directory tmp $< ;\ + done # Put the pdf in the right place %.pdf: tmp/%.pdf | tmp @@ -62,6 +73,7 @@ tmp/%.pdf: tmp/%.tex $(BIBS) | tmp # Update mupdf if the process exist, or do nothing. pkill -HUP mupdf || true +.PHONY: clean clean: rm -r tmp @@ -73,6 +85,7 @@ clean: # Watch mode, which regenerate the documents as soon there is a change in a # file., # requires inotifywait (package inotify-tools) +.PHONY: watch watch: while true; do \ $(MAKE) all; \ diff --git a/model_7/Makefile b/model_7/Makefile index 25786c6..6beef28 100755 --- a/model_7/Makefile +++ b/model_7/Makefile @@ -1 +1,3 @@ include ../common/Makefile.common + +EXTRA_STYLES = fontsize diff --git a/model_7/resources/00_preamble.tex b/model_7/resources/00_preamble.tex index 498551f..717d865 100755 --- a/model_7/resources/00_preamble.tex +++ b/model_7/resources/00_preamble.tex @@ -16,7 +16,7 @@ } \makeatother -\input{../common/10_language.tex} -\input{../common/10_lists.tex} -\input{../common/10_nowidows.tex} +\input{\commonPath/10_language.tex} +\input{\commonPath/10_lists.tex} +\input{\commonPath/10_nowidows.tex} diff --git a/model_7/resources/10_decoration.tex b/model_7/resources/10_decoration.tex index b394599..b9516ce 100644 --- a/model_7/resources/10_decoration.tex +++ b/model_7/resources/10_decoration.tex @@ -14,7 +14,7 @@ % 1: the size of the decoration % 2: the distance to the page (not the text margin but the page itself % 3: the color -\newcommand{\pageornament}[3]{% +\providecommand{\pageornament}[3]{% \begin{tikzpicture}[remember picture, overlay] \node[yshift=-#2,xshift=-#2, anchor=north east] at (current page.north east){% \pgfornament[color=#3,width=#1,symmetry=v]{41} diff --git a/model_7/resources/99_begin.tex b/model_7/resources/99_begin.tex index 5d9ca89..e9ec8a1 100755 --- a/model_7/resources/99_begin.tex +++ b/model_7/resources/99_begin.tex @@ -1,7 +1,6 @@ -\input{../common/90_ref.tex} +\input{\commonPath/90_ref.tex} %% On charge les colonnes dès le début du document. %\AtBeginDocument{% % \begin{paracol}{1} %} - diff --git a/model_7/resources/modules b/model_7/resources/modules index c7b9742..7627b8e 100755 --- a/model_7/resources/modules +++ b/model_7/resources/modules @@ -1,15 +1,8 @@ -tikz -parskip # Ne pas indenter la premiere ligne d'un paragraphe setspace - -# Polices mathematiques. -amsmath -amsfonts -amssymb +parskip # Ne pas indenter la premiere ligne d'un paragraphe DUsmallcaps paracol lipsum DUcolumn -Ducenter -fontsize +DUcenter diff --git a/readme.rst b/readme.rst index 74304e5..44f98e0 100755 --- a/readme.rst +++ b/readme.rst @@ -28,6 +28,56 @@ Organisation Chaque répertoire contient un style de document. La commande `make` permet de générer le fichier PDF à partir du fichier source. +Pour réutiliser un modèle, il suffit de créer ces lignes dans un fichier +`Makefile` : + +.. code:: Makefile + + MODEL = ../model_7 + + include ../common/Makefile.common + +Personalisation +--------------- + +Les règles de basent peuvent être personalisée en fonction des besoins. + +:`EXTRA_RST_OPTIONS`: + + Cette option va donner des directives supplémentaires au compilateur + rst2latex + + Exemple : + + .. code:: Makefile + + EXTRA_RST_OPTIONS = \ + --table-style=booktabs + + +:`EXTRA_STYLES`: + + Cette option permet d’ajouter des styles supplémentaires qui sont appliqués + sur le document généré. + + .. code:: Makefile + + EXTRA_STYLES = fontsize\ + +:`FILTERS`: + + Cette option permet de lister les modules présents dans le modèle de base + et ne devant pas être chargé. (En vue de les surcharger par exemple). + + .. code:: Makefile + + FILTERS = %10_geometry.tex \ + %10_title_style.tex \ + %00_colors.tex \ + +Exemples +======== + Les images ci-dessous sont construites à partir des fichiers exemples : Model 1 @@ -101,6 +151,17 @@ Modèle utilisé pour un mariage .. image:: /latex_template.git/plain/snapshots/model7.png :width: 400px +Commandes fournies par ce modèle : + +:pageornament: + + Commande appliquée en fond de page sur chaque page. Elle prend trois + arguments : + + - La dimension de l’image + - La distance par rapport au bord de l’image + - La couleur à appliquer + Model 8 ------- -- cgit v1.2.3