3 次代码提交 1a4fe82332 ... b5a76a61d5

作者 SHA1 备注 提交日期
  Thierry Dumont b5a76a61d5 avant chgt 3 周之前
  Thierry Dumont d731d3a360 ajouts divers 1 月之前
  Thierry Dumont f7dc9fae8d petites modifs 1 月之前
共有 6 个文件被更改,包括 132 次插入50 次删除
  1. 2 0
      All/nettex.sh
  2. 36 18
      All/tout.py
  3. 1 1
      README.md
  4. 9 0
      TODO
  5. 43 12
      extr.py
  6. 41 19
      tpl.tex

+ 2 - 0
All/nettex.sh

@@ -0,0 +1,2 @@
+#!/bin/sh
+rm -f *.aux *.md *.log *.toc *.bcf *.run.xml *blg *bbl

+ 36 - 18
All/tout.py

@@ -1,56 +1,74 @@
-
+#!/home/moi/ProtoMemoires/venv/bin/python
+import glob
 #-------------------------------------------            
 def addpath(x,ajout):
+    # Pour transformer les chemins vers les images
     if "includegraphics" in x:
         return x.replace("{",ajout)
     else:
         return x
 #
-templat= "../tpl.tex"
-#
 # Récupérer la liste des textes à introduire
 #
 with open("all_texts") as f:
-    lf= f.readlines()
+    lf= [x for x in f.readlines() if x[0] != "#"]
+    
+# faire la liste des *.bib (éventuels):
+forbiblatex={}
+for f in lf:
+    forbiblatex[f]=",".join([x for x
+                             in glob.glob(f"../{f.split("/")[0]}/*.bib")])
+allbibfiles=[forbiblatex[k] for k in forbiblatex.keys()  if forbiblatex[k]!=""]
+print("Fichiers bib",allbibfiles,"\n")
+#
+# Récuperer le template
+#
+templat= "../tpl.tex"
 #
-#on récupère le template
 with open(templat) as f:
     Ltmpl=f.readlines()
-# 
+#
+# ne garder du template que le début
 Lall=[]
 for l in Ltmpl:
     if "%@@debut" in l:
         break
     else:
+        if "addbibresource" in l:
+            # ajouter les chemins vers les fichires bib
+            for x in allbibfiles:
+                Lall.append(f"\\addbibresource{{{x}}}\n")
+                
         Lall.append(l)
-
-bound1= "pagestyle"
-bound2= "tableofcontents"
-
-
+#
+# parcourir les fichiers à assembler:
+#
 for l in lf:
     lok="../"+l.replace("\n","")
     print(lok)
     with open(lok) as g:
         LL=g.readlines()
-    #Z= getlines(LL,"debut","fin")
+    # insérer ce qui entre %@@debut et "%@@fin":
     start= False
     Z= []
     for x in LL:
-        if "%@@debut" in x:
+        if "@@debut" in x:
             start= True
-        if "%@@fin" in x:
+            print("--> start")
+        if "@@fin" in x:
             break
         if start:
             Z.append(x)
-    # graphiques
+    print("--> nl:",len(Z))
+    # graphiques: modifier les chemins:
     ajout="{../"+l.split("/")[0]+"/"
-    
     Lall+=[addpath(x,ajout) for x in Z if not "newcounter" in x]
-    Lall.append("\\eject\n")
-    
+    Lall.append("\\vfill\n\\eject\n")
+#
+# sauver le resultat....
 with open("final.tex","w") as f:
     for x in Lall[:-1]:
         f.write(x)
+#-----------------------------------------------------------
     f.write("\\tableofcontents\n")
     f.write("\\end{document}\n")

+ 1 - 1
README.md

@@ -2,7 +2,7 @@
 
 #### Dans ce répertoire
 
-  - configurer data.yml  (prototype au dessus)
+  - configurer data.yml  (prototype ici)
   
   - python ../extr1.py
 

+ 9 - 0
TODO

@@ -0,0 +1,9 @@
+* vérifier le layout
+
+* garamond ?
+
+* \ieme partout
+
+* headings
+
+* Chapter /part...

+ 43 - 12
extr.py

@@ -1,7 +1,8 @@
-#!./venv/bin/python
+#!/home/moi/ProtoMemoires/venv/bin/python
 import sys,pypandoc,os,re,subprocess,yaml
 #
 data_yml_mandatory_keys=['fichier', 'date',  'auteur', 'titre']
