Skip to content

Commit 370658e

Browse files
DesimentLeonidElkingithub-actions[bot]
authored
feat: new configuration system (#14)
* feat: new configuration system * fix: now workflow update submodules * chore: update generated PDF from CI --------- Co-authored-by: LeonidElkin <yolkinleonwork@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent a9b521e commit 370658e

35 files changed

+391
-953
lines changed

.github/workflows/latex.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
with:
2020
ref: ${{ github.head_ref }}
2121
persist-credentials: true
22+
submodules: recursive
23+
fetch-depth: 0
2224

2325
- name: Compile LaTeX
2426
uses: xu-cheng/latex-action@v4

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "configuration"]
2+
path = configuration
3+
url = https://github.com/Desiment/desiment-latex-preamble

.latexmkrc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
ensure_path( 'TEXINPUTS', './configuration/' );
1+
ensure_path( 'TEXINPUTS', 'configuration' );
2+
ensure_path( 'TEXINPUTS', 'configuration/packages//');
3+
ensure_path( 'LUAINPUTS', 'configuration' );
24
$pdf_mode=4;
35
$lualatex = 'lualatex %O -halt-on-error -synctex=1 --shell-escape %S';
46
$out_dir = '.';
@@ -23,7 +25,7 @@ sub mmz_analyze {
2325
my $base = $$Pbase;
2426
my $mmz_file = "$aux_dir1$base.mmz";
2527
$mmz_has_new = '';
26-
28+
2729
if (! -e $mmz_file) {
2830
print "mmz_analyze: No mmz file '$mmz_file', so memoize is not being used.\n";
2931
return 0;
@@ -46,7 +48,7 @@ sub mmz_analyze {
4648
s/\s*$//; # Remove trailing space, including new lines
4749
if ( /^\\mmzNewExtern\s+{([^}]+)}/ ) {
4850
# We have a new memo item without a corresponding pdf file.
49-
# It will be put in the aux directory.
51+
# It will be put in the aux directory.
5052
my $file = "$aux_dir1$1";
5153
print "mmz_analyze: new extern for memoize: '$file'\n";
5254
push @externs, $file;
@@ -64,11 +66,11 @@ sub mmz_analyze {
6466
close $mmz_fh;
6567
foreach (@dirs) {
6668
if ( ! -e ) {
67-
my @cmd = ( @memoize_extract, '--mkdir', $_ );
69+
my @cmd = ( @memoize_extract, '--mkdir', $_ );
6870
print "mmz_analyze: Making directory '$_' safely by running\n",
6971
" @cmd\n";
7072
mkdir $_;
71-
}
73+
}
7274
}
7375

7476
rdb_ensure_files_here( @externs );
@@ -77,7 +79,7 @@ sub mmz_analyze {
7779
if (@externs ) {
7880
$mmz_has_new = $mmz_file;
7981
}
80-
return 0;
82+
return 0;
8183
}
8284

8385
#-----------------------------------------------------
@@ -94,7 +96,7 @@ sub mmz_extract_new {
9496
print "mmz_extract_new : ENV{$_} = '$ENV{$_}'\n";
9597
}
9698
my @cmd = (@memoize_extract, '--format', 'latex',
97-
'--pdf', $pdf_file, $mmz_file_no_path );
99+
'--pdf', $pdf_file, $mmz_file_no_path );
98100

99101
if ( ! -e $pdf_file ) {
100102
warn "mmz_extract_new: Cannot generate externs here, since no pdf file generated\n";
@@ -116,7 +118,7 @@ sub mmz_cleanup {
116118
use strict;
117119
print "============= I am mmz_cleanup \n";
118120
my @cmd = ( @memoize_clean, '--all', '--yes',
119-
'--prefix', $aux_dir,
121+
'--prefix', $aux_dir,
120122
"$aux_dir1$$Pbase.mmz" );
121123
print "mmz_cleanup: Running\n @cmd\n";
122124
my $ret = system @cmd;
@@ -125,4 +127,3 @@ sub mmz_cleanup {
125127
}
126128

127129
#-----------------------------------------------------
128-

configuration

Submodule configuration added at e8a7e2d

configuration.lua

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
--- Configuration module for LuaLaTeX document
2+
--
3+
-- This module provides a centralized configuration system for LaTeX document settings,
4+
-- asset management, references, and typesetting options. The configuration can be
5+
-- overridden by a user-specific configuration file in the repository root.
6+
--
7+
-- @module configuration
8+
-- @return Configuration table
9+
10+
local configuration = {}
11+
12+
-- Build system configuration
13+
-- Controls output directories and build artifacts
14+
configuration.build = {
15+
-- Directory for intermediate build files (aux, log, etc.)
16+
dir = 'build/',
17+
-- Directory for final output files (PDFs)
18+
out = 'pdf/'
19+
}
20+
21+
-- Asset management configuration
22+
-- Controls how external assets (images, tables, etc.) are handled
23+
configuration.assets = {
24+
-- Root directory for all assets
25+
root = 'assets/',
26+
-- Enable custom LaTeX macros for quick insertion of figures/tables/etc.
27+
shortcuts = true,
28+
-- Enable externalization of assets (caching processed versions)
29+
-- For externalization 'memoize' package is used. Note that this
30+
-- requires quite modern LaTeX version, as well as some external
31+
--- dependicies, like Perl and PDF::API2 library
32+
externalize = true,
33+
-- Asset type configurations:
34+
-- 'keep' - memoize puts files in the same directory as source
35+
-- 'build' - memoize puts files into build directory
36+
-- 'none' - disable memoization for this asset type
37+
dirs = {
38+
images = { path = 'images/', extern = 'keep' }, -- Raster/vector images
39+
tables = { path = 'tables/', extern = 'build' }, -- Data tables, CSV files
40+
diagrams = { path = 'diagrams/', extern = 'keep' }, -- Diagram source files
41+
listings = { path = 'listings/', extern = 'keep' } -- Code listings
42+
}
43+
}
44+
45+
-- References and bibliography configuration
46+
-- Manages citations, indexes, and knowledge graphs
47+
configuration.references = {
48+
enable = true,
49+
--- Tooling for references
50+
hyperref = {
51+
shortref = {
52+
{csname = 'picref', reftext = 'рис.'},
53+
{csname = 'tabref', reftext = 'табл.'},
54+
{csname = 'lstref', reftext = 'листинг'},
55+
{csname = 'digref', reftext = 'диаг.'},
56+
{csname = 'secref', reftext = 'разд.'}
57+
},
58+
hypersetup = {
59+
breaklinks=true,
60+
hyperindex=true,
61+
colorlinks=true,
62+
hidelinks=false,
63+
hypertexnames='false', --- fix, cause right now false boolean filds are ignored
64+
unicode=true,
65+
pdfauthor={'Unknown Author'},
66+
pdfsubject={'Document Subject'},
67+
pdfkeywords={'keyword1, keyword2'},
68+
pdftitle={'Document Title'},
69+
bookmarksopen=false,
70+
linktocpage=true,
71+
plainpages=false,
72+
pdfpagelabels=true,
73+
-- Link colors
74+
urlcolor='blue',
75+
linkcolor='red',
76+
filecolor='red',
77+
citecolor='blue'
78+
}
79+
},
80+
-- Bibliography sources configuration
81+
bibtex = {
82+
-- Base path for bibliography files
83+
path = 'assets/bibliography',
84+
style = 'numeric',
85+
-- List of bibliography databases with display names
86+
bibliographies = {
87+
{
88+
name = 'main', -- Main literature bibliography
89+
title = 'Список литературы', -- Main literature bibliography
90+
files = 'main.bib',
91+
},
92+
-- {
93+
-- name = 'git', -- Software/online sources
94+
-- title = 'Репозитории, трекеры, обсуждения', -- Software/online sources
95+
-- files = { 'repos.bib', 'issues.bib' },
96+
-- }
97+
}
98+
},
99+
-- Index generation configuration (imakeidx package)
100+
indexes = {
101+
-- Enable index generation
102+
enable = true,
103+
-- imakeidx options
104+
build = {'makeindex'},
105+
-- Configure individual indexes
106+
list = {
107+
-- Symbol index
108+
{
109+
name = 'notation',
110+
title = 'Список обозначений',
111+
intoc = true,
112+
--columns = 2,
113+
--columnsep = '15pt',
114+
--columnseprule = true,
115+
},
116+
-- Main subject index
117+
{
118+
name = nil,
119+
title = 'Предметный указатель',
120+
intoc = true,
121+
}
122+
}
123+
},
124+
-- Knowledge configuration (knowledge package)
125+
-- knowledge = {
126+
-- Enable knowledge graph functionality
127+
-- enable = true,
128+
-- Configuration file for knowledge package
129+
-- config = '.knowledgerc.tex'
130+
-- }
131+
}
132+
133+
-- Float environment configuration
134+
-- Controls figures, tables, listings, and other floating elements
135+
configuration.floats = {
136+
-- Enable plugin for handling macroses
137+
enable = true,
138+
-- Graphics scaling and sizing options
139+
images = {
140+
-- Enable quiver package for commutative diagrams
141+
quiver = 'enabled', -- alternative is 'draft' or 'disabled'
142+
-- TODO: Enable drawio package for draw.io diagram integration
143+
-- drawio = 'enabled', -- alternative is 'draft' or 'disabled'
144+
145+
-- Default caption position
146+
caption = 'below',
147+
-- Default width ratio to \linewidth for regular figures (0.0-1.0)
148+
figurewidth = 0.9,
149+
-- Default width ratio for wrapfigure environments (0.0-1.0)
150+
wrapfigurewidth = 0.4,
151+
--- Whether or not create separate list of figures
152+
makeidx = true,
153+
},
154+
tables = {
155+
enables = true,
156+
caption = 'above',
157+
makeidx = true,
158+
},
159+
-- Code listing configuration
160+
listing = {
161+
-- Enable listing environment support
162+
enable = true,
163+
caption = 'above',
164+
-- Enable syntax highlighting via pygmentize
165+
pygmentize = true,
166+
makeidx = true,
167+
},
168+
-- Caption and labeling configuration
169+
captions = {
170+
-- Language for automatic captions (e.g., "Figure", "Table")
171+
lang = 'ru',
172+
}
173+
}
174+
175+
-- Typesetting and text macros configuration
176+
-- Controls custom text formatting, shortcuts, and theorem environments
177+
configuration.typesetting = {
178+
-- Enable custom typesetting macros
179+
enable = true,
180+
181+
-- Text shortcut configuration
182+
shortcuts = true,
183+
184+
-- Formatting features
185+
formatting = {
186+
todo = true,
187+
ulem = true,
188+
},
189+
-- Theorem and proof environment configuration
190+
theorems = {
191+
-- Enable theorem-like environments (theorem, lemma, proof, etc.)
192+
enable = true,
193+
--- Theorem naming style
194+
--- plain:
195+
--- theorem - numbered theorem
196+
--- theorem* - unnumbered theorem
197+
--- framed:
198+
--- Theorem - numbered theorem, framed
199+
--- Theorem* - unnumbered theorem, framed
200+
--- theorem - numbered theorem, not framed
201+
--- theorem* - unnumbered theorem, not framed
202+
thmstyle = 'framed',
203+
enviroments = {
204+
{envname = 'theorem', name = 'Теорема'},
205+
{envname = 'lemma', name = 'Лемма'},
206+
{envname = 'proposition', name = 'Предложение'},
207+
{envname = 'definition', name = 'Определение'},
208+
{envname = 'remark', name = 'Замечание'},
209+
210+
}
211+
}
212+
}
213+
214+
-- Mathematical typesetting configuration
215+
-- Controls math macros, symbols, and specialized notation
216+
configuration.mathematics = {
217+
-- Enable mathematical typesetting macros
218+
enable = true,
219+
mathcommand = 'error',
220+
-- Mathematical domain-specific plugin configuration
221+
plugins = {
222+
-- Algebra plugin: groups, rings, fields, linear algebra
223+
algebra = {
224+
enable = true, -- Enable algebra macros
225+
--knowledgify = true, -- Generate knowledge graph entries
226+
--indexify = false, -- Add to index automatically
227+
},
228+
-- Calculus plugin: limits, derivatives, integrals
229+
calculus = {
230+
enable = true,
231+
--knowledgify = true,
232+
--indexify = false
233+
},
234+
-- Combinatorics plugin: combinations, permutations, graphs
235+
combinatorics = {
236+
enable = true,
237+
--knowledgify = true,
238+
--indexify = false
239+
},
240+
-- Probability plugin: distributions, expectations, random variables
241+
probability = {
242+
enable = true,
243+
--knowledgify = true,
244+
--indexify = false,
245+
},
246+
-- Foundations plugin: set theory, logic, category theory
247+
foundations = {
248+
enable = true,
249+
--knowledgify = true,
250+
--indexify = false
251+
},
252+
-- Complexity plugin: Big-O notation, complexity classes
253+
complexity = {
254+
enable = false -- Disabled by default
255+
}
256+
}
257+
}
258+
259+
return configuration

0 commit comments

Comments
 (0)