diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | common/Makefile.common | 57 | ||||
-rwxr-xr-x | model_1/resources/10_fonts.tex | 2 | ||||
-rwxr-xr-x | model_2/resources/10_fonts.tex | 2 | ||||
-rwxr-xr-x | model_3/resources/10_fonts.tex | 2 | ||||
-rwxr-xr-x | model_4/resources/10_fonts.tex | 2 | ||||
-rwxr-xr-x | model_5/resources/10_fonts.tex | 3 | ||||
-rwxr-xr-x | model_7/Makefile | 2 | ||||
-rwxr-xr-x | model_7/resources/00_preamble.tex | 9 | ||||
-rw-r--r-- | model_7/resources/10_decoration.tex | 2 | ||||
-rw-r--r-- | model_7/resources/10_geometry.tex | 2 | ||||
-rwxr-xr-x | model_7/resources/99_begin.tex | 3 | ||||
-rwxr-xr-x | model_7/resources/modules | 11 | ||||
-rwxr-xr-x | model_8/Makefile | 10 | ||||
-rwxr-xr-x | readme.rst | 65 |
16 files changed, 138 insertions, 39 deletions
@@ -1,2 +1,5 @@ *.pdf *.swp +*/example.png +*/tmp +readme.html @@ -3,7 +3,7 @@ SUBDIRS := $(wildcard model*/. example*/.) all: $(SUBDIRS) $(SUBDIRS): - $(MAKE) -C $@ + $(MAKE) -j -C $@ pngs: $(SUBDIRS) for dir in $(SUBDIRS); do \ diff --git a/common/Makefile.common b/common/Makefile.common index 2a710cc..730a994 100644 --- a/common/Makefile.common +++ b/common/Makefile.common @@ -1,5 +1,6 @@ TEX=$(shell command -v lualatex xelatex | head -n 1) SOURCE=. +MODEL ?= . SRC =$(wildcard *.rst) SVG =$(wildcard content/*.svg) @@ -12,7 +13,31 @@ all: $(PDFS) BIBS =$(wildcard *.bib) DIR = $(sort $(shell find $(SOURCE) -name '*.rst' -print)) -SOURCES = $(sort $(wildcard resources/*.tex) ) + +# Pick the first file for the given name, either in the path from the model, or +# in the local path from the source. +select_file = \ + $(firstword $(wildcard ./resources/$(1)) $(wildcard $(MODEL)/resources/$1)) + + +# Select the files to use in the styles. +ifeq ($(MODEL),.) + $(info Modèle de base) + + SOURCES = $(sort $(filter-out $(FILTERS), $(wildcard $(MODEL)/resources/*.tex) )) + +else + $(info Modèle surchargé) + + # Remove from the list the elements given in the variable FILTERS + NEW_STYLES = $(wildcard resources/*.tex) + MODEL_STYLES = $(wildcard $(MODEL)/resources/*.tex) + # For each file, extract the name, and sort the list by order. + STYLE_NAME = $(sort $(foreach fic,$(NEW_STYLES) $(filter-out $(FILTERS),$(MODEL_STYLES)),$(notdir $(fic)))) + # Pick the file either in the current directory, or in the model path + SOURCES = $(foreach fic,$(STYLE_NAME),$(call select_file,$(fic))) + +endif null := space := $(null) # @@ -20,14 +45,25 @@ comma := , TEX_STYLE := $(subst $(space),$(comma),$(strip $(SOURCES))) TEX_BIBS := $(subst $(space),$(comma),$(strip $(BIBS))) -PACK = $(shell sed -e 's/\#.*$$//' -e '/^$$/d' resources/modules) -PACKAGES := $(subst $(space),$(comma),$(strip $(PACK))) +# Add a variable for specific options to add in the rst2latex command +# +EXTRA_RST_OPTIONS ?= + +EXTRA_STYLES ?= + +# Remove the comments and the empty lines from the module list file +PACK = $(shell sed -e 's/\#.*$$//' -e '/^\s$$/d' $(MODEL)/resources/modules) +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) | tmp $$(command -v rst2latex rst2latex.py | head -n 1) \ --no-section-subtitles \ --table-style=borderless \ @@ -36,21 +72,27 @@ tmp/%.tex: %.rst $(INCLUDED_PDF) $(SOURCES)| tmp --documentclass=extarticle \ --documentoption=12pt,A4,table \ --syntax-highlight=short \ - --stylesheet=$(PACKAGES),$(TEX_STYLE) $< $@ + $(EXTRA_RST_OPTIONS) \ + --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 cp $< $@ + # Update mupdf if the process exist, or do nothing. pkill -HUP mupdf || true +.PHONY: clean clean: rm -r tmp @@ -62,6 +104,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_1/resources/10_fonts.tex b/model_1/resources/10_fonts.tex index 5455f8a..d070ac6 100755 --- a/model_1/resources/10_fonts.tex +++ b/model_1/resources/10_fonts.tex @@ -21,5 +21,5 @@ , Contextual
, Historic } ]
-\newfontfamily\AltFont[Mapping=tex-text]{Linux Libertine O}
\input{../common/10_fonts.tex}
+\let\AltFont\LibertineFont
diff --git a/model_2/resources/10_fonts.tex b/model_2/resources/10_fonts.tex index 7d98468..0bb7c03 100755 --- a/model_2/resources/10_fonts.tex +++ b/model_2/resources/10_fonts.tex @@ -10,5 +10,5 @@ Mapping=tex-text,
Ligatures={Common, Required, Contextual, Historic}
]
-\newfontfamily\AltFont[Mapping=tex-text]{Linux Libertine O}
\input{../common/10_fonts.tex}
+\let\AltFont\LibertineFont
diff --git a/model_3/resources/10_fonts.tex b/model_3/resources/10_fonts.tex index 7c05521..f565b74 100755 --- a/model_3/resources/10_fonts.tex +++ b/model_3/resources/10_fonts.tex @@ -8,7 +8,6 @@ Mapping=tex-text,
Ligatures={Common, Required, Contextual, Historic}
]
-\newfontfamily\AltFont[Mapping=tex-text]{Linux Libertine O}
\setmainfont{Quicksand-Light}[
Path=../fonts/,
@@ -17,3 +16,4 @@ \setmonofont{Latin Modern Mono Light}
\input{../common/10_fonts.tex}
+\let\AltFont\LibertineFont
diff --git a/model_4/resources/10_fonts.tex b/model_4/resources/10_fonts.tex index e8014fb..164d136 100755 --- a/model_4/resources/10_fonts.tex +++ b/model_4/resources/10_fonts.tex @@ -1,6 +1,5 @@ \usepackage{fontspec}
-\newfontfamily\AltFont[Mapping=tex-text]{Linux Libertine O}
\newfontfamily\BeatrixFont[Path=../fonts/,Mapping=tex-text]{Beatrix}
\defaultfontfeatures{Ligatures={Common, Required, Contextual}}
@@ -9,3 +8,4 @@ \setmonofont{Latin Modern Mono Light}
\input{../common/10_fonts.tex}
+\let\AltFont\LibertineFont
diff --git a/model_5/resources/10_fonts.tex b/model_5/resources/10_fonts.tex index befadd5..52b69c3 100755 --- a/model_5/resources/10_fonts.tex +++ b/model_5/resources/10_fonts.tex @@ -10,4 +10,5 @@ {EB Garamond} [ Mapping=tex-text ] -\newfontfamily\AltFont[Mapping=tex-text]{Linux Libertine O} +\input{../common/10_fonts.tex} +\let\AltFont\LibertineFont 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 30c4fd3..717d865 100755 --- a/model_7/resources/00_preamble.tex +++ b/model_7/resources/00_preamble.tex @@ -1,6 +1,3 @@ -\usepackage[a4paper, landscape, top=1.0cm, left=1.5cm, right=1.5cm, bottom=2.0cm]{geometry} -%\pagestyle{empty} -%\pagenumbering{arabic} \newcommand{\DUrolelatex}[1]{#1} \usepackage{tocloft} @@ -19,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/10_geometry.tex b/model_7/resources/10_geometry.tex new file mode 100644 index 0000000..2cf4bb4 --- /dev/null +++ b/model_7/resources/10_geometry.tex @@ -0,0 +1,2 @@ +\usepackage[a4paper, top=1.0cm, left=1.5cm, right=1.5cm, bottom=2.0cm]{geometry} + 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/model_8/Makefile b/model_8/Makefile index d77d559..ca74045 100755 --- a/model_8/Makefile +++ b/model_8/Makefile @@ -1,11 +1,5 @@ include ../common/Makefile.common -tmp/%.tex: %.rst $(INCLUDED_TEX) $(SOURCES) | tmp - $$(command -v rst2latex rst2latex.py | head -n 1) \ +EXTRA_RST_OPTIONS = \ --no-section-numbering \ - --table-style=booktabs \ - --documentclass=article \ - --documentoption=12pt,A4,table \ - --syntax-highlight=short \ - --stylesheet=$(PACKAGES),$(TEX_STYLE) \ - $< $@ + --table-style=booktabs @@ -28,6 +28,60 @@ 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ées en fonction des besoins. + +Chaque fichier de style présent dans le répertoire du modèle peut être +surchargé par un fichier de style de même nom présent dans le répertoire +courant du modèle. + +:`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 +155,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 ------- |