+data_yml_order=['date','type','auteur','statut','titre']
 def star_sec(l):
     # \section est transformée en \section* et on ne garde comme argument
     # que ce qui est nécessaire.
@@ -34,16 +35,20 @@ def star_sec(l):
 #-----------------------------------------------------------------------
 with open("data.yml") as f:
     lt=yaml.safe_load(f)
+
 for x in data_yml_mandatory_keys: #vérifier la présence des clés obligatoires
     if not x in lt.keys():
         raise Exception(f"\n\n Il manque {x} dans data.yml\n\n")
-# si statut est défini, type dit l'être aussi:
+# si statut est défini, type doit l'être aussi:
 if "statut" in lt.keys():
     if "type" not in lt.keys():
         raise Exception(f"\n\n statut est défini, mais pas type\n\n")
-else: # si statut n'est pas défini, on le définit  à "" et type à "Conférence".
+    lt['statut']=", "+lt["statut"]
+else: # si statut n'est pas défini, on le définit  à " " et type à "Conférence".
     lt["statut"]=" "
     lt["type"]="Conférence"
+# biblio ?
+has_bib= "biblio"in lt.keys()
 #
 # le fichier (docx, odt) qu'on va traiter:
 #
@@ -51,9 +56,12 @@ fich=lt["fichier"].strip()
 #
 # fabriquer le titre à partir des données yml
 #
-titre_elements="}{".join([lt[x].replace("\n","") for x in lt.keys()
-                          if x!="fichier"])
-le_titre="\\titre{"+titre_elements+"}"+"\n"
+titre_elements="}{".join([lt[x].replace("\n","") for x in data_yml_order])
+
+#le_titre="\\titre{"+titre_elements+"}"+"\n"
+le_titre= f"\\titre{{{titre_elements}}}\n"
+
+
 #--------------------------------------------------------------------
 template="../tpl.tex" # le template
 #---------------------------------------------------------------------
@@ -73,9 +81,9 @@ if not os.path.isdir(images):
 #
 # conversion en latex
 #
-extra_args= ["-s",f"--template={template}",f"--extract-media={images}"]
-#extra_args= ["-s",f"--template={template}",f"--extract-media={images}",
-#             f"--lof=true"]
+#extra_args= ["-s",f"--template={template}",f"--extract-media={images}"]
+extra_args= ["-s",f"--template={template}",f"--extract-media={images}",
+             f"--lof=true"]
 L = pypandoc.convert_file(fich, 'tex',
                           extra_args=extra_args).splitlines()
 
@@ -102,26 +110,49 @@ with open(futurTex,"w") as f:
     
     rp0,rp1= repPath
     for l in L1:
-        
+        if has_bib and "addbibresource{}" in l:
+            bibfile=lt['biblio']
+            l=l.replace("{","{"+bibfile)
+        if "textsuperscript{e}" in l:
+            print(l)
+            l=l.replace("textsuperscript{e}","ieme{}")
+            print(l)
+            #ccc=input()
         while (q:=rechgrac.search(l)) != None:
             l=l.replace(rp0,rp1)
         # on supprime les "quote"
         l=l.replace("\\begin{quote}","")
         l=l.replace("\\end{quote}","")
+        # subsection-> subsection*
+        l=l.replace("subsection{","subsection*{")
         
+        if "@@fin" in l:
+            if has_bib:
+                f.write("\\begin{center}\\textbf{Bibliographie}\\end{center}\n")
+                f.write("\citeall[\\fullcite]\n")
+                f.write("\FloatBarrier\n")
         f.write(l)
         f.write("\n")
 
         
-        if "debut" in l:
+        if "@@debut" in l:
+            f.write("\\fancyhead{}\n")
+            f.write("\\fancyhead[CE]{Mémoires: 2\ieme{} partie}\n")
+            aut= lt["auteur"]
+            f.write(f"\\fancyhead[CO]{{{lt['auteur']}, {lt['titre']}}}\n")
             f.write(le_titre)
+        
 #
 #---fin d'éciture du fichier tex
 #
 # lualatex, 2 fois:
 #
-for i in {1,2}:
+
+subprocess.run(["/usr/bin/lualatex", futurTex])
+if has_bib:
+    subprocess.run(["/usr/bin/biber", futurTex.replace(".tex","")])
     subprocess.run(["/usr/bin/lualatex", futurTex])
+subprocess.run(["/usr/bin/lualatex", futurTex])
 #--- fin
 
 

+ 41 - 19
tpl.tex

