up
This commit is contained in:
@@ -8,9 +8,10 @@ contributes:
|
||||
pdf-engine: lualatex
|
||||
documentclass: scrartcl
|
||||
template-partials:
|
||||
- before-title.tex
|
||||
- title.tex
|
||||
- after-header-includes.latex
|
||||
include-in-header: header.tex
|
||||
include-before-title: before-title.tex
|
||||
include-before-body: before-body.tex
|
||||
papersize: a4paper
|
||||
geometry:
|
||||
@@ -20,4 +21,9 @@ contributes:
|
||||
- head=14.5pt
|
||||
number-sections: true
|
||||
toc: true
|
||||
metadata:
|
||||
type-document:
|
||||
cours: false
|
||||
exercice: false
|
||||
actvite: false
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
title: Si
|
||||
author: Georg Ramer
|
||||
version: 0.3.0
|
||||
quarto-required: ">=1.5.0"
|
||||
contributes:
|
||||
shortcodes:
|
||||
- si.lua
|
||||
|
||||
169
_extensions/cours/_extensions/GeorgRamer/si/si.lua
Normal file
169
_extensions/cours/_extensions/GeorgRamer/si/si.lua
Normal file
@@ -0,0 +1,169 @@
|
||||
si_prefix = {Q = "Q", R = "R", Y = "Y", Z="Z", E = "E", P="P", T="T", G="G", M="M", k="k", h="h", d="d", c="c", m="m", u="\u{03BC}", n="n", p="p", f="f", a="a", z="z", y="y", r="r", q="q"}
|
||||
|
||||
si_units = {m="m", l="l", L="L", g="g", V="V", A="A", ohm="\u{03A9}", ang="\u{212B}"}
|
||||
|
||||
SPACE = "\u{202F}"
|
||||
TIMES = "\u{00D7}"
|
||||
DOT = "\u{00B7}"
|
||||
|
||||
|
||||
local function concatenateTables(t1, t2)
|
||||
for i = 1, #t2 do
|
||||
t1[#t1 + 1] = t2[i]
|
||||
end
|
||||
return t1
|
||||
end
|
||||
|
||||
function identify_block(arg)
|
||||
if arg == "." then
|
||||
return "DOT"
|
||||
end
|
||||
|
||||
if arg == "x" then
|
||||
return "TIMES"
|
||||
end
|
||||
|
||||
|
||||
if arg == "/" then
|
||||
return "SLASH"
|
||||
end
|
||||
|
||||
if string.match(arg, "^[a-zA-Z_°]+[-0-9]-$") then
|
||||
|
||||
return "UNIT"
|
||||
end
|
||||
|
||||
num_start = string.match(arg, "^[%d.,Eeij()+-°]+$")
|
||||
|
||||
if num_start then
|
||||
return "NUMERIC"
|
||||
end
|
||||
|
||||
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
parsers = {}
|
||||
|
||||
|
||||
|
||||
function parse_numeric(arg)
|
||||
arg = string.gsub(arg, "%+%-", "\u{00B1}")
|
||||
-- add exponents
|
||||
outtab = {}
|
||||
while string.find(arg, "[eE][+-]?%d+") do
|
||||
idx_start, idx_stop = string.find(arg, "[eE][+-]?%d+")
|
||||
before_substr = string.sub(arg, 1, idx_start-1)..TIMES.."10"
|
||||
table.insert(outtab, before_substr)
|
||||
table.insert(outtab, pandoc.Superscript(string.sub(arg,idx_start+1,idx_stop)))
|
||||
arg = string.sub(arg, idx_stop+1)
|
||||
end
|
||||
if string.len(arg)>0 then
|
||||
table.insert(outtab, arg)
|
||||
end
|
||||
return outtab
|
||||
end
|
||||
|
||||
parsers["NUMERIC"] = parse_numeric
|
||||
|
||||
function parse_dot(arg)
|
||||
|
||||
return {DOT}
|
||||
|
||||
end
|
||||
parsers["DOT"] = parse_dot
|
||||
|
||||
function parse_slash(arg)
|
||||
|
||||
return {"/"}
|
||||
|
||||
end
|
||||
|
||||
|
||||
parsers["SLASH"] = parse_slash
|
||||
|
||||
|
||||
function parse_times(arg)
|
||||
return {TIMES}
|
||||
end
|
||||
|
||||
parsers["TIMES"] = parse_times
|
||||
|
||||
|
||||
function parse_unit(arg)
|
||||
|
||||
-- check for exponent and remove
|
||||
|
||||
exponent_start = string.find(arg, "%-?%d+$")
|
||||
exponent = nil
|
||||
if exponent_start then
|
||||
exponent = pandoc.Superscript(string.sub(arg, exponent_start))
|
||||
arg = string.sub(arg, 0, exponent_start-1)
|
||||
end
|
||||
|
||||
-- there may be a subscript in the unit, check and remove
|
||||
subscript_start = string.find(arg, "_[a-zA-Z%d]+")
|
||||
|
||||
subscript = nil
|
||||
if subscript_start then
|
||||
subscript = pandoc.Subscript(string.sub(arg, subscript_start+1))
|
||||
arg = string.sub(arg, 0, subscript_start-1)
|
||||
end
|
||||
|
||||
-- if the remaining part is longer than one character, the first character may be a prefix
|
||||
prefix=nil
|
||||
if string.len(arg)>1 then
|
||||
|
||||
if si_prefix[string.sub(arg,0,1)] ~=nil and si_units[arg] == nil then
|
||||
prefix = si_prefix[string.sub(arg,0,1) ]
|
||||
arg = string.sub(arg,2)
|
||||
end
|
||||
end
|
||||
-- check whether the remaining part is a shortcut unit and replace
|
||||
if si_units[arg] ~= nil then
|
||||
arg = si_units[arg]
|
||||
end
|
||||
|
||||
-- assemble
|
||||
outtab = {}
|
||||
|
||||
if prefix then
|
||||
table.insert(outtab, prefix)
|
||||
end
|
||||
table.insert(outtab, arg)
|
||||
if subscript then
|
||||
table.insert(outtab, subscript)
|
||||
end
|
||||
if exponent then
|
||||
table.insert(outtab, exponent)
|
||||
|
||||
end
|
||||
return outtab
|
||||
end
|
||||
|
||||
parsers["UNIT"] = parse_unit
|
||||
|
||||
|
||||
return {
|
||||
['si'] = function(args, kwargs, meta)
|
||||
outtab = {}
|
||||
for idx, arg in ipairs(args) do
|
||||
block_type = identify_block(arg)
|
||||
|
||||
if idx>1 then
|
||||
table.insert(outtab, SPACE)
|
||||
end
|
||||
if block_type then
|
||||
|
||||
outtab=concatenateTables(outtab, parsers[block_type](arg))
|
||||
else
|
||||
table.insert(outtab, arg)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return outtab
|
||||
end
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
title: LaTeX Environment
|
||||
author: Posit Software, PBC
|
||||
version: 1.2.1
|
||||
quarto-required: ">=1.3"
|
||||
contributes:
|
||||
filters:
|
||||
- latex-environment.lua
|
||||
format:
|
||||
pdf: default
|
||||
@@ -0,0 +1,150 @@
|
||||
-- environment.lua
|
||||
-- Copyright (C) 2020 by RStudio, PBC
|
||||
|
||||
local classEnvironments = pandoc.MetaMap({})
|
||||
local classCommands = pandoc.MetaMap({})
|
||||
|
||||
-- helper that identifies arrays
|
||||
local function tisarray(t)
|
||||
local i = 0
|
||||
for _ in pairs(t) do
|
||||
i = i + 1
|
||||
if t[i] == nil then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- reads the environments
|
||||
local function readEnvironments(meta)
|
||||
local env = meta['environments']
|
||||
if env ~= nil then
|
||||
if tisarray(env) then
|
||||
-- read an array of strings
|
||||
for i, v in ipairs(env) do
|
||||
local value = pandoc.utils.stringify(v)
|
||||
classEnvironments[value] = value
|
||||
end
|
||||
else
|
||||
-- read key value pairs
|
||||
for k, v in pairs(env) do
|
||||
local key = pandoc.utils.stringify(k)
|
||||
local value = pandoc.utils.stringify(v)
|
||||
classEnvironments[key] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function readCommands(meta)
|
||||
local env = meta['commands']
|
||||
if env ~= nil then
|
||||
if tisarray(env) then
|
||||
-- read an array of strings
|
||||
for i, v in ipairs(env) do
|
||||
local value = pandoc.utils.stringify(v)
|
||||
classCommands[value] = value
|
||||
end
|
||||
else
|
||||
-- read key value pairs
|
||||
for k, v in pairs(env) do
|
||||
local key = pandoc.utils.stringify(k)
|
||||
local value = pandoc.utils.stringify(v)
|
||||
classCommands[key] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function readEnvsAndCommands(meta)
|
||||
readEnvironments(meta)
|
||||
readCommands(meta)
|
||||
end
|
||||
|
||||
-- use the environments from metadata to
|
||||
-- emit a custom environment for latex
|
||||
local function writeEnvironments(divEl)
|
||||
if quarto.doc.is_format("latex") then
|
||||
for k, v in pairs(classEnvironments) do
|
||||
if divEl.attr.classes:includes(k) then
|
||||
-- process this into a latex environment
|
||||
local beginEnv = '\\begin' .. '{' .. v .. '}'
|
||||
local endEnv = '\n\\end{' .. v .. '}'
|
||||
|
||||
-- check if custom options or arguments are present
|
||||
-- and add them to the environment accordingly
|
||||
local opts = divEl.attr.attributes['options']
|
||||
if opts then
|
||||
beginEnv = beginEnv .. '[' .. opts .. ']'
|
||||
end
|
||||
|
||||
local args = divEl.attr.attributes['arguments']
|
||||
if args then
|
||||
beginEnv = beginEnv .. '{' .. args .. '}'
|
||||
end
|
||||
|
||||
-- if the first and last div blocks are paragraphs then we can
|
||||
-- bring the environment begin/end closer to the content
|
||||
if #divEl.content > 0 and divEl.content[1].t == "Para" and divEl.content[#divEl.content].t == "Para" then
|
||||
table.insert(divEl.content[1].content, 1, pandoc.RawInline('tex', beginEnv .. "\n"))
|
||||
table.insert(divEl.content[#divEl.content].content, pandoc.RawInline('tex', "\n" .. endEnv))
|
||||
else
|
||||
table.insert(divEl.content, 1, pandoc.RawBlock('tex', beginEnv))
|
||||
table.insert(divEl.content, pandoc.RawBlock('tex', endEnv))
|
||||
end
|
||||
return divEl
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function buildCommandArgs(opts, format)
|
||||
local function wrap(o)
|
||||
return string.format(format, o)
|
||||
end
|
||||
local t = pandoc.List()
|
||||
for str in string.gmatch(opts, "([^"..",".."]+)") do
|
||||
t:insert(str)
|
||||
end
|
||||
return table.concat(t:map(wrap), "")
|
||||
end
|
||||
|
||||
-- use the environments from metadata to
|
||||
-- emit a custom environment for latex
|
||||
local function writeCommands(spanEl)
|
||||
if quarto.doc.is_format("latex") then
|
||||
for k, v in pairs(classCommands) do
|
||||
if spanEl.attr.classes:includes(k) then
|
||||
|
||||
-- resolve the begin command
|
||||
local beginCommand = '\\' .. pandoc.utils.stringify(v)
|
||||
local opts = spanEl.attr.attributes['options']
|
||||
local args = spanEl.attr.attributes['arguments']
|
||||
if opts then
|
||||
beginCommand = beginCommand .. buildCommandArgs(opts, "[%s]")
|
||||
end
|
||||
if args then
|
||||
beginCommand = beginCommand .. buildCommandArgs(args, "{%s}")
|
||||
end
|
||||
|
||||
local beginCommandRaw = pandoc.RawInline('latex', beginCommand .. '{')
|
||||
|
||||
-- the end command
|
||||
local endCommandRaw = pandoc.RawInline('latex', '}')
|
||||
|
||||
-- attach the raw inlines to the span contents
|
||||
local result = spanEl.content
|
||||
table.insert(result, 1, beginCommandRaw)
|
||||
table.insert(result, endCommandRaw)
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Run in two passes so we process metadata
|
||||
-- and then process the divs
|
||||
return {
|
||||
{ Meta = readEnvsAndCommands },
|
||||
{ Div = writeEnvironments, Span = writeCommands }
|
||||
}
|
||||
53
_extensions/cours/after-header-includes.latex
Normal file
53
_extensions/cours/after-header-includes.latex
Normal file
@@ -0,0 +1,53 @@
|
||||
%% HEADER AND FOOTER
|
||||
|
||||
\newcommand*\circled[1]{
|
||||
\tikz[baseline=(char.base)]{
|
||||
\node[shape=circle,draw,inner sep=2pt] (char) {#1};
|
||||
}
|
||||
}
|
||||
|
||||
\ohead{}
|
||||
|
||||
% define the page numbering style
|
||||
\pagenumbering{arabic}
|
||||
% clear the defauls page header and footer, so the standard page numbering
|
||||
% \clearpairofpagestyles
|
||||
|
||||
% set my own numbering form for the footer
|
||||
\cfoot*{\thepage\ /\ \pageref{LastPage}}
|
||||
|
||||
\pagestyle{scrheadings}
|
||||
\setkomafont{pagehead}{\normalfont\bfseries}
|
||||
\setkomafont{pagefoot}{\normalfont}
|
||||
|
||||
\RedeclareSectionCommand[
|
||||
beforeskip=1.0\baselineskip,
|
||||
afterskip=0.5\baselineskip,
|
||||
font=\sffamily\bfseries\Large
|
||||
]{section}
|
||||
\renewcommand \thesection{\Roman{section}}
|
||||
\renewcommand*{\sectionformat}{\thesection.\enskip}
|
||||
|
||||
\RedeclareSectionCommand[
|
||||
beforeskip=1.0\baselineskip,
|
||||
afterskip=0.5\baselineskip,
|
||||
font=\sffamily\bfseries\large,
|
||||
indent=2em
|
||||
]{subsection}
|
||||
\renewcommand \thesubsection{\arabic{subsection}}
|
||||
\renewcommand*{\subsectionformat}{\thesubsection)\enskip}
|
||||
|
||||
\RedeclareSectionCommand[
|
||||
beforeskip=1.0\baselineskip,
|
||||
afterskip=0.5\baselineskip,
|
||||
font=\sffamily\bfseries\large,
|
||||
indent=4em
|
||||
]{subsubsection}
|
||||
\renewcommand \thesubsubsection{\alph{subsubsection}}
|
||||
\renewcommand*{\subsubsectionformat}{\circled{\thesubsubsection}\enskip}
|
||||
|
||||
|
||||
|
||||
%% GRAPHICS
|
||||
\graphicspath{{images/}}
|
||||
|
||||
0
_extensions/cours/before-body.tex
Normal file
0
_extensions/cours/before-body.tex
Normal file
@@ -1,73 +1,11 @@
|
||||
%% CAPTION
|
||||
|
||||
\usepackage{caption}
|
||||
\captionsetup{font=small}
|
||||
\captionsetup[figure]{labelfont=bf, textfont=it, name=Document}
|
||||
\captionsetup[table]{labelfont=bf, textfont=it, name=Document}
|
||||
|
||||
|
||||
|
||||
%% TASKS
|
||||
|
||||
\usepackage{tasks}
|
||||
\settasks{
|
||||
label-format = {\bfseries}
|
||||
}
|
||||
|
||||
|
||||
|
||||
%% SIUNITX
|
||||
|
||||
\usepackage[]{siunitx}
|
||||
\sisetup{
|
||||
locale=FR,
|
||||
output-decimal-marker={,},
|
||||
inter-unit-product={\ensuremath{ { } \cdot { } }},
|
||||
math-micro=\text{µ},
|
||||
text-micro=µ,
|
||||
}
|
||||
|
||||
|
||||
|
||||
%% HEADER AND FOOTER
|
||||
|
||||
\usepackage{pageslts}
|
||||
\usepackage[footsepline, plainfootsepline]{scrlayer-scrpage}
|
||||
\pagestyle{scrheadings}
|
||||
\setkomafont{pagehead}{\normalfont\bfseries}
|
||||
\setkomafont{pagefoot}{\normalfont}
|
||||
|
||||
\ohead{}
|
||||
|
||||
\pagenumbering{arabic}
|
||||
% clear the defauls page header and footer, so the standard page numbering
|
||||
% \clearpairofpagestyles
|
||||
|
||||
% set my own numbering form for the footer
|
||||
\cfoot*{\thepage\ /\ \pageref{LastPage}}
|
||||
|
||||
|
||||
|
||||
%% SECTIONS TITLES
|
||||
|
||||
\usepackage{titlesec}
|
||||
\titleformat{\section}[block]
|
||||
{\sffamily\bfseries\Large}
|
||||
{\thesection.}{.5em}{}[]
|
||||
\titleformat{\subsection}[block]
|
||||
{\sffamily\bfseries\large\hspace{2em}}
|
||||
{\thesubsection)}{.5em}{}[]
|
||||
\titleformat{\subsubsection}[block]
|
||||
{\sffamily\bfseries\large\hspace{2em}}
|
||||
{\circled{\thesubsubsection}}{.5em}{}[]
|
||||
\renewcommand \thesection{\Roman{section}}
|
||||
\renewcommand \thesubsection{\arabic{subsection}}
|
||||
\renewcommand \thesubsubsection{\alph{subsubsection}}
|
||||
|
||||
|
||||
|
||||
%% GRAPHICS
|
||||
\graphicspath{{images/}}
|
||||
|
||||
|
||||
%% DYNAMIC TITLE
|
||||
|
||||
$if(type-document.cours)$
|
||||
\rohead*[Cours]{Cours - $subtitle$}
|
||||
$elseif(type-document.exercice)$
|
||||
\rohead*[Exercices]{Exercices - $subtitle$}
|
||||
$elseif(type-document.activite)$
|
||||
\rohead*[Activité]{Activité - $subtitle$}
|
||||
$else$
|
||||
\rohead*{$subtitle$}
|
||||
$endif$
|
||||
11
_extensions/cours/header-setup.tex
Normal file
11
_extensions/cours/header-setup.tex
Normal file
@@ -0,0 +1,11 @@
|
||||
%% DYNAMIC TITLE
|
||||
|
||||
$if(type.cours)$
|
||||
\lohead*{Cours - \@subtitle}
|
||||
$elseif(type.exercice)$
|
||||
\lohead*{Exercices - $subtitle$}
|
||||
$elseif(type.activite)$
|
||||
\lohead*{Activité - $subtitle$}
|
||||
$else$
|
||||
\lohead*{$subtitle$}
|
||||
$endif$
|
||||
@@ -1,4 +1,5 @@
|
||||
% TODO: Add custom LaTeX header directives here
|
||||
%% PACKAGES TO LOAD IN THE HEADER OF THE DOCUMENT
|
||||
|
||||
\usepackage{polyglossia}
|
||||
\setdefaultlanguage{french}
|
||||
\usepackage{luatextra}
|
||||
@@ -11,6 +12,9 @@
|
||||
|
||||
\usepackage{asymptote}
|
||||
\usepackage{mathrsfs}
|
||||
\usepackage{tkz-base}
|
||||
\usepackage{tkz-euclide}
|
||||
\usetikzlibrary{arrows, calc, patterns, positioning, shapes.geometric, shadows, snakes, tikzmark}
|
||||
|
||||
\usepackage{array}
|
||||
\usepackage{tabularray}
|
||||
@@ -44,6 +48,12 @@
|
||||
\usepackage[]{hyperref}
|
||||
\usepackage{chngcntr}
|
||||
|
||||
\usepackage{pageslts}
|
||||
\usepackage[footsepline, plainfootsepline]{scrlayer-scrpage}
|
||||
|
||||
\usepackage{tabularray}
|
||||
|
||||
\usepackage{lipsum}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
%% TITLE
|
||||
|
||||
%\usepackage{titling}
|
||||
$if(title)$
|
||||
\title{$title$}
|
||||
$endif$
|
||||
@@ -16,3 +15,4 @@ $endif$
|
||||
$if(date)$
|
||||
\date{$date$}
|
||||
$endif$
|
||||
|
||||
|
||||
BIN
template.pdf
BIN
template.pdf
Binary file not shown.
29
template.qmd
29
template.qmd
@@ -1,8 +1,9 @@
|
||||
---
|
||||
title: "Cours avec Quarto"
|
||||
subtitle: "Sous-titre"
|
||||
format:
|
||||
cours-pdf: default
|
||||
title: "Template Quarto"
|
||||
subtitle: "pour mes documents"
|
||||
type-document:
|
||||
cours: true
|
||||
format: cours-pdf
|
||||
author: Jeff LANCE
|
||||
date: last-modified
|
||||
---
|
||||
@@ -10,7 +11,7 @@ date: last-modified
|
||||
# Introduction
|
||||
|
||||
Cette extension est un template pour mes documents de cours.\
|
||||
Elle est basée sur ma classe $\LaTeX$ ``latex-homework/jl-cours``.
|
||||
Elle est basée sur ma classe $\LaTeX$ `latex-homework/jl-cours`.
|
||||
|
||||
Ce document est un exemple d'usage de ce template.
|
||||
|
||||
@@ -22,7 +23,23 @@ Ce document est un exemple d'usage de ce template.
|
||||
|
||||
\lipsum[1]
|
||||
|
||||
## More Information
|
||||
### Une sous-sous-section
|
||||
|
||||
\lipsum[1]
|
||||
|
||||
# Tableaux avec ``tabularray``
|
||||
|
||||
\begin{center}
|
||||
\begin{tblr}{
|
||||
colspec={Q[red9,l]cccQ[green9,r]},
|
||||
hlines, vlines
|
||||
}
|
||||
cell 1-1 & cell 1-2 & cell 1-3 & cell 1-4 & cell 1-5 \\
|
||||
cell 2-1 & cell 2-2 & cell 2-3 & cell 2-4 & cell 2-5
|
||||
\end{tblr}
|
||||
\end{center}
|
||||
|
||||
# More Information
|
||||
|
||||
You can learn more about controlling the appearance of PDF output here: <https://quarto.org/docs/output-formats/pdf-basics.html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user