abougouffa / minemacs

MinEmacs: an Emacs configuration framework for daily use
https://abougouffa.github.io/minemacs/
MIT License
143 stars 16 forks source link

org export language error #69

Closed DarkBuffalo closed 1 year ago

DarkBuffalo commented 1 year ago

Salut @abougouffa.

Quand je defini dans config.el la variable org-export-default-language a "fr" il continu de génerer des pdf en anglais.

Ais je loupé quelquechose ?

abougouffa commented 1 year ago

J'avoue que je n'ai jamais utilisé ce paramètre org-export-default-language! Sur ma machine, je génère les PDFs en anglais par défaut, pour le Français, je le configure souvent en entête du fichier Org.

DarkBuffalo commented 1 year ago

J'avoue que je n'ai jamais utilisé ce paramètre org-export-default-language! Sur ma machine, je génère les PDFs en anglais par défaut, pour le Français, je le configure souvent en entête du fichier Org.

Dans ce deuxième cas #+language: fr ça ne fonctionne pas non plus.

abougouffa commented 1 year ago

Dans ce deuxième cas #+language: fr ça ne fonctionne pas non plus.

Oui, le #+language: fr n'as jamais fonctionné pour moi, en tout cas pour l'export en PDF, je n'ai pas essayé d'autres types de fichiers. Moi, pour le PDF, j'ai défini quelques noms de classes préconfigurées pour le Français (dans org-latex-classes), puis j'utilise #+latex_class: thesis-fr par exemple. Les classes ajoutées dans MinEmacs sont ici:

https://github.com/abougouffa/minemacs/blob/d391634f5d30d1f1d77fcb250498ba9feecc9f66/modules/extras/me-org-extras.el#L201-L254

Dans la plupart des cas, comme je n'exporte qu'en PDF, je fais ma config soit en entête, soit dans un fichier séparé que j'inclue au début avec +setupfile: template.org, le contenu serait quelque chose comme:

#+latex_compiler: xelatex
#+options: toc:nil author:nil date:nil title:nil subtitle:nil
#+language: fr
#+latex_class: thesis
#+latex_class_options: [french,12pt,a4paper]

#+latex_header: \usepackage{fontspec}
#+latex_header: \usepackage[french]{babel}

J'espère que cela peut t'aider!

abougouffa commented 1 year ago

NOTE: Je viens de tester la config minimale pour générer un PDF en Français, ça a marché avec:

#+language: fr
#+latex_header: \usepackage[french]{babel}

UPDATE: Je viens de voir sur la documentation de org-latex-classes qu'il faut ajouter \usepackage[AUTO]{babel} à la classe. Dans ce cas, le AUTO serait remplacé par la valeur de org-export-default-language ou #+langage:.

Donc, il faudrait ajouter un truc comme:

(add-to-list 'org-latex-classes
             '("article-auto"
               "\\documentclass[11pt]{article}
\\usepackage[AUTO]{babel}"
               ("\\section{%s}" . "\\section*{%s}")
               ("\\subsection{%s}" . "\\subsection*{%s}")
               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
               ("\\paragraph{%s}" . "\\paragraph*{%s}")
               ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

Puis, dans un fichier Org:

#+language: fr
#+latex_class: article-auto

Bla bla bla

Je vais faire le nécessaire pour que cela soit activé par défaut dans MinEmacs.

abougouffa commented 1 year ago

Après le dernier commit, un truc comme:

#+language: fr

* Fusce suscipit, wisi nec facilisis
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit tempor
tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et, mattis
eget, convallis nec, purus. Cum sociis natoque penatibus et magnis dis
parturient montes, nascetur ridiculus mus. Nulla posuere.

* In id erat non orci commodo lobortis
Donec vitae dolor. Nullam tristique diam non turpis. Cras placerat accumsan
nulla. Nullam rutrum. Nam vestibulum accumsan nisl.

Serait automatiquement exporté en Français.

Screenshot_20230602_230631

Ça doit marcher aussi avec org-export-default-language.

DarkBuffalo commented 1 year ago

Merci beaucoup @abougouffa En effet ça fonctionne.

DarkBuffalo commented 1 year ago

Salut @abougouffa c'est aussi possible d'utiliser la variable suivante pour ajouter babel en AUTO

  (setq org-latex-default-packages-alist
      '(("AUTO" "inputenc" t ("pdflatex"))
        ("T1" "fontenc" t ("pdflatex"))
        ("AUTO" "babel" t ("pdflatex"))
        ("" "xcolor" nil) ; Generally useful
        ("" "hyperref" nil)
        ;;("" "natbib" t)
        ("" "cleveref")))