@@ -7,7 +7,7 @@ total={130mm,212mm},
 %
 %\setcounter{secnumdepth}{-4}
 %\setcounter{tocdepth}{0}
-\usepackage{mfirstuc}
+\usepackage{mfirstuc}% mettre en majuscule une 1re letter
 %
 %\usepackage[fontsize=10]{fontsize}
 %
@@ -16,19 +16,18 @@ total={130mm,212mm},
 %\usepackage[showframe,b5paper,verbose]{geometry}
 \counterwithin{figure}{section}
 %\usepackage{fontspec}
-\usepackage{lmodern}
-%\usepackage{ebgaramond}
-%\usepackage{ebgaramond-maths}
-%\usepackage{times}
+%\usepackage{lmodern}
+\usepackage{ebgaramond}
+\usepackage{unicode-math}
+\setmathfont{Garamond-Math}
+
 \usepackage[export]{adjustbox}
 \usepackage{wrapfig}
-% \usepackage{fourier}
-%\usepackage[T1]{fontenc}
 
 \usepackage[french]{babel}
 %\frenchsetup{og=«, fg=»} % inutile avec lualatex
 
-\usepackage{textcomp}
+\usepackage{textcomp}% des symboles?
 \usepackage{epigraph,csquotes,verse}
 
 \usepackage{graphicx}
@@ -50,9 +49,14 @@ total={130mm,212mm},
 %\usepackage{footnote}
 \usepackage{soul}
 \usepackage{multirow}
-\usepackage{placeins}
+\usepackage{placeins}% pour avoir \FloatBarrier
+%
+\usepackage{fancyhdr}
+
 %
-\usepackage[natbib,style=authoryear]{biblatex}
+\usepackage[style=authoryear]{biblatex}
+\usepackage{citeall}
+\addbibresource{}
 %
 \providecommand{\tightlist}{%
 	   \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
@@ -69,16 +73,28 @@ total={130mm,212mm},
 \newcommand{\mysection}[2]{\section*{ #2}}
 
 \newcommand{\titre}[5]{% date / type /auteur/ membre/ titre
-  %\section*[{\bfseries #1.} \capitalisewords{#2} par #3, #4.\\#5]{}%
-  %{\raggedright\sl\bfseries #1}%
   {\raggedright{\textsl{\bfseries\large \capitalisewords{#1}}}}\\%
-  {\raggedright{\bfseries\large \capitalisewords{{#2}} de #3,} \textsl{#4}}%
+  {\raggedright{\bfseries\large \capitalisewords{{#2}} de #3} \textsl{#4}}%
    \addcontentsline{toc}{section}{{\bfseries #1.} \capitalisewords{#2}
-     par #3, #4.\\\textsl{#5}}%
+     de #3, #4.\\\textsl{#5}}%
   \vspace*{24pt}%
   \begin{center}{\Large\bfseries #5}\end{center}%
   \vspace*{5mm}%
+  \fancyhead{}%
+  \fancyhead[CE]{Mémoires: 2\ieme{} partie}%
+  \fancyhead[CO]{#3. #5}%
+}
+
+\newcommand{\epigraphnorule}[1]{%
+\vspace*{\beforeepigraphskip}%
+\begin{flushright}%
+  \begin{minipage}{\epigraphwidth}\raggedright\small
+#1%
+\end{minipage}%
+\end{flushright}%
+\vspace*{\afterepigraphskip}%
 }
+\renewcommand{\thefigure}{\arabic{figure}}
 % \makeatletter
 
 % \renewcommand\section{\@startsection {section}{1}{\z@}%
@@ -87,21 +103,27 @@ total={130mm,212mm},
 %                                    {\normalfont\large\scshape}}
 
 % \makeatother
-%\titleformat{\section}[block]{\normalsize\scshape\filcenter}{}{1em}{}
+%
 \titleformat{\section}[block]{\large\bfseries}{}{100em}{}
 \titleformat{\subsection}{\normalsize\bfseries}{}{}{}
 %
-
+% \makeatletter
+% \titleformat{\part}[display]
+%   {\Huge\scshape\filright}
+%   {\partname~}
+%   {20pt}
+%   \makeatother
 %
 \begin{document}%\layout
 
-\pagestyle{plain}
-
+%\pagestyle{plain}
+\pagestyle{fancy}
 \newcounter{none}
+%\fancyhead{} 
+%\fancyhead[RO,LE]{\textbf{blabla}}
 %@@debut
 % \maketitle
 
-
   $body$
   
 %@@fin