abougouffa commented 1 year ago

Merci @DarkBuffalo

Super! C'est effectivement plus logique de le faire de cette manière là. Merci pour l'info!

DarkBuffalo commented 1 year ago

@abougouffa voici une config que j'ai trouvé sympa dans la structure créé par tecosaur içi

(defun +org-extras-latex-classes-setup ()
  (with-eval-after-load 'ox-latex

    ;; Use `babel' with automatic language detection (from `#+language:' or
    ;; `org-export-default-language')
    (add-to-list 'org-latex-default-packages-alist '("AUTO" "babel" t ("pdflatex" "xelatex")))

    (let* ((article-sections '(("\\section{%s}" . "\\section*{%s}")
                               ("\\subsection{%s}" . "\\subsection*{%s}")
                               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                               ("\\paragraph{%s}" . "\\paragraph*{%s}")
                               ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
           (book-sections (append '(("\\chapter{%s}" . "\\chapter*{%s}"))
                                  article-sections))
           (cv-sections '(("\\cvsection{%s}" . "\\cvsection*{%s}")))
           (hanging-secnum-preamble "\\renewcommand\\sectionformat{\\llap{\\thesection\\autodot\\enskip}}
\\renewcommand\\subsectionformat{\\llap{\\thesubsection\\autodot\\enskip}}
\\renewcommand\\subsubsectionformat{\\llap{\\thesubsubsection\\autodot\\enskip}}
")
           (big-chap-preamble "\\usepackage[AUTO]{babel}
\\RedeclareSectionCommand[afterindent=false, beforeskip=0pt, afterskip=0pt, innerskip=0pt]{chapter}
\\setkomafont{chapter}{\\normalfont\\Huge}
\\renewcommand*{\\chapterheadstartvskip}{\\vspace*{0\\baselineskip}}
\\renewcommand*{\\chapterheadendvskip}{\\vspace*{0\\baselineskip}}
\\renewcommand*{\\chapterformat}{%
  \\fontsize{60}{30}\\selectfont\\rlap{\\hspace{6pt}\\thechapter}}
\\renewcommand*\\chapterlinesformat[3]{%
  \\parbox[b]{\\dimexpr\\textwidth-0.5em\\relax}{%
    \\raggedleft{{\\large\\scshape\\bfseries\\chapapp}\\vspace{-0.5ex}\\par\\Huge#3}}%
    \\hfill\\makebox[0pt][l]{#2}}
")
           (fancy-preamble "\\usepackage[T1]{fontenc}
\\usepackage[osf,largesc,helvratio=0.9]{newpxtext}
\\usepackage[scale=0.92]{sourcecodepro}
\\usepackage[varbb]{newpxmath}
\\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=2000]{microtype}
\\usepackage{xcolor}
\\usepackage{booktabs}
\\usepackage{subcaption}
\\usepackage[hypcap=true]{caption}
\\setkomafont{caption}{\\sffamily\\small}
\\setkomafont{captionlabel}{\\upshape\\bfseries}
\\captionsetup{justification=raggedright,singlelinecheck=true}
\\setcapindent{0pt}

\\setlength{\\parskip}{\\baselineskip}
\\setlength{\\parindent}{0pt}

\\usepackage{pifont}
\\newcommand{\\checkboxUnchecked}{$\\square$}
\\newcommand{\\checkboxTransitive}{\\rlap{\\raisebox{0.0ex}{\\hspace{0.35ex}\\Large\\textbf -}}$\\square$}
\\newcommand{\\checkboxChecked}{\\rlap{\\raisebox{0.2ex}{\\hspace{0.35ex}\\scriptsize \\ding{56}}}$\\square$}
\\usepackage{awesomebox}
")
           (num-section-tuf "\\usepackage[AUTO]{babel}
\\definecolor{g1}{HTML}{077358}
\\definecolor{g2}{HTML}{00b096}
%%section format
\\titleformat{\\section}
{\\normalfont\\Large\\itshape\\color{g1}}%% format applied to label+text
{\\llap{\\colorbox{g1}{\\parbox{1.5cm}{\\hfill\\color{white}\\thesection}}}}%% label
{1em}%% horizontal separation between label and title body
{}%% before the title body
[]%% after the title body

%% subsection format
\\titleformat{\\subsection}%%
{\\normalfont\\large\\itshape\\color{g2}}%% format applied to label+text
{\\llap{\\colorbox{g2}{\\parbox{1.5cm}{\\hfill\\color{white}\\thesubsection}}}}%% label
{1em}%% horizontal separation between label and title body
{}%% before the title body
[]%% after the title body")

           (two-column-preamble "%%\\documentclass[a4paper, twocolumn]{article}
\\usepackage[OT1]{fontenc}
%% for setting the linespace (\setstretch)
\\usepackage{setspace}

%% distance between the columns
\\setlength{\\columnsep}{1cm}

%% for compactitem
\\usepackage{paralist}

%% for comments
\\usepackage{verbatim}

\\usepackage{graphicx}

\\def\\title#1{\\gdef\\@title{#1}\\gdef\\THETITLE{#1}}
\\makeatletter
\\renewcommand\\maketitle{
  \\parindent0pt
  \\setstretch{1.4}

  \\hrulefill
  \\vspace{0.0cm}
  \\begin{spacing}{2.1}
  {
    \\flushleft
    \\fontsize{22pt}{44pt}\\selectfont
    \\THETITLE\\
  }\\
  \\end{spacing}
  \\setstretch{1.2}
  {\\Large \\@author\\par}
  {\\Large \\@email\\par}
  {\\large \\@date\\par}
  \\hrulefill
}
\\makeatother
")
           (cv-preamble "% Change the page layout if you need to
\\geometry{left=1.25cm,right=1.25cm,top=1.5cm,bottom=1.5cm,columnsep=1.2cm}

% Use roboto and lato for fonts
\\renewcommand{\\familydefault}{\\sfdefault}

% Change the colours if you want to
\\definecolor{SlateGrey}{HTML}{2E2E2E}
\\definecolor{LightGrey}{HTML}{666666}
\\definecolor{DarkPastelRed}{HTML}{450808}
\\definecolor{PastelRed}{HTML}{8F0D0D}
\\definecolor{GoldenEarth}{HTML}{E7D192}
\\colorlet{name}{black}
\\colorlet{tagline}{PastelRed}
\\colorlet{heading}{DarkPastelRed}
\\colorlet{headingrule}{GoldenEarth}
\\colorlet{subheading}{PastelRed}
\\colorlet{accent}{PastelRed}
\\colorlet{emphasis}{SlateGrey}
\\colorlet{body}{LightGrey}

% Change some fonts, if necessary
\\renewcommand{\\namefont}{\\Huge\\rmfamily\\bfseries}
\\renewcommand{\\personalinfofont}{\\footnotesize}
\\renewcommand{\\cvsectionfont}{\\LARGE\\rmfamily\\bfseries}
\\renewcommand{\\cvsubsectionfont}{\\large\\bfseries}

% Change the bullets for itemize and rating marker
% for \cvskill if you want to
\\renewcommand{\\itemmarker}{{\\small\\textbullet}}
\\renewcommand{\\ratingmarker}{\\faCircle}
"))

      (setcdr (assoc "article" org-latex-classes)
          `(,(concat "\\documentclass{scrartcl}" hanging-secnum-preamble)
            ,@article-sections))
      (add-to-list 'org-latex-classes
                   `("report" ,(concat "\\documentclass{scrartcl}" hanging-secnum-preamble)
                     ,@article-sections))
      (add-to-list 'org-latex-classes
                   `("fancy-article" ,(concat "\\documentclass{scrartcl}" fancy-preamble)
                     ,@article-sections))
      (add-to-list 'org-latex-classes
                   `("book" ,(concat "\\documentclass[twoside=false]{scrbook}"
                                     big-chap-preamble hanging-secnum-preamble)
                     ,@book-sections))
      (add-to-list 'org-latex-classes
                   `("blank" ,(concat "\\documentclass[twocolumn]{scrartcl}"
                               two-column-preamble
                                      "[DEFAULT-PACKAGES]\n[PACKAGES]\n[EXTRA]")
                     ,@article-sections))
      (add-to-list 'org-latex-classes
                   `("bmc-article" "\\documentclass[article,code,maths]{bmc}\n[NO-DEFAULT-PACKAGES]\n[NO-PACKAGES]\n[EXTRA]"
                     ,@article-sections))
      (add-to-list 'org-latex-classes
                   `("bmc" "\\documentclass[code,maths]{bmc}\n[NO-DEFAULT-PACKAGES]\n[NO-PACKAGES]\n[EXTRA]"
                     ,@book-sections))
      (add-to-list 'org-latex-classes
                   `("tufnotes" ,(concat "\\documentclass{tufte-handout}" num-section-tuf)
                     ,@article-sections))
      (add-to-list 'org-latex-classes
                   `("altacv" ,(concat "\\documentclass[10pt,a4paper,ragged2e,withhyper]{altacv}"
                                       cv-preamble)
                     ,@cv-sections)))))