From 6d44c638512eb736c41551c5887b4475a14935bf Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 15 Sep 2022 03:15:34 +0000 Subject: CTAN sync 202209150315 --- macros/jptex/latex/jsclasses/LICENSE | 2 +- macros/jptex/latex/jsclasses/README.md | 2 +- macros/jptex/latex/jsclasses/jsclasses.dtx | 33 +- macros/jptex/latex/jsclasses/jsclasses.pdf | Bin 412473 -> 426004 bytes macros/jptex/latex/jsclasses/jslogo.dtx | 5 +- macros/jptex/latex/jsclasses/jslogo.pdf | Bin 76779 -> 78734 bytes macros/jptex/latex/jsclasses/jsverb.dtx | 3 +- macros/jptex/latex/jsclasses/jsverb.pdf | Bin 75649 -> 77479 bytes macros/jptex/latex/jsclasses/okumacro.dtx | 3 +- macros/jptex/latex/jsclasses/okumacro.pdf | Bin 175557 -> 180851 bytes macros/jptex/latex/jsclasses/okuverb.dtx | 3 +- macros/jptex/latex/jsclasses/okuverb.pdf | Bin 59902 -> 61261 bytes macros/latex/contrib/asmeconf/README.md | 9 +- .../latex/contrib/asmeconf/asmeconf-template.pdf | Bin 271758 -> 599902 bytes .../latex/contrib/asmeconf/asmeconf-template.tex | 22 +- macros/latex/contrib/asmeconf/asmeconf.bst | 19 +- macros/latex/contrib/asmeconf/asmeconf.cls | 20 +- .../asmeconf-template-widetext.pdf | Bin 2930107 -> 2930072 bytes .../asmeconf-template-widetext.tex | 10 +- .../themes/beamertheme-tcolorbox/README.md | 2 +- .../beamerinnerthemetcolorbox.sty | 171 +++-- .../beamertheme-tcolorbox-doc.pdf | Bin 181132 -> 177229 bytes .../beamertheme-tcolorbox-doc.tex | 48 +- macros/latex/contrib/beamer/CHANGELOG.md | 13 +- macros/latex/contrib/beamer/base/beamer.cls | 2 +- macros/latex/contrib/beamer/base/beamerarticle.sty | 2 +- .../latex/contrib/beamer/base/beamerbaseboxes.sty | 2 +- .../contrib/beamer/base/beamerbaseframesize.sty | 21 +- .../contrib/beamer/base/beamerbasenavigation.sty | 18 +- .../base/themes/color/beamercolorthemedefault.sty | 1 + .../base/themes/outer/beamerouterthemedefault.sty | 10 +- .../base/themes/outer/beamerouterthemeshadow.sty | 2 +- .../beamer/doc/beamerexample-conference-talk.pdf | Bin 343911 -> 343911 bytes .../doc/beamerexample-lecture-beamer-version.pdf | Bin 547609 -> 547609 bytes .../doc/beamerexample-lecture-print-version.pdf | Bin 441714 -> 441714 bytes .../contrib/beamer/doc/beamerug-introduction.tex | 2 +- .../contrib/beamer/doc/beamerug-localstructure.tex | 12 + .../latex/contrib/beamer/doc/beamerug-overlays.tex | 6 +- .../latex/contrib/beamer/doc/beameruserguide.pdf | Bin 2251679 -> 2219543 bytes .../latex/contrib/beamer/doc/beameruserguide.tex | 4 +- macros/latex/contrib/csquotes/csq-compat.def | 2 +- macros/latex/contrib/csquotes/csquotes.def | 2 +- macros/latex/contrib/csquotes/csquotes.pdf | Bin 304739 -> 304934 bytes macros/latex/contrib/csquotes/csquotes.sty | 12 +- macros/latex/contrib/csquotes/csquotes.tex | 8 +- macros/latex/contrib/fixdif/fixdif-zh-cn.pdf | Bin 163015 -> 163097 bytes macros/latex/contrib/fixdif/fixdif-zh-cn.tex | 8 +- macros/latex/contrib/fixdif/fixdif.dtx | 8 +- macros/latex/contrib/fixdif/fixdif.pdf | Bin 97323 -> 97323 bytes macros/latex/contrib/stex/doc/Makefile | 2 +- macros/latex/contrib/stex/doc/img/vsc1.png | Bin 0 -> 25993 bytes macros/latex/contrib/stex/doc/img/vsc2.png | Bin 0 -> 54764 bytes macros/latex/contrib/stex/doc/img/vsc3.png | Bin 0 -> 49418 bytes .../stex/doc/packages/stex-document-structure.tex | 26 +- .../contrib/stex/doc/packages/stex-features.tex | 12 +- .../contrib/stex/doc/packages/stex-hwexam.tex | 60 +- .../contrib/stex/doc/packages/stex-idesetup.tex | 61 ++ .../contrib/stex/doc/packages/stex-mathhub.tex | 2 +- .../stex/doc/packages/stex-mathhubsetup.tex | 25 + .../contrib/stex/doc/packages/stex-notesslides.tex | 243 +++++++ .../contrib/stex/doc/packages/stex-problem.tex | 97 ++- .../contrib/stex/doc/packages/stex-proofs.tex | 425 +++++++---- .../contrib/stex/doc/packages/stex-references.tex | 90 ++- .../latex/contrib/stex/doc/packages/stex-setup.tex | 34 + .../contrib/stex/doc/packages/stex-slides.tex | 212 ------ .../contrib/stex/doc/packages/stex-symbols.tex | 8 +- macros/latex/contrib/stex/doc/stex-doc.pdf | Bin 1645539 -> 1802605 bytes macros/latex/contrib/stex/doc/stex-doc.tex | 9 +- macros/latex/contrib/stex/doc/stex-docheader.tex | 101 +-- macros/latex/contrib/stex/doc/stex-ide.pdf | Bin 0 -> 378968 bytes macros/latex/contrib/stex/doc/stex-ide.tex | 155 ++++ macros/latex/contrib/stex/doc/stex-manual.pdf | Bin 983933 -> 1121031 bytes macros/latex/contrib/stex/doc/stex-manual.tex | 154 ++-- macros/latex/contrib/stex/doc/stex-tutorial.tex | 2 +- .../stex/source/extensions/document-structure.dtx | 20 +- .../contrib/stex/source/extensions/hwexam.dtx | 51 +- .../contrib/stex/source/extensions/notesslides.dtx | 141 ++-- .../contrib/stex/source/extensions/problem.dtx | 167 +++-- .../contrib/stex/source/extensions/tikzinput.dtx | 19 +- .../latex/contrib/stex/source/stex/stex-basics.dtx | 29 +- .../contrib/stex/source/stex/stex-features.dtx | 66 +- .../contrib/stex/source/stex/stex-inheritance.dtx | 11 +- .../contrib/stex/source/stex/stex-mathhub.dtx | 19 +- .../contrib/stex/source/stex/stex-metatheory.dtx | 2 +- .../contrib/stex/source/stex/stex-modules.dtx | 16 +- .../latex/contrib/stex/source/stex/stex-others.dtx | 4 +- .../latex/contrib/stex/source/stex/stex-proofs.dtx | 578 +++++---------- .../contrib/stex/source/stex/stex-references.dtx | 573 ++++++++++----- .../contrib/stex/source/stex/stex-statements.dtx | 6 +- .../contrib/stex/source/stex/stex-symbols.dtx | 209 +++++- .../latex/contrib/stex/source/stex/stex-terms.dtx | 182 ++++- .../contrib/stex/tex/etc/beamernotesthemesTeX.sty | 14 - .../latex/contrib/stex/tex/etc/beamerthemesTeX.sty | 94 ++- .../contrib/stex/tex/etc/stex-backend-pdflatex.cfg | 2 + .../contrib/stex/tex/etc/stex-backend-rustex.cfg | 10 + .../contrib/stex/tex/etc/stex-backend-tex4ht.cfg | 13 + macros/latex/contrib/stex/tex/etc/stexthm.sty | 69 +- .../latex/contrib/stex/tex/ldf/problem-ngerman.ldf | 2 + macros/luatex/latex/luatruthtable/README.txt | 9 + .../luatex/latex/luatruthtable/luatruthtable.bib | 20 + .../luatex/latex/luatruthtable/luatruthtable.pdf | Bin 0 -> 119179 bytes .../luatex/latex/luatruthtable/luatruthtable.sty | 286 ++++++++ .../luatex/latex/luatruthtable/luatruthtable.tex | 358 +++++++++ macros/luatex/latex/piton/README.md | 26 + macros/luatex/latex/piton/piton-french.pdf | Bin 0 -> 151124 bytes macros/luatex/latex/piton/piton-french.tex | 361 +++++++++ macros/luatex/latex/piton/piton.dtx | 810 +++++++++++++++++++++ macros/luatex/latex/piton/piton.ins | 47 ++ macros/luatex/latex/piton/piton.lua | 473 ++++++++++++ macros/luatex/latex/piton/piton.pdf | Bin 0 -> 223287 bytes 110 files changed, 5225 insertions(+), 1667 deletions(-) create mode 100644 macros/latex/contrib/stex/doc/img/vsc1.png create mode 100644 macros/latex/contrib/stex/doc/img/vsc2.png create mode 100644 macros/latex/contrib/stex/doc/img/vsc3.png create mode 100644 macros/latex/contrib/stex/doc/packages/stex-idesetup.tex create mode 100644 macros/latex/contrib/stex/doc/packages/stex-mathhubsetup.tex create mode 100644 macros/latex/contrib/stex/doc/packages/stex-notesslides.tex create mode 100644 macros/latex/contrib/stex/doc/packages/stex-setup.tex delete mode 100644 macros/latex/contrib/stex/doc/packages/stex-slides.tex create mode 100644 macros/latex/contrib/stex/doc/stex-ide.pdf create mode 100644 macros/latex/contrib/stex/doc/stex-ide.tex delete mode 100644 macros/latex/contrib/stex/tex/etc/beamernotesthemesTeX.sty create mode 100644 macros/latex/contrib/stex/tex/etc/stex-backend-tex4ht.cfg create mode 100644 macros/luatex/latex/luatruthtable/README.txt create mode 100644 macros/luatex/latex/luatruthtable/luatruthtable.bib create mode 100644 macros/luatex/latex/luatruthtable/luatruthtable.pdf create mode 100644 macros/luatex/latex/luatruthtable/luatruthtable.sty create mode 100644 macros/luatex/latex/luatruthtable/luatruthtable.tex create mode 100644 macros/luatex/latex/piton/README.md create mode 100644 macros/luatex/latex/piton/piton-french.pdf create mode 100644 macros/luatex/latex/piton/piton-french.tex create mode 100644 macros/luatex/latex/piton/piton.dtx create mode 100644 macros/luatex/latex/piton/piton.ins create mode 100644 macros/luatex/latex/piton/piton.lua create mode 100644 macros/luatex/latex/piton/piton.pdf (limited to 'macros') diff --git a/macros/jptex/latex/jsclasses/LICENSE b/macros/jptex/latex/jsclasses/LICENSE index 1f8bc0f533..7d331ec015 100644 --- a/macros/jptex/latex/jsclasses/LICENSE +++ b/macros/jptex/latex/jsclasses/LICENSE @@ -1,6 +1,6 @@ Copyright 1995-1999 ASCII MEDIA WORKS Copyright 1999-2016 Haruhiko Okumura -Copyright 2016-2020 Japanese TeX Development Community +Copyright 2016-2022 Japanese TeX Development Community All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/macros/jptex/latex/jsclasses/README.md b/macros/jptex/latex/jsclasses/README.md index 284efa7815..da6539d7bd 100644 --- a/macros/jptex/latex/jsclasses/README.md +++ b/macros/jptex/latex/jsclasses/README.md @@ -37,7 +37,7 @@ distributed separately. ## Release Date -2021-07-01 +2022-09-13 Haruhiko Okumura, Japanese TeX Development Community diff --git a/macros/jptex/latex/jsclasses/jsclasses.dtx b/macros/jptex/latex/jsclasses/jsclasses.dtx index 37567b64d9..39c85dcabe 100644 --- a/macros/jptex/latex/jsclasses/jsclasses.dtx +++ b/macros/jptex/latex/jsclasses/jsclasses.dtx @@ -9,13 +9,13 @@ % pLaTeX2ε新ドキュメントクラス(日本語 TeX 開発コミュニティ版) % 原作者:奥村晴彦 % -% Copyright 1993-2021 +% Copyright 1993-2022 % The LaTeX3 Project and any individual authors listed elsewhere % in this file. % % Copyright 1995-1999 ASCII Corporation. % Copyright 1999-2016 Haruhiko Okumura -% Copyright 2016-2021 Japanese TeX Development Community +% Copyright 2016-2022 Japanese TeX Development Community % % \fi % @@ -32,9 +32,10 @@ %<*driver> \ProvidesFile{jsclasses.dtx} % - [2021/06/28 jsclasses (okumura, texjporg)] + [2022/09/13 jsclasses (okumura, texjporg)] %<*driver> -\documentclass{jsarticle} +\RequirePackage{plautopatch} +\documentclass[dvipdfmx]{jsarticle} \usepackage{doc} \xspcode"5C=1 %% \ \xspcode"22=1 %% " @@ -481,10 +482,14 @@ % ようですので,少し小さくします。 % また,中央の要素も |\displaystyle| にします。 % +% [2022-09-13] \LaTeXe~2021-11-15 (ltmath.dtx 2021/10/14 v1.2j)で +% |\@currentcounter|が追加されましたので,追随します。 +% % \begin{macrocode} \def\eqnarray{% \stepcounter{equation}% \def\@currentlabel{\p@equation\theequation}% + \def\@currentcounter{equation}% \global\@eqnswtrue \m@th \global\@eqcnt\z@ @@ -504,6 +509,9 @@ % \texttt{fleqn} で数式が本文左端から一定距離のところに出力されます。 % 森本さんにしたがって訂正しました。 % +% [2022-09-13] \LaTeXe~2021-11-15 (ltmath.dtx 2021/10/14 v1.2j)で +% |\@currentcounter|が追加されましたので,追随します。 +% % \begin{macrocode} \DeclareOption{leqno}{\input{leqno.clo}} \DeclareOption{fleqn}{\input{fleqn.clo}% @@ -511,6 +519,7 @@ \def\eqnarray{% \stepcounter{equation}% \def\@currentlabel{\p@equation\theequation}% + \def\@currentcounter{equation}% \global\@eqnswtrue\m@th \global\@eqcnt\z@ \tabskip\mathindent @@ -771,9 +780,15 @@ % 発行する |\special| の中身を展開しておくようにしました。 % こうしないと,用紙サイズ設定を間違ってしまいます(Issue \#72)。 % +% [2022-09-12] 次期\LaTeXe カーネルに|\stockwidth|,|\stockheight|が +% 追加されるようですので, +% クラスファイル側では未定義のときのみこれらの長さ変数を定義します。 +% h20y6mさん,ありがとうございます。 +% % \begin{macrocode} \iftombow - \newdimen\stockwidth \newdimen\stockheight + \ifx\stockwidth\@undefined\newdimen\stockwidth\fi + \ifx\stockheight\@undefined\newdimen\stockheight\fi \setlength{\stockwidth}{\paperwidth} \setlength{\stockheight}{\paperheight} \advance \stockwidth 2in @@ -5589,6 +5604,13 @@ % % [2018-03-11] |\next|などいくつかの内部命令を |\jsc@...| 付きの % ユニークな名前にしました。 +% +% [2022-09-13] \LaTeXe~2021-11-15 (ltfloat.dtx 2021/10/14 v1.2g)で +% |\@currentcounter|が追加されましたので,追随します。 +% なお,\LaTeXe~2021-06-01 (ltfloat.dtx 2021/02/10 v1.2e)で +% parhook対応として\cs{par}が追加されていますが, +% 実は同時に\cs{color@endgroup}も\cs{endgraf}するように変更 +% されていますので,不要だと思います。というわけで追加しません。 % \begin{macrocode} \long\def\@footnotetext{% \insert\footins\bgroup @@ -5597,6 +5619,7 @@ \splittopskip\footnotesep \splitmaxdepth \dp\strutbox \floatingpenalty \@MM \hsize\columnwidth \@parboxrestore + \def\@currentcounter{footnote}% \protected@edef\@currentlabel{% \csname p@footnote\endcsname\@thefnmark }% diff --git a/macros/jptex/latex/jsclasses/jsclasses.pdf b/macros/jptex/latex/jsclasses/jsclasses.pdf index f41951d9e6..3a3f56fe36 100644 Binary files a/macros/jptex/latex/jsclasses/jsclasses.pdf and b/macros/jptex/latex/jsclasses/jsclasses.pdf differ diff --git a/macros/jptex/latex/jsclasses/jslogo.dtx b/macros/jptex/latex/jsclasses/jslogo.dtx index e8350bdb61..dc058e5ff4 100644 --- a/macros/jptex/latex/jsclasses/jslogo.dtx +++ b/macros/jptex/latex/jsclasses/jslogo.dtx @@ -15,7 +15,7 @@ % LaTeX 関連のロゴ(pLaTeX2ε新ドキュメントクラス付録) % % Copyright 1999-2016 Haruhiko Okumura -% Copyright 2016-2019 Japanese TeX Development Community +% Copyright 2016-2022 Japanese TeX Development Community % % \fi % @@ -29,7 +29,8 @@ % [2019/07/25 okumura, texjporg] %<*driver> -\documentclass{jsarticle} +\RequirePackage{plautopatch} +\documentclass[dvipdfmx]{jsarticle} \usepackage{doc} \xspcode"5C=1 %% \ \xspcode"22=1 %% " diff --git a/macros/jptex/latex/jsclasses/jslogo.pdf b/macros/jptex/latex/jsclasses/jslogo.pdf index 6975d75515..d46e75216a 100644 Binary files a/macros/jptex/latex/jsclasses/jslogo.pdf and b/macros/jptex/latex/jsclasses/jslogo.pdf differ diff --git a/macros/jptex/latex/jsclasses/jsverb.dtx b/macros/jptex/latex/jsclasses/jsverb.dtx index ed6fefde63..a62afba435 100644 --- a/macros/jptex/latex/jsclasses/jsverb.dtx +++ b/macros/jptex/latex/jsclasses/jsverb.dtx @@ -22,7 +22,8 @@ %\NeedsTeXFormat{pLaTeX2e} %\ProvidesFile{jsverb.sty}[2007/01/28 okumura] %<*driver> -\documentclass{jsarticle} +\RequirePackage{plautopatch} +\documentclass[dvipdfmx]{jsarticle} \usepackage{doc} \xspcode"5C=1 %% \ \xspcode"22=1 %% " diff --git a/macros/jptex/latex/jsclasses/jsverb.pdf b/macros/jptex/latex/jsclasses/jsverb.pdf index a2273084a5..6b323f735b 100644 Binary files a/macros/jptex/latex/jsclasses/jsverb.pdf and b/macros/jptex/latex/jsclasses/jsverb.pdf differ diff --git a/macros/jptex/latex/jsclasses/okumacro.dtx b/macros/jptex/latex/jsclasses/okumacro.dtx index e2d70e4770..9f20aaf31a 100644 --- a/macros/jptex/latex/jsclasses/okumacro.dtx +++ b/macros/jptex/latex/jsclasses/okumacro.dtx @@ -14,7 +14,8 @@ %\NeedsTeXFormat{pLaTeX2e} %\ProvidesPackage{okumacro}[2021/07/01 okumura, texjporg] %<*driver> -\documentclass{jsarticle} +\RequirePackage{plautopatch} +\documentclass[dvipdfmx]{jsarticle} \usepackage{doc} \xspcode"5C=1 %% \ \xspcode"22=1 %% " diff --git a/macros/jptex/latex/jsclasses/okumacro.pdf b/macros/jptex/latex/jsclasses/okumacro.pdf index d01f531572..26cd6c2985 100644 Binary files a/macros/jptex/latex/jsclasses/okumacro.pdf and b/macros/jptex/latex/jsclasses/okumacro.pdf differ diff --git a/macros/jptex/latex/jsclasses/okuverb.dtx b/macros/jptex/latex/jsclasses/okuverb.dtx index b6cc0256ec..3694217245 100644 --- a/macros/jptex/latex/jsclasses/okuverb.dtx +++ b/macros/jptex/latex/jsclasses/okuverb.dtx @@ -20,7 +20,8 @@ %\NeedsTeXFormat{pLaTeX2e} %\ProvidesFile{okuverb.sty}[2003/09/03 okumura] %<*driver> -\documentclass{jsarticle} +\RequirePackage{plautopatch} +\documentclass[dvipdfmx]{jsarticle} \usepackage{doc} \xspcode"5C=1 %% \ \xspcode"22=1 %% " diff --git a/macros/jptex/latex/jsclasses/okuverb.pdf b/macros/jptex/latex/jsclasses/okuverb.pdf index b8014b3c66..c0703b0c80 100644 Binary files a/macros/jptex/latex/jsclasses/okuverb.pdf and b/macros/jptex/latex/jsclasses/okuverb.pdf differ diff --git a/macros/latex/contrib/asmeconf/README.md b/macros/latex/contrib/asmeconf/README.md index e140c90277..ed1fece635 100644 --- a/macros/latex/contrib/asmeconf/README.md +++ b/macros/latex/contrib/asmeconf/README.md @@ -1,7 +1,7 @@ #asmeconf: A latex template for ASME conference papers# - Version 1.31 dated 2022/07/04. + Version 1.32 dated 2022/09/14. ####Overview#### This class provides a LaTeX template for ASME Conference papers formatted according to @@ -79,9 +79,14 @@ --- ####Change log#### + v1.32 (2022/09/14) + - Incorporate patch to correct bug in hyperxmp that had impaired pdf/a compliance. + - Add code to asmeconf.bst for empty page field in @article. + v1.31 (2022/07/04) - Minor updates to address changes in the June 2022 release of LaTeX (PL 4) and the textcase package. -- Add option to asmewide.sty to suppress final page column balancing, [raggedend], expand error message text. +- Add option to asmewide.sty to suppress final page column balancing, \[raggedend\], expand error message text. + v1.30 (2022/03/14) - Edit code loading fonts for Greek, Vietnamese, and cyrillic languages under pdflatex, to ensure compatibility with newtx v1.71. These options now require LaTeX distributions 2020/02/02 or later. - Edit font loading for the case when luaLaTeX is called without fontspec. diff --git a/macros/latex/contrib/asmeconf/asmeconf-template.pdf b/macros/latex/contrib/asmeconf/asmeconf-template.pdf index 00c82e854c..59379fb80e 100644 Binary files a/macros/latex/contrib/asmeconf/asmeconf-template.pdf and b/macros/latex/contrib/asmeconf/asmeconf-template.pdf differ diff --git a/macros/latex/contrib/asmeconf/asmeconf-template.tex b/macros/latex/contrib/asmeconf/asmeconf-template.tex index 8b65781b7f..3788a13de4 100644 --- a/macros/latex/contrib/asmeconf/asmeconf-template.tex +++ b/macros/latex/contrib/asmeconf/asmeconf-template.tex @@ -4,7 +4,7 @@ %% This file is asmeconf-template.tex, a LaTeX template to format ASME Conference papers according to %% the requirements on ASME's conference web pages, and including hypertext support for the pdf. %% -%% This file is version 1.31 dated 2022/07/04 +%% This file is version 1.32 dated 2022/09/14 %% %% As of version 1.11, this template defaults to ASME's newer conference guidelines first posted July 2019. %% Those guidelines changed the requested author block formatting to be inline. @@ -84,6 +84,21 @@ %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% New pdf management code (June 2021); with this, the class option [pdf-a] can be omitted. +%% This change to the LaTeX kernel is being phased-in by the LaTeX3 team. Can delete if it gives you trouble. +%% Under LuaLaTeX, choose pdfstandard=A-3b (and be cautious when loading extra fonts) + +%\RequirePackage{pdfmanagement-testphase}% +% \DocumentMetadata{% +% pdfstandard=A-3b,% A-2b, A-2u, A-3b, or A-3u +% pdfversion=1.7, +% lang=en-US, +% }% + % 6 July 2022: this is breaking \hrefurl and \url. Not sure why, conflict with other parts of my code. + % \renewcommand\hrefurl[2]{{#1}{#2}} \renewcommand\url[1]{#1} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %% Class options are described above. Change these options as desired. %% If you are not using the language options, remove them (together with Appendices B and C) %% Remove the [colorlinks] option before *final* submission to ASME, to get black text for printing, @@ -94,7 +109,7 @@ %%%%% pdf metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \hypersetup{% - pdfauthor={John H. Lienhard}, % <=== change to YOUR name[s]! + pdfauthor={John H. Lienhard}, pdftitle={ASME Conference Paper LaTeX Template}, % <=== change to YOUR pdf file title pdfkeywords={ASME conference paper, LaTeX template, BibTeX style},% <=== change to YOUR pdf keywords pdfsubject = {Describes the asmeconf LaTeX template}, % <=== change to YOUR subject @@ -156,7 +171,6 @@ %%% \date{..} calls the same command. \versionfootnote{Documentation for \texttt{asmeconf.cls}: Version~\versionno, \today.}% <=== Delete before final submission. - %%% Change these to your keywords. Keywords are automatically printed at the end of the abstract. %%% This command MUST COME BEFORE the end of the abstract. %%% If you don't want keywords, leave the argument of \keywords{} empty (or use the abstract* environment) @@ -199,7 +213,6 @@ This paper is an example of and a {\upshape\LaTeX} template for typesetting ASM \entry{$\infty$}{free stream value} \end{nomenclature} - %%%%%%%%% BODY OF PAPER %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Introduction} @@ -222,7 +235,6 @@ After setting up the headers, authors, and title, issue the \verb|\maketitle| c The abstract text must be placed into \verb|\begin{abstract}| \ldots \verb|\end{abstract}|. The abstract will automatically be italicized. Keywords may be included using the \verb|\keywords{..}| command. The \texttt{keyword} command \textit{must} be issued before the abstract environment. - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Referring to Citations, Figures, and Equations} diff --git a/macros/latex/contrib/asmeconf/asmeconf.bst b/macros/latex/contrib/asmeconf/asmeconf.bst index 0e378d305d..8884ca5f21 100644 --- a/macros/latex/contrib/asmeconf/asmeconf.bst +++ b/macros/latex/contrib/asmeconf/asmeconf.bst @@ -4,7 +4,7 @@ %%%%% *** https://www.asme.org/publications-submissions/proceedings/author-guidelines/elements-of-a-paper/references *** %%%%% *** The examples given by ASME do *not* cover all possibilities *** %%%%% -%%%%% This file is version 1.13 dated 2021/12/02 (and checked 2022/02/14) +%%%%% This file is version 1.14 dated 2022/09/13 %%%%% %%%%% Author: John H. Lienhard V %%%%% Department of Mechanical Engineering @@ -26,6 +26,9 @@ %%%%% Added: urlprefix = {}, format.web.urldate, bbl.urldate; urltype field changes "accessed" to something else. %%%%% Added: venue and eventdate to @inproceedings %%%%% +%%%%% Edits in version 1.14, 2022/09/13 +%%%%% Add code to format.journal.pages to deal with empty pages +%%%%% %%%%% Edits in version 1.13, 2021/12/02 %%%%% Switched remaining http:// prefixes to https:// %%%%% Replace \href{}{} in \eprint by \url @@ -1036,8 +1039,16 @@ FUNCTION {format.pages} } FUNCTION {format.journal.pages} -{ pages duplicate$ empty$ 'pop$ - { swap$ duplicate$ empty$ +{ pages duplicate$ empty$ + { "empty pages in " cite$ * warning$ } + 'skip$ + if$ + duplicate$ empty$ + { pop$ + " " * + format.year * + } + { swap$ duplicate$ empty$ { pop$ pop$ format.pages } { " " * @@ -1054,7 +1065,7 @@ FUNCTION {format.journal.pages} * } if$ - } + } if$ } FUNCTION {format.journal.eid} diff --git a/macros/latex/contrib/asmeconf/asmeconf.cls b/macros/latex/contrib/asmeconf/asmeconf.cls index 97b2ce8404..c078785e01 100644 --- a/macros/latex/contrib/asmeconf/asmeconf.cls +++ b/macros/latex/contrib/asmeconf/asmeconf.cls @@ -5,8 +5,8 @@ %% ASME conference requirements as represented on ASME's conference web pages in 2022. %% %% This file's version and date: - \def\versionno{1.31} - \def\versiondate{2022/07/04\space} + \def\versionno{1.32} + \def\versiondate{2022/09/14\space} %% %% Author: John H. Lienhard, V %% Department of Mechanical Engineering @@ -1129,9 +1129,23 @@ \RequirePackage{hyperxmp}% improve transfer of metadata to pdf +% Patch bug in hyperxmp, unless a more recent version is used. +\ifdefined\hyxmp@no@bad@parts% \hyxmp@no@bad@parts is not def'd in TeX Live 2019 or older + \@ifpackagelater{hyperxmp}{2022/09/14}{% no new version at present, still 2020/11/22 + \relax + }{% + \newcount\hypxmp@tempcnt + \define@key{Hyp}{pdfapart}{% + \afterassignment\hyxmp@no@bad@parts\hypxmp@tempcnt=0#1\relax + \hyxmp@pdfstringdef\@pdfapart{\the\hypxmp@tempcnt}% + } + } +\else + \relax +\fi + \RequirePackage[psdextra]{hyperref} % recent kernel transition suggests providing most hyperref options via \hypersetup, % but setting psdextra here (for additional math support in bookmarks) 2021/12/01 - \hypersetup{% unicode, % Unicode encoded PDF strings pdfborder={0 0 0},% diff --git a/macros/latex/contrib/asmeconf/examples/asmeconf-wide-equation-example/asmeconf-template-widetext.pdf b/macros/latex/contrib/asmeconf/examples/asmeconf-wide-equation-example/asmeconf-template-widetext.pdf index cf119cdbde..de1e14c24a 100644 Binary files a/macros/latex/contrib/asmeconf/examples/asmeconf-wide-equation-example/asmeconf-template-widetext.pdf and b/macros/latex/contrib/asmeconf/examples/asmeconf-wide-equation-example/asmeconf-template-widetext.pdf differ diff --git a/macros/latex/contrib/asmeconf/examples/asmeconf-wide-equation-example/asmeconf-template-widetext.tex b/macros/latex/contrib/asmeconf/examples/asmeconf-wide-equation-example/asmeconf-template-widetext.tex index 2456b0266d..a0f58488e4 100644 --- a/macros/latex/contrib/asmeconf/examples/asmeconf-wide-equation-example/asmeconf-template-widetext.tex +++ b/macros/latex/contrib/asmeconf/examples/asmeconf-wide-equation-example/asmeconf-template-widetext.tex @@ -7,6 +7,8 @@ %% * \begin{widetext[N] .. changes upper/lower separation of wide material from default 5pt to Npt %% * \begin{widetext}[][tbn]: t = top line only; b = bottom line only; n = no lines. BOTH arguments are REQUIRED, even if first is left empty. %% +%% asmewide,sty supports one option, [raggedend], which suppresses final page column balancing: \usepackage[raggedend]{asmewide} +%% %% The widetext environment can only appear once per page. It clashes with floats and footnotes, as discussed herein. %% %% NB: the strip environment from cuted is incompatible with the [lineno] option to asmeconf! @@ -14,7 +16,7 @@ \documentclass[nofoot,colorlinks,balance,pdf-acolorlinks,balance,pdf-a]{asmeconf} \def\ACwidetextversion{1.1} -\def\ACwidetextdate{February 15, 2022} +\def\ACwidetextdate{September 14, 2022} \usepackage{lipsum}% Latin filler text \usepackage{asmewide} @@ -114,7 +116,7 @@ to be read---the rest is simply filler to aid in layout.} \centering{\includegraphics{tesseral-harmonic.pdf}}% \subcaption{\label{fig:tesseral}}% \end{subfigure}% -\caption{A figure with two subfigures: (a) Zonal harmonic $n=1, m=0$, (b) Tesseral harmonic $n=2, m=3$. See Appendix~\ref{sec:sph-har}.\label{fig:1}} +\caption{A figure with two subfigures: (a) Zonal harmonic $n=1, m=0$, (b) Tesseral harmonic $n=2, m=3$. See Appendix~\ref{sec:sph-har}.}\label{fig:1} \end{figure*} %%%%%%%%%%%%%%%%%%% end two column figure %%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -265,7 +267,7 @@ until both are done\footnotemark. The single column table, Table~\ref{tab:3}, is %%%%%%%%%%%%%%%%%%% begin linewidth table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{table}[b] \newcolumntype{C}{>{$}c<{$}} % math-mode version of "c" column type, from array package -\caption{\label{tab:3}Table at full column width with columns in math mode} +\caption{Table at full column width with columns in math mode}\label{tab:3} \centering{% \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}CCCC@{\extracolsep{\fill}}} \hline\hline @@ -320,7 +322,7 @@ q_\textrm{gray} & q_\textrm{int, $T_1$} & q_\textrm{int, $T_m$} & q_\textrm{exa %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \appendix -\section{Spherical harmonics\label{sec:sph-har}} +\section{Spherical harmonics}\label{sec:sph-har} Without getting into the details, a regular function $f(\theta,\phi)$ on the surface of the unit sphere may be written \begin{equation} diff --git a/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/README.md b/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/README.md index 17b1e7e79b..f950f9b51b 100644 --- a/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/README.md +++ b/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/README.md @@ -2,7 +2,7 @@ A beamer inner theme which reproduces standard beamer blocks using tcolorboxes -Current version: 2022/09/06 version v0.4 +Current version: 2022/09/14 version v0.5 This project is licensed under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt diff --git a/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/beamerinnerthemetcolorbox.sty b/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/beamerinnerthemetcolorbox.sty index 4b50b04ca1..7878e5620e 100644 --- a/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/beamerinnerthemetcolorbox.sty +++ b/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/beamerinnerthemetcolorbox.sty @@ -12,40 +12,76 @@ % See http://www.latex-project.org/lppl.txt % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\ProvidesPackage{beamerinnerthemetcolorbox}[2022/09/06 version v0.4 Beamer blocks with tcolorboxes] +\ProvidesPackage{beamerinnerthemetcolorbox}[2022/09/14 version v0.5 Beamer blocks with tcolorboxes] \RequirePackage{tcolorbox} \tcbuselibrary{skins,hooks} +\providecommand\@secondofthree[3]{#2} + \tcbset{ - beamer@tcb@iftitle/.code n args={1}{ - \ifbeamer@tcb@title - \pgfkeysalso{#1} - \fi + beamer@tcb@if/.code n args = {3}{% + \csname #1\endcsname\expandafter\@secondofthree\fi + \@secondoftwo{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}% } } - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Theme Options -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newif\ifbeamer@tcb@rounded \newif\ifbeamer@tcb@shadow \newif\ifbeamer@tcb@shaded -\newif\ifbeamer@tcb@title +\newif\ifbeamer@tcb@showtitle \newif\ifbeamer@tcb@inmargin +\newif\ifbeamer@tcb@color +\newif\ifbeamer@tcb@left +\newif\ifbeamer@tcb@right +\newif\ifbeamer@tcb@center +\newif\ifbeamer@tcb@titlepage +\newif\ifbeamer@tcb@blocks +\beamer@tcb@colortrue \def\beamer@tcb@true{true} +\tikzset{ + /beamer@tcb/.cd, + wd/.store in = \beamer@tcb@wd, + wd = \textwidth, + dp/.code = \relax, + ht/.code = \relax, + left/.code = \beamer@tcb@lefttrue, + right/.code = \beamet@tcb@righttrue, + center/.code = \beamer@tcb@centertrue, + leftskip/.store in = \beamer@tcb@leftskip, + leftskip = 0.05cm, + rightskip/.store in = \beamer@tcb@rightskip, + rightskip = 0.05cm, + sep/.store in = \beamer@tcb@sep, + sep = 1mm, + colsep/.code = \relax, + colsep*/.code = \relax, + shadow/.code = \relax, + rounded/.code = \relax, + ignorebg/.code = \relax, + vmode/.code = \relax, +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Theme Options +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \DeclareOptionBeamer{shadow}[true]{\csname beamer@tcb@shadow#1\endcsname} -\DeclareOptionBeamer{rounded}[true]{\csname beamer@tcb@rounded#1\endcsname\csname beamer@tcb@shaded#1\endcsname} +\DeclareOptionBeamer{rounded}[true]{\csname beamer@tcb@rounded#1\endcsname\csname beamer@tcb@shaded#1\endcsname\csname beamer@tcb@showtitlefalse\endcsname} \DeclareOptionBeamer{shaded}[true]{\csname beamer@tcb@shaded#1\endcsname} \DeclareOptionBeamer{inmargin}[true]{\csname beamer@tcb@inmargin#1\endcsname} +\DeclareOptionBeamer{showtitle}[true]{\csname beamer@tcb@showtitle#1\endcsname} +\DeclareOptionBeamer{titlepage}[true]{\csname beamer@tcb@titlepage#1\endcsname} +\DeclareOptionBeamer{blocks}[true]{\csname beamer@tcb@blocks#1\endcsname} \ExecuteOptionsBeamer{shadow=false} \ExecuteOptionsBeamer{rounded=false} \ExecuteOptionsBeamer{shaded=false} \ExecuteOptionsBeamer{inmargin=false} +\ExecuteOptionsBeamer{showtitle=true} +\ExecuteOptionsBeamer{titlepage=true} +\ExecuteOptionsBeamer{blocks=true} % check options from other themes \ifdefined\beamer@themerounded@shadow @@ -54,6 +90,7 @@ \ifx\beamer@themerounded@shadow\beamer@tcb@true \beamer@tcb@shadowtrue \fi + \beamer@tcb@showtitlefalse \fi \ifdefined\beamer@putleft @@ -112,7 +149,6 @@ } \else \tcbsetforeverylayer{sharpish corners} - \beamer@tcb@titletrue \fi \ifbeamer@tcb@shaded @@ -143,58 +179,63 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \mode -% normal block -\setbeamertemplate{block begin}{% - \beamer@tcb@colini - \ifx\insertblocktitle\@empty\else - \beamer@tcb@titletrue - \fi - \begin{tcolorbox}[ - colback=beamer@tcb@bodybg, - colbacktitle=beamer@tcb@titlebg, - coltext=beamer@tcb@bodyfg, - coltitle=beamer@tcb@titlefg, - before title={\usebeamerfont{block title}}, - before upper={\usebeamercolor{block body}\usebeamerfont{block body}}, - beamer@tcb@iftitle={title={\insertblocktitle}} - ] -} -\setbeamertemplate{block end}{\end{tcolorbox}} - -% alert block -\setbeamertemplate{block alerted begin}{% - \beamer@tcb@colini[ alerted] - \ifx\insertblocktitle\@empty\else - \beamer@tcb@titletrue - \fi - \begin{tcolorbox}[ - colback=beamer@tcb@bodybg, - colbacktitle=beamer@tcb@titlebg, - coltext=beamer@tcb@bodyfg, - coltitle=beamer@tcb@titlefg, - before title={\usebeamerfont{block title alerted}}, - before upper={\usebeamercolor{block body alerted}\usebeamerfont{block body alerted}}, - beamer@tcb@iftitle={title={\insertblocktitle}} - ] -} -\setbeamertemplate{block alerted end}{\end{tcolorbox}} - -% example block -\setbeamertemplate{block example begin}{% - \beamer@tcb@colini[ example] - \ifx\insertblocktitle\@empty\else - \beamer@tcb@titletrue - \fi - \begin{tcolorbox}[ +\newtcolorbox{beamer@tcb@block}[1][]{ + code={ + \beamer@tcb@colini[#1] + \ifx\insertblocktitle\@empty\else + \beamer@tcb@showtitletrue + \fi + }, + colback=beamer@tcb@bodybg, + colbacktitle=beamer@tcb@titlebg, + coltext=beamer@tcb@bodyfg, + coltitle=beamer@tcb@titlefg, + before title={\usebeamerfont{block title}}, + before upper={\usebeamercolor{block body}\usebeamerfont{block body}}, + beamer@tcb@if={ifbeamer@tcb@showtitle}{title={\insertblocktitle}}{}, +} + +\ifbeamer@tcb@blocks + \setbeamertemplate{block begin}{\begin{beamer@tcb@block}} + \setbeamertemplate{block end}{\end{beamer@tcb@block}} + \setbeamertemplate{block alerted begin}{\begin{beamer@tcb@block}[ alerted]} + \setbeamertemplate{block alerted end}{\end{beamer@tcb@block}} + \setbeamertemplate{block example begin}{\begin{beamer@tcb@block}[ example]} + \setbeamertemplate{block example end}{\end{beamer@tcb@block}} +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% patch title page etc. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newcommand{\beamer@tcb@patchcolorbox}{% + \renewtcolorbox{beamercolorbox}[2][]{% + code={% + \usebeamercolor{##2}% + \colorlet{beamer@tcb@bodybg}{##2.bg}% + \colorlet{beamer@tcb@bodyfg}{##2.fg}% + \ifbeamercolorempty[bg]{##2}{}{\beamer@tcb@colorfalse}% + \tikzset{/beamer@tcb/.cd,##1}% + }, colback=beamer@tcb@bodybg, - colbacktitle=beamer@tcb@titlebg, coltext=beamer@tcb@bodyfg, - coltitle=beamer@tcb@titlefg, - before title={\usebeamerfont{block title example}}, - before upper={\usebeamercolor{block body example}\usebeamerfont{block body example}}, - beamer@tcb@iftitle={title={\insertblocktitle}} - ] -} -\setbeamertemplate{block example end}{\end{tcolorbox}} + beamer@tcb@if={ifbeamer@tcb@color}{no shadow}{boxsep=\beamer@tcb@sep}, + width=\beamer@tcb@wd, + beamer@tcb@if={ifbeamer@tcb@center}{halign=center}{}, + beamer@tcb@if={ifbeamer@tcb@left}{halign=left}{}, + beamer@tcb@if={ifbeamer@tcb@right}{halign=right}{}, + left=\beamer@tcb@leftskip, + right=\beamer@tcb@rightskip, + }% +} + +\ifbeamer@tcb@titlepage + \addtobeamertemplate{title page}{\begingroup\beamer@tcb@patchcolorbox}{\endgroup} + \addtobeamertemplate{part page}{\begingroup\beamer@tcb@patchcolorbox}{\endgroup} + \addtobeamertemplate{section page}{\begingroup\beamer@tcb@patchcolorbox}{\endgroup} + \addtobeamertemplate{subsection page}{\begingroup\beamer@tcb@patchcolorbox}{\endgroup} +\fi \mode diff --git a/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/beamertheme-tcolorbox-doc.pdf b/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/beamertheme-tcolorbox-doc.pdf index 07d7d84c78..6c7f2c6a11 100644 Binary files a/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/beamertheme-tcolorbox-doc.pdf and b/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/beamertheme-tcolorbox-doc.pdf differ diff --git a/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/beamertheme-tcolorbox-doc.tex b/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/beamertheme-tcolorbox-doc.tex index 234082375d..1adec46b48 100644 --- a/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/beamertheme-tcolorbox-doc.tex +++ b/macros/latex/contrib/beamer-contrib/themes/beamertheme-tcolorbox/beamertheme-tcolorbox-doc.tex @@ -68,6 +68,15 @@ \lstset{style=tcolorboxstyle} +%\makeatletter +\newcommand{\prefix}{./build} +\tcbset{ + compilable listing/.style={listing file={\prefix/\jobname-listing-\thetcblistingcount.tex}}, + run pdflatex/.style={run@system@command={cd\space \prefix;\space pdflatex}{\jobname-listing-\thetcblistingcount.tex}},% +} +%\makeatother + + % meta %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \title{The tcolorbox beamer inner theme} \subtitle{A beamer inner theme to reproduce standard beamer blocks using tcolorboxes} @@ -77,7 +86,7 @@ \url{https://github.com/samcarter/beamertheme-tcolorbox}\\ \url{https://www.ctan.org/pkg/beamertheme-tcolorbox} }{samcarter}} -\date{Version v0.4 \textendash{} 2022/09/06} +\date{Version v0.5 \textendash{} 2022/09/14} \begin{document} \maketitle @@ -89,9 +98,7 @@ Over the last decade of answering beamer problems and more recently also being o For all these cases, there is now an alternative to the default beamer blocks: The tcolorbox inner beamer theme will replace the usual beamer mechanism to draw blocks with tcolorboxes. The tcolorboxes will automatically adopt the look and feel (round vs.\ sharp corners and shadows) as well as the colours of the normal beamer blocks. -The package is included in \TeX{}Live -%and MiK\TeX\ -and available from \textsc{CTAN} (\url{https://www.ctan.org/pkg/beamertheme-tcolorbox}). +The package is included in \TeX{}Live and MiK\TeX\ and available from \textsc{CTAN} (\url{https://www.ctan.org/pkg/beamertheme-tcolorbox}). The development version of this package is located at \url{https://github.com/samcarter/beamertheme-tcolorbox}. If you have any problems, ideas or other feedback, please make constructive use of the issue tracker. Copyright \raisebox{0.2em}{\tiny\fontfamily{cmr}\selectfont\textcopyright} \texttt{samcarter}. Permission is granted to copy, distribute and\slash or modify this software under the terms of the LaTeX project public licence, version 1.3c or later \url{http://www.latex-project.org/lppl.txt}. @@ -137,28 +144,19 @@ In this simple configuration, the look and feel of the new blocks will be taken \section{Options} -In addition to automatically adopting settings from the other themes, one can also influence the look and feel via these options: +In addition to automatically adopting settings from other themes, one can also explicitly influence the look and feel via these options: \begin{description} -\item[inmargin] controls if the block titles are placed in the left sidebar instead of the top of the block, e.g. for themes like \lstinline|Bergen| (default: \lstinline|false|) -\item[rounded] controls if corners are rounded or sharp (default: \lstinline|false|) -\item[shadow] controls if the block has a shadow (default: \lstinline|false|) -\item[shaded] controls if there is a short colour gradient between the title and the body or if there is a sharp border between the colours (Default: \lstinline|false|; if rounded corners are activated, it is \lstinline|true|) +\item[blocks] controls if tcolorboxes should be used for beamer blocks (default: \lstinline|true|) +\item[inmargin] controls if the block titles are placed in the left sidebar instead of the top of the block, e.g. for themes like \lstinline|Bergen| (default: \lstinline|false|, but set to \lstinline|true| if the \lstinline|inmargin| inner theme is detected) +\item[rounded] controls if corners are rounded or sharp (default: \lstinline|false|, but set to \lstinline|true| if the \lstinline|rounded| inner theme is detected) +\item[shaded] controls if there is a short colour gradient between the title and the body (default: \lstinline|false|, but set to \lstinline|true| if the block corners are rounded) +\item[shadow] controls if the block has a shadow (default: \lstinline|false|, but set to \lstinline|true| if the \lstinline|shadow| outer theme is detected) +\item[showtitle] controls if a small coloured stripe is shown for blocks with empty title (default: \lstinline|true|, but set to \lstinline|false| if the block has rounded corners) +\item[titlepage] controls if tcolorboxes should be used for the title page, section page etc. (default: \lstinline|true|) \end{description} These options can be set to \lstinline|true| or \lstinline|false| (calling either option without explicit \lstinline|true| or \lstinline|false| will set it to \lstinline|true|). -\begin{tcolorbox}[title={}] -\begin{lstlisting} -\useinnertheme[ - rounded, - shadow=false, - shaded, - inmargin=false -]{tcolorbox} -\end{lstlisting} -\end{tcolorbox} - -If one for example likes the Antibes theme, but prefers the blocks to have shadows, they can now easily be added: - +If one for example likes the Antibes theme, but prefers the blocks to have shadows, they can now easily be added: \nopagebreak \begin{tcblisting}{ listing and comment, pdf comment, @@ -217,10 +215,4 @@ Beyond these two options, the users also has the myriads of options of the tcolo \end{document} \end{tcblisting} -\section{Caveats and known issues} - -\begin{itemize} -\item at the moment, this theme only applies to blocks. Things like the title page, which directly use beamercolorboxes, won't be replaced by tcolorboxes -\end{itemize} - \end{document} diff --git a/macros/latex/contrib/beamer/CHANGELOG.md b/macros/latex/contrib/beamer/CHANGELOG.md index 9bfff6ad56..ff3c75b7a7 100644 --- a/macros/latex/contrib/beamer/CHANGELOG.md +++ b/macros/latex/contrib/beamer/CHANGELOG.md @@ -8,6 +8,16 @@ a major and minor version only. ## [Unreleased] +## [v3.68] + +### Changed + +- simplified non-text links for navigation symbols and framezoom + +### Fixed +- fixed height of non-text links to prevent overlaps in vertically stacked miniframes (see #780) +- avoid problem with non-black black (see #772 and #659) + ## [v3.67] ### Changed @@ -202,7 +212,8 @@ a major and minor version only. - Support for `noxcolor` with `beamerarticle` (see #483) - Treatment of mixed overlay/alert specifications -[Unreleased]: https://github.com/josephwright/beamer/compare/v3.67...HEAD +[Unreleased]: https://github.com/josephwright/beamer/compare/v3.68...HEAD +[v3.68]: https://github.com/josephwright/beamer/compare/v3.67...v3.68 [v3.67]: https://github.com/josephwright/beamer/compare/v3.66...v3.67 [v3.66]: https://github.com/josephwright/beamer/compare/v3.65...v3.66 [v3.65]: https://github.com/josephwright/beamer/compare/v3.64...v3.65 diff --git a/macros/latex/contrib/beamer/base/beamer.cls b/macros/latex/contrib/beamer/base/beamer.cls index 7e5b558121..475d5d0ab6 100644 --- a/macros/latex/contrib/beamer/base/beamer.cls +++ b/macros/latex/contrib/beamer/base/beamer.cls @@ -12,7 +12,7 @@ % See the file doc/licenses/LICENSE for more details. \ProvidesClass{beamer} - [2022/05/17 v3.67 A class for typesetting presentations] + [2022/09/13 v3.68 A class for typesetting presentations] % Setup modes and check for article option % Also loads packages required by both beamer and beamerarticle diff --git a/macros/latex/contrib/beamer/base/beamerarticle.sty b/macros/latex/contrib/beamer/base/beamerarticle.sty index c56dbc55a3..1de9be15f6 100644 --- a/macros/latex/contrib/beamer/base/beamerarticle.sty +++ b/macros/latex/contrib/beamer/base/beamerarticle.sty @@ -12,7 +12,7 @@ % See the file doc/licenses/LICENSE for more details. \ProvidesPackage{beamerarticle} - [2022/05/17 v3.67 beamer input in article mode] + [2022/09/13 v3.68 beamer input in article mode] % Setup modes and check for article option % Also loads packages required by both beamer and beamerarticle diff --git a/macros/latex/contrib/beamer/base/beamerbaseboxes.sty b/macros/latex/contrib/beamer/base/beamerbaseboxes.sty index cf53f9544a..1248f957cd 100644 --- a/macros/latex/contrib/beamer/base/beamerbaseboxes.sty +++ b/macros/latex/contrib/beamer/base/beamerbaseboxes.sty @@ -169,7 +169,7 @@ % % clipping is needed because shadow is typeset on top of box \begin{pgfscope} - \pgfsetcolor{black} + \pgfsetcolor{beamer@safeblack} \pgfpathrectangle{\pgfpoint{4bp}{8.1bp}}{\pgfpoint{\bmb@boxwidth}{\bmb@boxheight-2bp}} \pgfusepath{fill} \end{pgfscope} diff --git a/macros/latex/contrib/beamer/base/beamerbaseframesize.sty b/macros/latex/contrib/beamer/base/beamerbaseframesize.sty index 0cac2fd8ad..a11ce6f4b1 100644 --- a/macros/latex/contrib/beamer/base/beamerbaseframesize.sty +++ b/macros/latex/contrib/beamer/base/beamerbaseframesize.sty @@ -51,21 +51,14 @@ \only<#1>{% {\hypersetup{pdfhighlight={/P},pdfborder={0 0 \beamer@zoomborderwidth}}% \global\setbox\@tempboxa=\vbox{\hyperlink{\beamer@labelzoomed}{% - \expandafter\ifx\csname XeTeXrevision\endcsname\relax - \vbox to #7{% - \hbox to#6{\hfil}% - \vfil% - }% + \expandafter\ifx\csname XeTeXrevision\endcsname\relax% \else% - \begingroup% - \normalsize% - \begin{pgfpicture}{0pt}{0pt}{#6}{#7}% - \pgfsetfillopacity{0} - \pgftext[x=0cm,y=3pt]{.} - \pgftext[x=#6,y=\dimexpr#7-\baselineskip+3pt]{.} - \end{pgfpicture}% - \endgroup% - \fi% + \special{pdf:xann width #6 height #7 depth 0pt}% + \fi% + \vbox to #7{% + \hbox to#6{\hfil}% + \vfil% + }% }}}% \ht\@tempboxa=0pt% \wd\@tempboxa=0pt% diff --git a/macros/latex/contrib/beamer/base/beamerbasenavigation.sty b/macros/latex/contrib/beamer/base/beamerbasenavigation.sty index 59886007c4..408fa4bfe4 100644 --- a/macros/latex/contrib/beamer/base/beamerbasenavigation.sty +++ b/macros/latex/contrib/beamer/base/beamerbasenavigation.sty @@ -213,11 +213,19 @@ \fi {% \def\beamer@linkspace#1{% - \begin{pgfpicture}{0pt}{-1.5pt}{#1}{5.5pt} - \pgfsetfillopacity{0} - \pgftext[x=0pt,y=-1.5pt]{.} - \pgftext[x=#1,y=5.5pt]{.} - \end{pgfpicture}} + \@ifundefined{if@RTL}{% + \special{dvipdfmx:catch_phantom true height 8pt depth 1.5pt}% + \vbox to7.5pt{}\kern#1% + }{% + \if@RTL% + \vbox to7.5pt{}\kern#1% + \special{dvipdfmx:catch_phantom true height 8pt depth 1.5pt}% + \else% + \special{dvipdfmx:catch_phantom true height 8pt depth 1.5pt}% + \vbox to7.5pt{}\kern#1% + \fi% + }% + }% } \pgfdefobject{beamerslidenavlight}{\pgfpoint{0pt}{-1pt}}{\pgfpoint{20pt}{5pt}} diff --git a/macros/latex/contrib/beamer/base/themes/color/beamercolorthemedefault.sty b/macros/latex/contrib/beamer/base/themes/color/beamercolorthemedefault.sty index acc9216b8c..68f5600799 100644 --- a/macros/latex/contrib/beamer/base/themes/color/beamercolorthemedefault.sty +++ b/macros/latex/contrib/beamer/base/themes/color/beamercolorthemedefault.sty @@ -12,6 +12,7 @@ \mode \definecolor{beamer@blendedblue}{rgb}{0.2,0.2,0.7} % use structure theme to change +\colorlet{beamer@safeblack}{black} % safe copy of black for shadows etc. \setbeamercolor{normal text}{fg=black,bg=white} \setbeamercolor{alerted text}{fg=red} diff --git a/macros/latex/contrib/beamer/base/themes/outer/beamerouterthemedefault.sty b/macros/latex/contrib/beamer/base/themes/outer/beamerouterthemedefault.sty index 3113bfb92a..0a25efc33b 100644 --- a/macros/latex/contrib/beamer/base/themes/outer/beamerouterthemedefault.sty +++ b/macros/latex/contrib/beamer/base/themes/outer/beamerouterthemedefault.sty @@ -21,18 +21,16 @@ \newcommand{\beamer@xelatex@fixminiframes}{% \expandafter\ifx\csname XeTeXrevision\endcsname\relax \else - \pgfsetfillopacity{0} - \pgftext[x=0cm,y=0.0cm]{.} - \pgftext[x=0.1cm,y=0.1cm]{.} + \special{dvipdfmx:catch_phantom true height 0.1cm depth 0cm}% \fi } \defbeamertemplate*{mini frame}{default} {% + \beamer@xelatex@fixminiframes \begin{pgfpicture}{0pt}{0pt}{0.1cm}{0.1cm} \pgfpathcircle{\pgfpoint{0.05cm}{0.05cm}}{0.05cm} \pgfusepath{fill,stroke} - \beamer@xelatex@fixminiframes \end{pgfpicture}% } [action] @@ -42,19 +40,19 @@ \defbeamertemplate*{mini frame in current section}{default} {% + \beamer@xelatex@fixminiframes \begin{pgfpicture}{0pt}{0pt}{0.1cm}{0.1cm} \pgfpathcircle{\pgfpoint{0.05cm}{0.05cm}}{0.05cm} \pgfusepath{stroke} - \beamer@xelatex@fixminiframes \end{pgfpicture}% } \defbeamertemplate*{mini frame in current subsection}{default} {% + \beamer@xelatex@fixminiframes \begin{pgfpicture}{0pt}{0pt}{0.1cm}{0.1cm} \pgfpathcircle{\pgfpoint{0.05cm}{0.05cm}}{0.05cm} \pgfusepath{stroke} - \beamer@xelatex@fixminiframes \end{pgfpicture}% } diff --git a/macros/latex/contrib/beamer/base/themes/outer/beamerouterthemeshadow.sty b/macros/latex/contrib/beamer/base/themes/outer/beamerouterthemeshadow.sty index de2c9775cb..d0251deab0 100644 --- a/macros/latex/contrib/beamer/base/themes/outer/beamerouterthemeshadow.sty +++ b/macros/latex/contrib/beamer/base/themes/outer/beamerouterthemeshadow.sty @@ -65,7 +65,7 @@ \advance\beamer@tempdim by 2pt% \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{\beamer@tempdim} \begin{pgfscope} - \pgfsetfillcolor{black}% + \pgfsetfillcolor{beamer@safeblack}% \pgfpathrectangle{\pgfpoint{0pt}{-4pt}}{\pgfpoint{\paperwidth}{8pt}}% \pgfsetfading{beamer@topshadowmask}{}% \pgfusepath{fill}% diff --git a/macros/latex/contrib/beamer/doc/beamerexample-conference-talk.pdf b/macros/latex/contrib/beamer/doc/beamerexample-conference-talk.pdf index 7aebaaeccf..e18033ad3c 100644 Binary files a/macros/latex/contrib/beamer/doc/beamerexample-conference-talk.pdf and b/macros/latex/contrib/beamer/doc/beamerexample-conference-talk.pdf differ diff --git a/macros/latex/contrib/beamer/doc/beamerexample-lecture-beamer-version.pdf b/macros/latex/contrib/beamer/doc/beamerexample-lecture-beamer-version.pdf index 5bad383bf6..cd5a3421d6 100644 Binary files a/macros/latex/contrib/beamer/doc/beamerexample-lecture-beamer-version.pdf and b/macros/latex/contrib/beamer/doc/beamerexample-lecture-beamer-version.pdf differ diff --git a/macros/latex/contrib/beamer/doc/beamerexample-lecture-print-version.pdf b/macros/latex/contrib/beamer/doc/beamerexample-lecture-print-version.pdf index 54c13f9716..2555657089 100644 Binary files a/macros/latex/contrib/beamer/doc/beamerexample-lecture-print-version.pdf and b/macros/latex/contrib/beamer/doc/beamerexample-lecture-print-version.pdf differ diff --git a/macros/latex/contrib/beamer/doc/beamerug-introduction.tex b/macros/latex/contrib/beamer/doc/beamerug-introduction.tex index c46e8842e2..317ab826bd 100644 --- a/macros/latex/contrib/beamer/doc/beamerug-introduction.tex +++ b/macros/latex/contrib/beamer/doc/beamerug-introduction.tex @@ -14,7 +14,7 @@ \section{Introduction} -\beamer\ is a \LaTeX\ class for creating presentations that are held using a projector, but it can also be used to create transparency slides. Preparing presentations with \beamer\ is different from preparing them with \textsc{wysiwyg} programs like Libre-/OpenOffice.org Impress, Apple Keynote, KOffice KPresenter or Microsoft PowerPoint. A \beamer\ presentation is created like any other \LaTeX\ document: It has a preamble and a body, the body contains |\section|s and |\subsection|s, the different slides (called \emph{frames} in \beamer) are put in environments, they are structured using |itemize| and |enumerate| environments, and so on. The obvious disadvantage of this approach is that you have to know \LaTeX\ in order to use \beamer. The advantage is that if you know \LaTeX, you can use your knowledge of \LaTeX\ also when creating a presentation, not only when writing papers. +\beamer\ is a \LaTeX\ class for creating presentations that are held using a projector, but it can also be used to create transparency slides. Preparing presentations with \beamer\ is different from preparing them with \textsc{wysiwyg} programs like Libre-/OpenOffice.org Impress, Apple Keynote, Calligra Stage or Microsoft PowerPoint. A \beamer\ presentation is created like any other \LaTeX\ document: It has a preamble and a body, the body contains |\section|s and |\subsection|s, the different slides (called \emph{frames} in \beamer) are put in environments, they are structured using |itemize| and |enumerate| environments, and so on. The obvious disadvantage of this approach is that you have to know \LaTeX\ in order to use \beamer. The advantage is that if you know \LaTeX, you can use your knowledge of \LaTeX\ also when creating a presentation, not only when writing papers. \subsection{Main Features} diff --git a/macros/latex/contrib/beamer/doc/beamerug-localstructure.tex b/macros/latex/contrib/beamer/doc/beamerug-localstructure.tex index 1f58012eac..232979ac5c 100644 --- a/macros/latex/contrib/beamer/doc/beamerug-localstructure.tex +++ b/macros/latex/contrib/beamer/doc/beamerug-localstructure.tex @@ -1036,6 +1036,18 @@ Normally, \beamer\ uses \TeX's normal typesetting mechanism to position text and The package |textpos| provides several commands for positioning text absolutely and it works together with \beamer. When using this package, you will typically have to specify the options |overlay| and perhaps |absolute|. For details on how to use the package, please see its documentation. +Another package to conveniently position elements at specific positions on the frame is Ti\emph{k}Z. Besides the possibility to manually chose coordinates, this also allows to position elements in respect to the page: + + \example +\begin{verbatim} +\usepackage{tikz} + +\begin{frame} + \tikz[remember picture, overlay] \node at (3.1415,1) {I'm here}; + + \tikz[remember picture, overlay] \node at (current page.center) {I'm the centre of the frame!}; +\end{frame} +\end{verbatim} \subsection{Verbatim and Fragile Text} diff --git a/macros/latex/contrib/beamer/doc/beamerug-overlays.tex b/macros/latex/contrib/beamer/doc/beamerug-overlays.tex index c3d770701c..82767756f5 100644 --- a/macros/latex/contrib/beamer/doc/beamerug-overlays.tex +++ b/macros/latex/contrib/beamer/doc/beamerug-overlays.tex @@ -539,9 +539,9 @@ This section explains how to define new commands that are overlay specification- \example \begin{verbatim} -\renewenvironment<>{verse} -{\begin{actionenv}#1\begin{originalverse}} -{\end{originalverse}\end{actionenv}} +\renewenvironment<>{center} + {\begin{actionenv}#1\begin{originalcenter}} + {\end{originalcenter}\end{actionenv}} \end{verbatim} \end{command} diff --git a/macros/latex/contrib/beamer/doc/beameruserguide.pdf b/macros/latex/contrib/beamer/doc/beameruserguide.pdf index 633300470c..2c93b611ac 100644 Binary files a/macros/latex/contrib/beamer/doc/beameruserguide.pdf and b/macros/latex/contrib/beamer/doc/beameruserguide.pdf differ diff --git a/macros/latex/contrib/beamer/doc/beameruserguide.tex b/macros/latex/contrib/beamer/doc/beameruserguide.tex index b6ca2c0380..1380e2307d 100644 --- a/macros/latex/contrib/beamer/doc/beameruserguide.tex +++ b/macros/latex/contrib/beamer/doc/beameruserguide.tex @@ -13,7 +13,7 @@ \documentclass{ltxdoc} -\def\beamerugversion{3.67} +\def\beamerugversion{3.68} \def\beamerugpgfversion{3.1.7} \def\beamerugxcolorversion{2.00} @@ -25,7 +25,7 @@ \usepackage{pifont} \usepackage{makeidx} \usepackage{pgf,xcolor} -\usepackage[pdfborder={0 0 0},bookmarksnumbered]{hyperref} +\AddToHook{package/hyperref/after}{\hypersetup{pdfborder={0 0 0},bookmarksnumbered}} \usepackage[left=2.25cm,right=2.25cm,top=2.5cm,bottom=2.5cm,nohead]{geometry} \usepackage{translator} \usepackage{tikz} diff --git a/macros/latex/contrib/csquotes/csq-compat.def b/macros/latex/contrib/csquotes/csq-compat.def index 3e7a6ead61..9a19bf1fa4 100644 --- a/macros/latex/contrib/csquotes/csq-compat.def +++ b/macros/latex/contrib/csquotes/csq-compat.def @@ -1,5 +1,5 @@ \ProvidesFile{csq-compat.def} - [2022-09-09 v5.2m csquotes backwards compatibility (JAW)] + [2022-09-14 v5.2n csquotes backwards compatibility (JAW)] \def\csq@getversion#1{% \expandafter\csq@getversion@i diff --git a/macros/latex/contrib/csquotes/csquotes.def b/macros/latex/contrib/csquotes/csquotes.def index a310943d57..80f8cb5713 100644 --- a/macros/latex/contrib/csquotes/csquotes.def +++ b/macros/latex/contrib/csquotes/csquotes.def @@ -1,5 +1,5 @@ \ProvidesFile{csquotes.def} - [2022-09-09 v5.2m csquotes generic definitions (JAW)] + [2022-09-14 v5.2n csquotes generic definitions (JAW)] % Set defaults diff --git a/macros/latex/contrib/csquotes/csquotes.pdf b/macros/latex/contrib/csquotes/csquotes.pdf index c1b26aaf79..c9e8a11c1e 100644 Binary files a/macros/latex/contrib/csquotes/csquotes.pdf and b/macros/latex/contrib/csquotes/csquotes.pdf differ diff --git a/macros/latex/contrib/csquotes/csquotes.sty b/macros/latex/contrib/csquotes/csquotes.sty index 4973fbbbe4..0a5cbb4e84 100644 --- a/macros/latex/contrib/csquotes/csquotes.sty +++ b/macros/latex/contrib/csquotes/csquotes.sty @@ -12,7 +12,7 @@ \NeedsTeXFormat{LaTeX2e}[2005/12/01] \ProvidesPackage{csquotes} - [2022-09-09 v5.2m context-sensitive quotations (JAW)] + [2022-09-14 v5.2n context-sensitive quotations (JAW)] %% Compatibility and requirements @@ -1008,9 +1008,15 @@ % {}{}{} \long\def\csq@quote@i#1#2#3{% - \csq@bqgroup#1\csq@oqopen@i{#3}\csq@qclose@i{#2}} + \csq@bqgroup\expandafter\let\expandafter\csq@font\the\font + #1\csq@oqopen@i#3% + \expandafter\ifx\the\font\csq@font\else\expandafter\csq@font\fi + \csq@qclose@i{#2}} \long\def\csq@quote@ii#1#2#3{% - \csq@bqgroup#1\csq@iqopen@i{#3}\csq@qclose@i{#2}} + \csq@bqgroup\expandafter\let\expandafter\csq@font\the\font + #1\csq@iqopen@i#3% + \expandafter\ifx\the\font\csq@font\else\expandafter\csq@font\fi + \csq@qclose@i{#2}} % Plain quotes + language switching diff --git a/macros/latex/contrib/csquotes/csquotes.tex b/macros/latex/contrib/csquotes/csquotes.tex index 1b3ae93492..97c6e2e3cc 100644 --- a/macros/latex/contrib/csquotes/csquotes.tex +++ b/macros/latex/contrib/csquotes/csquotes.tex @@ -18,8 +18,8 @@ url={http://www.ctan.org/pkg/csquotes/}, author={Philipp Lehman, Joseph Wright}, email={joseph.wright@morningstar2.co.uk}, - revision={v5.2m}, - date={2022-09-09}} + revision={v5.2n}, + date={2022-09-14}} \hypersetup{% pdftitle={The csquotes Package}, @@ -1554,6 +1554,10 @@ This revision history is a list of changes relevant to users of this package. Ch \begin{changelog} +\begin{release}{5.2n}{2022-09-14} +\item Furtehr work to localise font changes inside quotes +\end{release} + \begin{release}{5.2m}{2022-09-09} \item Localise font changes inside quotes \item Added Turkish and Slovenian styles diff --git a/macros/latex/contrib/fixdif/fixdif-zh-cn.pdf b/macros/latex/contrib/fixdif/fixdif-zh-cn.pdf index 4994a32680..8b18290433 100644 Binary files a/macros/latex/contrib/fixdif/fixdif-zh-cn.pdf and b/macros/latex/contrib/fixdif/fixdif-zh-cn.pdf differ diff --git a/macros/latex/contrib/fixdif/fixdif-zh-cn.tex b/macros/latex/contrib/fixdif/fixdif-zh-cn.tex index f54662ffff..d99e8933a6 100644 --- a/macros/latex/contrib/fixdif/fixdif-zh-cn.tex +++ b/macros/latex/contrib/fixdif/fixdif-zh-cn.tex @@ -1,5 +1,5 @@ \documentclass[letterpaper,11pt]{article} -\date{2022/08/11\quad Version 1.4% +\date{2022/09/14\quad Version 1.4a% \thanks{源代码见~\hyperref{https://github.com/AlphaZTX/fixdif}{}{}{GitHub} 或~\hyperref{https://www.ctan.org/pkg/fixdif}{}{}{CTAN}。} } @@ -298,9 +298,9 @@ $\d x$ 和 \d x \end{Verbatim} 这样 |\nabla| 和 |\grad| 都会得到微分算符 $\nabla$。 -{\attention[2]}如需得到原来的普通数学符号 \cs{\meta{csname}},只需在数学模式中输入 -\cs{\meta{csname}nondif}。例如\hyperlink{cs:partialnondif}{% -\textcolor{titlecolor!75!black}{前面介绍的 \cs{partialnondif}}}。 +{\attention[2]}如需得到原来的普通数学符号 \texttt{\textbackslash}\meta{csname}, +只需在数学模式中输入 \texttt{\textbackslash}\meta{csname}\texttt{nondif}。 +例如\hyperlink{cs:partialnondif}{\textcolor{titlecolor!75!black}{前面介绍的 \cs{partialnondif}}}。 \noindent\textcolor{titlecolor}{\cs{letdif*}\marg{cmd}\marg{csname}}% \DescribeMacro{\letdif*}\hfill(仅限在导言区使用) diff --git a/macros/latex/contrib/fixdif/fixdif.dtx b/macros/latex/contrib/fixdif/fixdif.dtx index 1155a130fa..bc6b3bfce5 100644 --- a/macros/latex/contrib/fixdif/fixdif.dtx +++ b/macros/latex/contrib/fixdif/fixdif.dtx @@ -131,7 +131,7 @@ Copyright (C) 2022 by Zhang Tingxuan . % % %<*driver> -\ProvidesFile{fixdif.dtx}[2022/8/11 (c) Copyright 2022 by Zhang Tingxuan] +\ProvidesFile{fixdif.dtx}[2022/9/14 (c) Copyright 2022 by Zhang Tingxuan] \documentclass{ltxdoc} \usepackage{xcolor} @@ -150,7 +150,7 @@ Copyright (C) 2022 by Zhang Tingxuan . \title{The \pkg{fixdif} Package} \author{Zhang Tingxuan} -\date{2022/8/11\quad Version 1.4\thanks{\url{https://github.com/AlphaZTX/fixdif}}} +\date{2022/9/14\quad Version 1.4a\thanks{\url{https://github.com/AlphaZTX/fixdif}}} \usepackage{hyperref} \hypersetup{ @@ -238,7 +238,7 @@ Copyright (C) 2022 by Zhang Tingxuan . % which is regarded bad. For example, |$\d y/\d x$| produces % $\mathrm{d}y/\,\mathrm{d}x$; % -% \item This |\d| command cannot be used out of math mode. In another word, +% \item This |\d| command cannot be used out of math mode. In other words, % |\d{o}| would not produce ``\d{o}'' in text; % % \item The skip between ``d'' and the expression before it can be regarded @@ -473,7 +473,7 @@ Copyright (C) 2022 by Zhang Tingxuan . % Check the \TeX{} format and provides the package name. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{fixdif}[2022/8/11 Interface for defining differential operators.] +\ProvidesPackage{fixdif}[2022/9/14 Interface for defining differential operators.] % \end{macrocode} % % \subsection{Control the skip between slashes and differential operator} diff --git a/macros/latex/contrib/fixdif/fixdif.pdf b/macros/latex/contrib/fixdif/fixdif.pdf index 4452ce66ff..e0422d40fc 100644 Binary files a/macros/latex/contrib/fixdif/fixdif.pdf and b/macros/latex/contrib/fixdif/fixdif.pdf differ diff --git a/macros/latex/contrib/stex/doc/Makefile b/macros/latex/contrib/stex/doc/Makefile index b727f2f94d..7544a3c2fd 100644 --- a/macros/latex/contrib/stex/doc/Makefile +++ b/macros/latex/contrib/stex/doc/Makefile @@ -2,7 +2,7 @@ STY = stex extensions SPATH = $(STY:%=../source/%) DTX = $(shell ls $(SPATH:%=%/*.dtx)) INS = $(shell ls $(SPATH:%=%/*.ins)) -DOC = stex-doc.pdf stex-manual.pdf +DOC = stex-doc.pdf stex-manual.pdf stex-ide.pdf TEXDIR = ../tex TEXINPUTS = $(TEXDIR)//: diff --git a/macros/latex/contrib/stex/doc/img/vsc1.png b/macros/latex/contrib/stex/doc/img/vsc1.png new file mode 100644 index 0000000000..c6c3847f69 Binary files /dev/null and b/macros/latex/contrib/stex/doc/img/vsc1.png differ diff --git a/macros/latex/contrib/stex/doc/img/vsc2.png b/macros/latex/contrib/stex/doc/img/vsc2.png new file mode 100644 index 0000000000..e6365ad802 Binary files /dev/null and b/macros/latex/contrib/stex/doc/img/vsc2.png differ diff --git a/macros/latex/contrib/stex/doc/img/vsc3.png b/macros/latex/contrib/stex/doc/img/vsc3.png new file mode 100644 index 0000000000..d7b67ae278 Binary files /dev/null and b/macros/latex/contrib/stex/doc/img/vsc3.png differ diff --git a/macros/latex/contrib/stex/doc/packages/stex-document-structure.tex b/macros/latex/contrib/stex/doc/packages/stex-document-structure.tex index f8d570ea5e..f2cabec6c0 100644 --- a/macros/latex/contrib/stex/doc/packages/stex-document-structure.tex +++ b/macros/latex/contrib/stex/doc/packages/stex-document-structure.tex @@ -1,3 +1,4 @@ +\begin{sfragment}[id=sec:ds:intro]{Introduction} The \pkg{document-structure} package supplies an infrastructure for writing {\omdoc} documents in {\LaTeX}. This includes a simple structure sharing mechanism for \sTeX that allows to to move from a copy-and-paste document development model to a copy-and-reference model, which @@ -17,7 +18,9 @@ after translation. DAG models of documents allow to replace the ``Copy and Paste'' in the source document with a label-and-reference model where document are shared in the document source and the formatter does the copying during document formatting/presentation. +\end{sfragment} +\begin{sfragment}{Package Options} The \pkg{document-structure} package accepts the following options: \begin{center} \begin{tabular}{|l|p{10cm}|}\hline @@ -26,7 +29,9 @@ The \pkg{document-structure} package accepts the following options: \meta{sect} is \texttt{section}\\\hline \end{tabular} \end{center} +\end{sfragment} +\begin{sfragment}{Document Fragments} \begin{environment}{sfragment} The structure of the document is given by nested |sfragment| environments. In the {\LaTeX} route, the |sfragment| environment is flexibly mapped to sectioning commands, @@ -36,8 +41,8 @@ The \pkg{document-structure} package accepts the following options: sfragment. The optional metadata argument has the keys |id| for an identifier, |creators| and |contributors| for the Dublin Core metadata~\cite{DCMI:dmt03}. The option |short| allows to give a short title for the generated section. If the title contains - semantic macros, they need to be protected by |\protect|\ednote{MK: still?}, and we need - to give the |loadmodules| key it needs no value. For instance we would have + semantic macros, we need to give the |loadmodules| key (it needs no value). For instance + we would have \begin{latexcode} \begin{smodule}{foo} \symdef{bar}{B^a_r} @@ -90,9 +95,8 @@ Here we use two levels of |blindfragment|: the introductory remarks become a ``chapter'' instead of a ``part''. \item The inner one groups the frontmatter\footnote{We shied away from redefining the |frontmatter| to induce a blindfragment, but this may be the ``right'' way to go in - the future.} and makes the preface of the book a section-level construct.\ednote{MK: - We need a substitute for the ``Note that here the |display=flow| on the |sfragment| - environment prevents numbering as is traditional for prefaces.''} + the future.} and makes the preface of the book a section-level construct. The + |frontmatter| environment also suppresses numbering as is traditional for prefaces. \end{itemize} \end{environment} @@ -110,11 +114,13 @@ Here we use two levels of |blindfragment|: will\ldots'' in an |sfragment| environment, where we do not know which sectioning level we will end up. \end{function} +\end{sfragment} +\begin{sfragment}{Ending Documents Prematurely} \begin{function}{\prematurestop,\afterprematurestop} For prematurely stopping the formatting of a document, \sTeX provides the |\prematurestop| macro. It can be used everywhere in a document and ignores all input - after that -- backing out of the |sfragment| environment as needed. After that -- and + after that -- backing out of the |sfragment| environments as needed. After that -- and before the implicit |\end{document}| it calls the internal |\afterprematurestop|, which can be customized to do additional cleanup or e.g. print the bibliography. @@ -132,7 +138,12 @@ instance, the admin section of a course can be made course-independent (and ther re-usable) by using variables (actually token registers) |courseAcronym| and |courseTitle| instead of the text itself. The variables can then be set in the \sTeX preamble of the course notes file. - +\end{sfragment} + +\begin{sfragment}{Global Document Variables} + To make document fragments more reusable, we sometimes want to make the content depend + on the context. We use \defemph{document variables} for that. + \begin{function}{\setSGvar,\useSGvar} |\setSGvar{|\meta{vname}|}{|\meta{text}|}| to set the global variable \meta{vname} to \meta{text} and |\useSGvar{|\meta{vname}|}| to reference it. @@ -144,6 +155,7 @@ course notes file. variable \meta{vname}, only if (after expansion) it is equal to \meta{val}, the conditional text \meta{ctext} is formatted. \end{function} +\end{sfragment} %%% Local Variables: %%% mode: latex diff --git a/macros/latex/contrib/stex/doc/packages/stex-features.tex b/macros/latex/contrib/stex/doc/packages/stex-features.tex index b5ce5906d1..4e0cd21457 100644 --- a/macros/latex/contrib/stex/doc/packages/stex-features.tex +++ b/macros/latex/contrib/stex/doc/packages/stex-features.tex @@ -144,8 +144,16 @@ and be a \symname{monoid} on $\Int$ ... } - We will return to these two example later, when we also know - how to handle the \emph{axioms} of a monoid. + +We will return to these two example later, when we also know how to handle the +\emph{axioms} of a monoid. + +\begin{environment}{usestructure} + The |usestructure{}| environment is used in multilingual settings as a parallel + to the |mathstructure|. It opens a group and then issues a + |\usemodule{.../-structure}| that gives the body access to all the semantic + macros in the referenced structure. +\end{environment} \end{smodule} \end{sfragment} diff --git a/macros/latex/contrib/stex/doc/packages/stex-hwexam.tex b/macros/latex/contrib/stex/doc/packages/stex-hwexam.tex index 5aced96e66..a3679d0d94 100644 --- a/macros/latex/contrib/stex/doc/packages/stex-hwexam.tex +++ b/macros/latex/contrib/stex/doc/packages/stex-hwexam.tex @@ -1,15 +1,29 @@ - +\begin{sfragment}{Introduction} The \pkg{hwexam} package and class supplies an infrastructure that allows to format nice-looking assignment sheets by simply including problems from problem files marked up -with the \pkg{roblem} package. It is designed to be compatible with |problems.sty|, and +with the \pkg{problem} package. It is designed to be compatible with |problems.sty|, and inherits some of the functionality. +\end{sfragment} +\begin{sfragment}{Package Options} \begin{variable}{solutions,notes,hints,gnotes,pts,min} - The \pkg{wexam} package and class take the options |solutions|, |notes|, |hints|, + The \pkg{hwexam} package and class take the options |solutions|, |notes|, |hints|, |gnotes|, |pts|, |min|, and |boxed| that are just passed on to the \pkg{problems} package (cf. its documentation for a description of the intended behavior). \end{variable} +Furthermore, the \pkg{hwexam} package takes the option +\DescribeMacro{multiple}|multiple| that allows to combine multiple assignment sheets +into a compound document (the assignment sheets are treated as section, there is a table +of contents, etc.). + +Finally, there is the option \DescribeMacro{test}|test| that modifies the behavior to +facilitate formatting tests. Only in |test| mode, the macros |\testspace|, +|\testnewpage|, and |\testemptypage| have an effect: they generate space for the +students to solve the given problems. Thus they can be left in the {\LaTeX} source. +\end{sfragment} + +\begin{sfragment}{Assignments} This package supplies the \DescribeEnv{assignment}|assignment| environment that groups problems into assignment sheets. It takes an optional KeyVal argument with the keys \DescribeMacro{number}|number| (for the assignment number; if none is given, 1 is @@ -19,23 +33,22 @@ is referenced in the title of the assignment sheet), \DescribeMacro{type}|type| assignment type; e.g. ``quiz'', or ``homework''), \DescribeMacro{given}|given| (for the date the assignment was given), and \DescribeMacro{due}|due| (for the date the assignment is due). +\end{sfragment} -Furthermore, the \pkg{hwexam} package takes the option -\DescribeMacro{multiple}|multiple| that allows to combine multiple assignment sheets -into a compound document (the assignment sheets are treated as section, there is a table -of contents, etc.). - -Finally, there is the option \DescribeMacro{test}|test| that modifies the behavior to -facilitate formatting tests. Only in |test| mode, the macros |\testspace|, -|\testnewpage|, and |\testemptypage| have an effect: they generate space for the -students to solve the given problems. Thus they can be left in the {\LaTeX} source. +\begin{sfragment}{Including Assignments} +\begin{function}{\inputassignment} + The |\inputassignment| macro can be used to input an assignment from another file. It + takes an optional KeyVal argument and a second argument which is a path to the file + containing the problem (the macro assumes that there is only one |assignment| + environment in the included file). The keys |number|, |title|, |type|, |given|, and + |due| are just as for the |assignment| environment and (if given) overwrite the ones + specified in the |assignment| environment in the included file. +\end{function} +\end{sfragment} -\DescribeMacro{\testspace}|\testspace| takes an argument that expands to a dimension, -and leaves vertical space accordingly. \DescribeMacro{\testnewpage}|\testnewpage| makes -a new page in |test| mode, and \DescribeMacro{\testemptypage}|\testemptypage| generates -an empty page with the cautionary message that this page was intentionally left empty. +\begin{sfragment}{Typesetting Exams} -Finally, the \DescribeEnv{testheading}|\testheading| takes an optional keyword argument +The \DescribeEnv{testheading}|\testheading| takes an optional keyword argument where the keys \DescribeMacro{duration}|duration| specifies a string that specifies the duration of the test, \DescribeMacro{min}|min| specifies the equivalent in number of minutes, and \DescribeMacro{reqpts}|reqpts| the points that are required for a perfect @@ -68,17 +81,12 @@ Will result in \end{center} \ednote{MK: The first three ``problems'' come from the stex examples above, how do we get rid of this?} - -\begin{function}{\inputassignment} - The |\inputassignment| macro can be used to input an assignment from another file. It - takes an optional KeyVal argument and a second argument which is a path to the file - containing the problem (the macro assumes that there is only one |assignment| - environment in the included file). The keys |number|, |title|, |type|, |given|, and - |due| are just as for the |assignment| environment and (if given) overwrite the ones - specified in the |assignment| environment in the included file. -\end{function} +\end{sfragment} %%% Local Variables: %%% mode: latex %%% TeX-master: "../stex-manual" %%% End: + +% LocalWords: hwexam solutions,notes,hints,gnotes,pts,min gnotes testemptypage reqpts +% LocalWords: inputassignment reqpts hour,min 60,reqpts diff --git a/macros/latex/contrib/stex/doc/packages/stex-idesetup.tex b/macros/latex/contrib/stex/doc/packages/stex-idesetup.tex new file mode 100644 index 0000000000..b4d495b628 --- /dev/null +++ b/macros/latex/contrib/stex/doc/packages/stex-idesetup.tex @@ -0,0 +1,61 @@ +\begin{sfragment}{Setting up the \sTeX IDE} + + The \sTeX IDE consists of two components using the + \emph{Language Server Protocol (LSP)}: A \emph{client} + in the form of a VSCode extension, and a \emph{server} + included in the \mmt system. Installing the extension will + open up a setup routine that will guide you through the rest. + + \begin{sfragment}{The \sTeX VSCode Extension} + + If you have not already, you should first install the VSCode editor + available at \url{https://code.visualstudio.com/}. + + Next, open VSCode and install the \sTeX extension by clicking on + the \emph{extensions} menu on the very left of the VSCode window + and searching for ``sTeX'' in the + \emph{``Search Extensions in Marketplace''} field, as in + \autoref{fig:install}, and clicking the \emph{Install}-button + of the \sTeX extension by KWARC. + + \begin{figure} + \begin{center} + \includegraphics[width=0.6\textwidth]{img/vsc1.png} + \end{center} + \caption{Installing the \sTeX extension for VSCode}\label{fig:install} + \end{figure} + + \end{sfragment} + + \begin{sfragment}{Setting up \mmt} + + Next, open any directory (\texttt{File $\to$ Open Folder...}) that contains + a \verb|.tex|-file, and a setup window as in \autoref{fig:setup} + will pop up. Clik on the highlighted link `\emph{here}' and download + the latest version of the \texttt{MMT.jar} file (at least version 23.0.0) + anywhere you like. Then click the \emph{``Browse...''}-button + and select your freshly downloaded \texttt{MMT.jar}. + + If you have already set a system variable for your MathHub-directory, + you are now done and can click \emph{``Finish''}. If you have not, + you can now also enter a directory path in the lower text field, + and the VSCode extension will attempt to globally set one up + for you, depending on your operating system. + + \begin{figure} + \begin{center} + \includegraphics[width=\textwidth]{img/vsc2.png} + \end{center} + \caption{\sTeX Setup Routine}\label{fig:setup} + \end{figure} + + Once you click \emph{``Finish''}, the client will connect + to \url{https://stexmmt.mathhub.info/:sTeX}, query for + available archives, download the core libraries required + for all (or most) semantic services (\texttt{MMT/urtheories} + and \texttt{sTeX/meta-inf}) and set up \RusTeX for you + automatically. + + \end{sfragment} + + \end{sfragment} \ No newline at end of file diff --git a/macros/latex/contrib/stex/doc/packages/stex-mathhub.tex b/macros/latex/contrib/stex/doc/packages/stex-mathhub.tex index fb872acfba..eb09414ac7 100644 --- a/macros/latex/contrib/stex/doc/packages/stex-mathhub.tex +++ b/macros/latex/contrib/stex/doc/packages/stex-mathhub.tex @@ -1,4 +1,4 @@ -\begin{sfragment}{The Local MathHub-Directory} +\begin{sfragment}[id=sec:localmh]{The Local MathHub-Directory} \stexcode"\usemodule", \stexcode"\importmodule", \stexcode"\inputref" etc. allow for including content modularly without having to specify absolute diff --git a/macros/latex/contrib/stex/doc/packages/stex-mathhubsetup.tex b/macros/latex/contrib/stex/doc/packages/stex-mathhubsetup.tex new file mode 100644 index 0000000000..7a653186b3 --- /dev/null +++ b/macros/latex/contrib/stex/doc/packages/stex-mathhubsetup.tex @@ -0,0 +1,25 @@ + \begin{sfragment}{Setting your MathHub Directory} + One of \sTeX's features is a proper \emph{module system} + of interconnected document snippets for mathematical + content. Analogously to \emph{object-oriented programming}, + it allows for ``object-oriented mathematics'' via individual + combinable and, importantly, \emph{reusable} modules, developed + collaboratively. + + To make use of such modules, the \sTeX system needs to be told + where to find them. There are several ways to do so (see + \sref[file=stex-mathhub]{sec:localmh}[in=../stex-manual, + title={\href{\basedocurl/stex-manual.pdf}{the \sTeX{}3 Manual}}]), + but the most convenient way to do so is via a system variable. + + To do so, create a directory \texttt{MathHub} somewhere on + your local file system and set the environment + variable \texttt{MATHHUB} to the file path to that directory. + + In linux, you can do so by writing + \begin{lstlisting}[language=bash] + export MATHHUB="/path/to/your/MathHub" + \end{lstlisting} + in your \verb|~/.profile| (for all shells) or \verb|~/.bashrc| + (for the bash terminal only) file. + \end{sfragment} \ No newline at end of file diff --git a/macros/latex/contrib/stex/doc/packages/stex-notesslides.tex b/macros/latex/contrib/stex/doc/packages/stex-notesslides.tex new file mode 100644 index 0000000000..75fd9ee9e8 --- /dev/null +++ b/macros/latex/contrib/stex/doc/packages/stex-notesslides.tex @@ -0,0 +1,243 @@ +\begin{sfragment}{Introduction} + The \pkg{notesslides} document class is derived from |beamer.cls|~\cite{beamerclass:on}, +it adds a ``notes version'' for course notes that is more suited to printing than the one +supplied by |beamer.cls|. + +The \pkg{notesslides} class takes the notion of a slide frame from Till Tantau's excellent +\pkg{beamer} class and adapts its notion of frames for use in the \sTeX and \omdoc. To +support semantic course notes, it extends the notion of mixing frames and explanatory +text, but rather than treating the frames as images (or integrating their contents into +the flowing text), the \pkg{notesslides} package displays the slides as such in the course +notes to give students a visual anchor into the slide presentation in the course (and to +distinguish the different writing styles in slides and course notes). + +In practice we want to generate two documents from the same source: the slides for +presentation in the lecture and the course notes as a narrative document for home +study. To achieve this, the \pkg{notesslides} class has two modes: \emph{slides mode} and +\emph{notes mode} which are determined by the package option. +\end{sfragment} + +\begin{sfragment}{Package Options} + The \pkg{notesslides} class takes a variety of class options: + + \begin{variable}{slides,notes} The options |slides| and |notes| switch between slides + mode and notes mode (see \sref{sec:user:notesslides}). + \end{variable} + + \begin{variable}{sectocframes} If the option |sectocframes| is given, then for the + |sfragment|s, special frames with the |sfragment| title (and number) are generated. + \end{variable} + + \begin{variable}{frameimages,fiboxed} + If the option |frameimages| is set, then slide mode also shows the + |\frameimage|-generated frames (see \sref{sec:user:frameimage}). If also the |fiboxed| + option is given, the slides are surrounded by a box. + \end{variable} +\end{sfragment} + +\begin{sfragment}[id=sec:user:notesslides]{Notes and Slides} + +\begin{environment}{frame} + Slides are represented with the |frame| environment just like in the \pkg{beamer} class, + see~\cite{Tantau:ugbc} for details. +\end{environment} + +\begin{environment}{note} + The \pkg{notesslides} class adds the |note| environment for encapsulating the course + note fragments. +\end{environment} + +\begin{dangerbox} + Note that it is essential to start and end the |notes| environment at the start of the + line -- in particular, there may not be leading blanks -- else {\LaTeX} becomes confused + and throws error messages that are difficult to decipher. +\end{dangerbox} + +By interleaving the |frame| and |note| environments, we can build course notes as shown +here: + +\begin{latexcode} +\ifnotes\maketitle\else +\frame[noframenumbering]\maketitle\fi + +\begin{note} + We start this course with ... +\end{note} + +\begin{frame} + \frametitle{The first slide} + ... +\end{frame} +\begin{note} + ... and more explanatory text +\end{note} + +\begin{frame} + \frametitle{The second slide} + ... +\end{frame} +... +\end{latexcode} + +\begin{function}{\ifnotes} + Note the use of the |\ifnotes| conditional, which allows different treatment between + |notes| and |slides| mode -- manually setting |\notestrue| or |\notesfalse| is strongly + discouraged however. +\end{function} + +\begin{dangerbox} + We need to give the title frame the |noframenumbering| option so that the frame + numbering is kept in sync between the slides and the course notes. +\end{dangerbox} + +\begin{dangerbox} + The \pkg{beamer} class recommends not to use the |allowframebreaks| option on frames + (even though it is very convenient). This holds even more in the |notesslides| case: At + least in conjunction with |\newpage|, frame numbering behaves funnily (we have tried to + fix this, but who knows). +\end{dangerbox} +\end{sfragment} + +\begin{function}{\inputref*} + If we want to transclude a the contents of a file as a note, we can use a new variant + |\inputref*| of the |\inputref| macro: |\inputref*{foo}| is equivalent to + |\begin{note}\inputref{foo}\end{note}|. +\end{function} + +\begin{environment}{nparagraph, nparagraph, ndefinition, nexample, nsproof, nassertion} + There are some environments that tend to occur at the top-level of |note| + environments. We make convenience versions of these: e.g. the |nparagraph| environment + is just an |sparagraph| inside a |note| environment (but looks nicer in the source, + since it avoids one level of source indenting). Similarly, we have the |nfragment|, + |ndefinition|, |nexample|, |nsproof|, and |nassertion| environments. +\end{environment} + +\begin{sfragment}{Customizing Header and Footer Lines} + The \pkg{notesslides} package and class comes with a simple default theme named + \pkg{sTeX} that provided by the \pkg{beamterthemesTeX}. It is assumed as the default + theme for \sTeX-based notes and slides. + The result in |notes| mode (which is like the |slides| version except that the slide + hight is variable) is + + \includegraphics[width=.95\textwidth]{\libfolder{img/notes-frame}} + +The footer line can be customized. In particular the logos. + +\begin{function} {\setslidelogo} + The default logo provided by the \pkg{notesslides} package is the {\sTeX} logo it can be + customized using |\setslidelogo{|\meta{logo name}|}|. +\end{function} + +\begin{function}{\setsource} + The default footer line of the \pkg{notesslides} package mentions copyright and + licensing. In \pkg{notesslides} |\source| stores the author's name as the copyright + holder. By default it is the author's name as defined in the |\author| macro in the + preamble. |\setsource{|\meta{name}|}| can change the writer's name. +\end{function} + +\begin{function}{\setlicensing} + For licensing, we use the Creative Commons Attribuition-ShareAlike license by default to + strengthen the public domain. If package |hyperref| is loaded, then we can attach a + hyperlink to the license logo. |\setlicensing[|\meta{url}|]{|\meta{logo name}|}| is used + for customization, where \meta{url} is optional. +\end{function} +\end{sfragment} + +\begin{sfragment}[id=sec:user:frameimages]{Frame Images} + Sometimes, we want to integrate slides as images after all -- e.g. because we already +have a PowerPoint presentation, to which we want to add \sTeX notes. + +\begin{function}{\frameimage,\mhframeimage} + In this case we can use |\frameimage[|\meta{opt}|]{|\meta{path}|}|, where \meta{opt} are + the options of |\includegraphics| from the \pkg{graphicx} package~\cite{CarRah:tpp99} + and \meta{path} is the file path (extension can be left off like in + |\includegraphics|). We have added the |label| key that allows to give a frame label + that can be referenced like a regular |beamer| frame. + +The |\mhframeimage| macro is a variant of |\frameimage| with repository support. Instead +of writing +\begin{latexcode} +\frameimage{\MathHub{fooMH/bar/source/baz/foobar}} +\end{latexcode} + we can simply write (assuming that |\MathHub| is defined as above) +\begin{latexcode} +\mhframeimage[fooMH/bar]{baz/foobar} +\end{latexcode} + Note that the |\mhframeimage| form is more semantic, which allows more advanced document +management features in \textsf{MathHub}. +\end{function} + +If |baz/foobar| is the ``current module'', i.e. if we are on the \textsf{MathHub} path +\ldots|MathHub/fooMH/bar|\ldots, then stating the repository in the first optional +argument is redundant, so we can just use +\begin{latexcode} +\mhframeimage{baz/foobar} +\end{latexcode} +\end{sfragment} + +\begin{function}{\textwarning} + The |\textwarning| macro generates a warning sign: \textwarning +\end{function} + +\begin{sfragment}[id=sec:user:excursions]{Excursions} +In course notes, we sometimes want to point to an ``excursion'' -- material that is either +presupposed or tangential to the course at the moment -- e.g. in an appendix. The typical +setup is the following: + +\begin{latexcode} +\excursion{founif}{../fragments/founif.en} + {We will cover first-order unification in} +... +\begin{appendix}\printexcursions\end{appendix} +\end{latexcode} + +It generates a paragraph that references the excursion whose source is in the file +|../fragments/founif.en.tex| and automatically books the file for the |\printexcursions| +command that is used here to put it into the appendix. We will look at the mechanics now. + +\begin{function}{\excursion} + The |\excursion{|\meta{ref}|}{|\meta{path}|}{|\meta{text}|}| is syntactic sugar for + +\begin{latexcode} +\begin{nparagraph}[title=Excursion] + \activateexcursion{founif}{../ex/founif} + We will cover first-order unification in \sref{founif}. +\end{nparagraph} +\end{latexcode} +\end{function} + +\begin{function}{\activateexcursion,\printexcursion,\excursionref} + Here |\activateexcursion{|\meta{path}|}| augments the |\printexcursions| macro by a call + |\inputref{|\meta{path}|}|. In this way, the |\printexcursions| macro (usually in the + appendix) will collect up all excursions that are specified in the main text. + + Sometimes, we want to reference -- in an excursion -- part of another. We can use + |\excursionref{|\meta{label}|}| for that. +\end{function} + +\begin{function}{\excursiongroup} + Finally, we usually want to put the excursions into an |sfragment| environment and add + an introduction, therefore we provide the a variant of the |\printexcursions| macro: + |\excursiongroup[id=|\meta{id}|,intro=|\meta{path}|]| is equivalent to +\begin{latexcode} +\begin{note} +\begin{sfragment}[id=]{Excursions} + \inputref{} + \printexcursions +\end{sfragment} +\end{note} +\end{latexcode} +\end{function} +\end{sfragment} + +\begin{dangerbox} + When option |book| which uses |\pagestyle{headings}| is given and semantic macros are + given in the |sfragment| titles, then they sometimes are not defined by the time the + heading is formatted. Need to look into how the headings are made. This is a problem of + the underlying \pkg{document-structure} package. +\end{dangerbox} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: "../stex-manual" +%%% End: diff --git a/macros/latex/contrib/stex/doc/packages/stex-problem.tex b/macros/latex/contrib/stex/doc/packages/stex-problem.tex index a90c36412d..53316b28bc 100644 --- a/macros/latex/contrib/stex/doc/packages/stex-problem.tex +++ b/macros/latex/contrib/stex/doc/packages/stex-problem.tex @@ -1,4 +1,5 @@ -The \pkg{problem} package supplies an infrastructure that allows specify problem. Problems +\begin{sfragment}{Introduction} + The \pkg{problem} package supplies an infrastructure that allows specify problem. Problems are text fragments that come with auxiliary functions: hints, notes, and solutions\footnote{for the moment multiple choice problems are not supported, but may well be in a future version}. Furthermore, we can specify how long the solution to a @@ -7,7 +8,11 @@ solution. Finally, the \pkg{problem} package facilitates the management of problems in small files, so that problems can be re-used in multiple environment. +\end{sfragment} + +\begin{sfragment}{Problems and Solutions} + \begin{function}{solutions,notes,hints,gnotes,pts,min,boxed,test} The \pkg{problem} package takes the options |solutions| (should solutions be output?), |notes| (should the problem notes be presented?), |hints| (do we give the hints?), @@ -43,7 +48,7 @@ so that problems can be re-used in multiple environment. \begin{exnote} Justify your answer \end{exnote} -\begin{solution}[for=elefants,height=3cm] +\begin{solution}[for=elefants] Four, two in the front seats, and two in the back. \begin{gnote} if they do not give the justification deduct 5 pts @@ -66,7 +71,7 @@ so that problems can be re-used in multiple environment. \begin{environment}{hint,exnote,gnote} The |hint| and |exnote| environments can be used in a |problem| environment to give hints and to make notes that elaborate certain aspects of the problem. The |gnote| - (grading notes) environment can be used to document situtations that may arise in + (grading notes) environment can be used to document situations that may arise in grading. \end{environment} @@ -80,7 +85,22 @@ so that problems can be re-used in multiple environment. Also, sometimes, we want content (e.g. in an exam with master solutions) conditional on whether solutions are shown. This can be done with the |\ifsolutions| conditional. \end{function} +\end{sfragment} + +\begin{sfragment}{Markup for Added-Value Services} + +\begin{sparagraph} + The |problem| package is all about specifying the meaning of the various moving parts of + practice/exam problems. The motivation for the additional markup is that we can base + added-value services from these, for instance auto-grading and immediate feedback. + The simplest example of this are multiple-choice problems, where the |problem| package + allows to annotate answer options with the intended values and possibly feedback that + can be delivered to the users in an interactive setting. In this section we will give + some infrastructure for these, we expect that this will grow over time. +\end{sparagraph} + +\begin{sfragment}{Multiple Choice Blocks} \begin{environment}{mcb} Multiple choice blocks can be formatted using the |mcb| environment, in which single choices are marked up with |\mcc| macro. @@ -96,8 +116,8 @@ so that problems can be re-used in multiple environment. \item |feedback| for a short feedback text given to the student. \end{itemize} \end{function} - -If we start the solutions, then we get +What we see when this is formatted to PDF depends on the context. In solutions mode (we +start the solutions in the code fragment below) we get \stexexample{% \startsolutions @@ -111,8 +131,8 @@ If we start the solutions, then we get \end{mcb} \end{sproblem} } -without solutions (that is what the students see during the exam/quiz)\ednote{MK: that did -not work!} + +In ``exam mode'' where disable solutions (here via |\stopsolutions|) \stexexample{% \stopsolutions \begin{sproblem}[title=Functions,name=functions1] @@ -125,7 +145,44 @@ not work!} \end{mcb} \end{sproblem} } - +we get the questions without solutions (that is what the students see during the +exam/quiz). +\end{sfragment} + +\begin{sfragment}{Filling-In Concrete Solutions} +The next simplest situation, where we can implement auto-grading is the case where we +have fill-in-the-blanks + +\begin{function}{\fillinsol} + The |\fillinsol| macro takes\Ednote{for now; more to come} an a single argument, which + contains a concrete solution (i.e. a number, a string, \ldots), which generates a + fill-in-box in test mode: +\stexexample{% + \stopsolutions + \begin{sproblem}[id=elefants.fillin,title=Fitting Elefants] + How many Elefants can you fit into a Volkswagen beetle? \fillinsol{4} +\end{sproblem}} + and the actual solution in solutions mode: +\end{function} +\stexexample{% + \begin{sproblem}[id=elefants.fillin,title=Fitting Elefants] + How many Elefants can you fit into a Volkswagen beetle? \fillinsol{4} + \end{sproblem}} +If we do not want to leak information about the solution by the size of the blank we can +also give |\fillinsol| an optional argument with a size: |\fillinsol[3cm]{12}| makes a box + three cm wide. + + Obviously, the required argument of |\fillinsol| can be used for auto-grading. For + concrete data like numbers, this is immediate, for more complex data like strings ``soft + comparisons'' might be in order. \ednote{For the moment we only assume a single concrete + value as correct. In the future we will almost certainly want to extend the + functionality to multiple answer classes that allow different feedback like im + MCQ. This still needs a bit of design. Also we want to make the formatting of the + answer in solutions/test mode configurable.} +\end{sfragment} +\end{sfragment} + +\begin{sfragment}{Including Problems} \begin{function}{\includeproblem} The |\includeproblem| macro can be used to include a problem from another file. It takes an optional KeyVal argument and a second argument which is a path to the file containing @@ -144,8 +201,32 @@ The |\min| and |\pts| macros allow to specify (i.e. to print to the margin) the distribution of time and reward to parts of a problem, if the |pts| and |pts| options are set. This allows to give students hints about the estimated time and the points to be awarded. +\end{sfragment} + +\begin{sfragment}{Testing and Spacing} +The |problem| package is often used by the |hwexam| package, which is used to create +homework assignments and exams. Both of these have a ``test mode'' (invoked by the +package option |test|), where certain information --master solutions or feedback -- is +not shown in the presentation. + +\DescribeMacro{\testspace}|\testspace| takes an argument that expands to a dimension, and +leaves vertical space accordingly. Specific instances exist: +\DescribeMacro{\testsmallspace}|\testsmallspace|, +\DescribeMacro{\testsmallspace}|\testsmallspace|, +\DescribeMacro{\testsmallspace}|\testsmallspace| give small (1cm), medium (2cm), and big (3cm) +vertical space. + +\DescribeMacro{\testnewpage}|\testnewpage| makes a new page in |test| mode, and +\DescribeMacro{\testemptypage}|\testemptypage| generates an empty page with the cautionary +message that this page was intentionally left empty. +\end{sfragment} %%% Local Variables: %%% mode: latex %%% TeX-master: "../stex-manual" %%% End: + +% LocalWords: solutions,notes,hints,gnotes,pts,min,boxed,test gnotes elefants,pts gnote +% LocalWords: 2,title exnote hint,exnote,gnote ifsolutions mcb keyvals Ttext Ftext +% LocalWords: Functions,name F,feedback Nooooooooo,feedback 2,title includeproblem +% LocalWords: elefants.fillin,title diff --git a/macros/latex/contrib/stex/doc/packages/stex-proofs.tex b/macros/latex/contrib/stex/doc/packages/stex-proofs.tex index d06db1282f..9e6e44f5ca 100644 --- a/macros/latex/contrib/stex/doc/packages/stex-proofs.tex +++ b/macros/latex/contrib/stex/doc/packages/stex-proofs.tex @@ -1,100 +1,308 @@ +\begin{sfragment}{Proofs} + The \pkg{stex-proof} package supplies macros and environment that allow to annotate the structure of mathematical proofs in \sTeX document. This structure can be used by MKM systems for added-value services, either directly from the \sTeX sources, or after translation. -We will go over the general intuition by way of a running example: +Its central component is the |sproof|-environment, whose body consists +of: +\begin{itemize} + \item \emph{subproofs} via the |subproof|-environment, + \item \emph{proof steps} via the |\spfstep|, |\eqstep| + |\assumption|, and |\conclude| macros, and + \item \emph{comments}, via normal text without special markup. +\end{itemize} + +|sproof|, |subproof| and the various proof step macros take the following +optional arguments: +\begin{itemize} + \item[|id|] (\meta{string}) for referencing, + \item[|method|] (\meta{string}) the proof method (e.g. contradiction, induction,...) + \item[|term|] (\meta{token list}) the (ideally semantically-marked up) + proposition that is derived/proven by this proof/subproof/proof step. +\end{itemize} +Additionally, they take one mandatory argument for the document text +to be annotated, or (in the case of the environments) +as an introductory description of the proof itself. Since +the latter often contains the |term| to be derived +as text, alternatively to providing it as +an optional argument, the mandatory argument can use the +|\yield|-macro to mark it up in the text. + +The |sproof| and |subproof| environments additionally take +two optional arguments: +\begin{itemize} + \item[|for|] the symbol identifier/name corresponding to the |sassertion| + to be proven. This too subsumes |\yield| and the |term|-argument. + \item[|hide|] In the pdf, this only shows the mandatory argument text + and hides the body of the environment. In the HTML (as served by \mmt), + the bodies of all |proof| and |subproof| environments are \emph{collapsible}, + and |hide| collapses the body by default. +\end{itemize} + +\begin{smodule}{sproofs} + \symdef{coprime}[args=2]{#1 \comp\bot #2} + \symdef{realroot}[args=1]{\sqrt{#1}} + \symdecl{irrational}[args=1] + \symdecl{rational}[args=1] + \symdef{eq}[args=2]{#1 \comp= #2} + \symdef{ratfrac}[args=2,prec=1]{\frac{#1}{#2}} + \symdef{intpow}[args=2,prec=-1]{{#1}^{#2}} + \symdef{ratpow}[args=2]{{#1}^{#2}} + \symdef{inset}[args=ai]{#1\comp\in#2}{##1\comp,##2} + \symdef{Int}{\comp{\mathbb Z}} + \symdef{PosInt}{\comp{{\mathbb Z}^+}} + \symdef{inttimes}[args=2]{#1 #2} + \symdef{divides}[args=2]{#1\comp\|#2} + + \vardef{vara}{\comp a} + \vardef{varb}{\comp b} + \vardef{varc}{\comp c} + + \def\contradiction{} \begin{latexcode} -\begin{sproof}[id=simple-proof] + \begin{sassertion}[type=theorem,name=sqrt2irr] + \conclusion{\irrational{$\arg{\realroot{2}}$ is \comp{irrational}}}. +\end{sassertion} + +\begin{sproof}[for=sqrt2irr,method=contradiction]{By contradiction} + \assumption{Assume \yield{\rational{$\arg{\realroot{2}}$ is + \comp{rational}}}} + \begin{subproof}[method=straightforward]{Then + \yield{$\eq{\ratfrac{\intpow{\vara}{2}}{\intpow{\varb}2}}{2}$ + for some $\inset{\vara,\varb}\PosInt$ with + \coprime{$\arg{\vara},\arg{\varb}$ \comp{coprime}}}} + \assumption{By assumption, \yield{there are + $\inset{\vara,\varb}\PosInt $ with + $\realroot{2}=\ratfrac{\vara}{\varb}$}} + \spfstep{wlog, we can assume \coprime{$\arg{\vara},\arg{\varb}$ + to be \comp{coprime}}} + % a comment: + If not, reduce the fraction until numerator and denominator + are coprime, and let the resulting components be + $\vara $ and $\varb $ + \spfstep{Then \yield{$\eq{\intpow{\ratfrac{\vara}{\varb}}2}2$}} + \eqstep{\ratfrac{\intpow{\vara}2}{\intpow{\varb}2}} + \end{subproof} + \begin{subproof}[term=\divides{2}{\vara},method=straightforward]{ + Then $\vara $ is even} + \spfstep{Multiplying the equation by $\intpow{\varb}2$ yields + $\yield{\eq{\intpow{\vara}2}{\inttimes{2}{\intpow{\varb}2}}}$} + \spfstep[term=\divides{2}{\intpow{\vara}2}]{Hence + $\intpow{\vara}2$ is even} + \conclude[term=\divides{2}{\vara}]{Hence $\vara $ is even as well} + % another comment: + Hint: Think about the prime factorizations of $\vara $ and + $\intpow{\vara}2$ + \end{subproof} + \begin{subproof}[term=\divides{2}{\varb},method=straightforward,]{ + Then $\varb $ is also even} + \spfstep{Since $\vara $ is even, we have \yield{some $\varc $ + such that $\eq{\inttimes{2}{\varc}}{\vara}$}} + \spfstep{Plugging into the above, we get + \yield{$\eq{\intpow{\inttimes{2}{\vara}}2} + {\inttimes{2}{\intpow{\varb}2}}$}} + \eqstep{\inttimes{4}{\intpow{\vara}2}} + \spfstep{Dividing both sides by $2$ yields + \yield{$\eq{\intpow{\varb}2}{\inttimes{2}{\intpow{\vara}2}}$}} + \spfstep[term=\divides{2}{\intpow{\varb}2}]{Hence + $\intpow{\varb}2$ is even} + \conclude[term=\divides{2}{\varb}]{Hence $\varb $ is even} + % one more comment: + By the same argument as above + \end{subproof} + \conclude[term=\contradiction]{Contradiction to $\vara,\varb $ being + \symname{coprime}.} +\end{sproof} +\end{latexcode} + +which will produce: + +\begin{mdframed} +\begin{sassertion}[type=theorem,name=sqrt2irr] + \conclusion{\irrational{$\arg{\realroot2}$ is \comp{irrational}}}. +\end{sassertion} + +\begin{sproof}[for=sqrt2irr,method=contradiction]{By contradiction} + \assumption{Assume \yield{\rational{$\arg{\realroot2}$ is \comp{rational}}}} + \begin{subproof}[method=straightforward]% + {Then \yield{$\eq{\ratfrac{\intpow \vara2}{\intpow \varb2}}{2}$ for some $\inset{\vara,\varb}\PosInt$ with \coprime{$\arg \vara,\arg \varb$ \comp{coprime}}}} + \assumption{By assumption, \yield{there are $\inset{\vara,\varb}\PosInt$ with $\realroot2=\ratfrac\vara\varb$}} + \spfstep{wlog, we can assume \coprime{$\arg{\vara},\arg{\varb}$ to be \comp{coprime}}} + If not, reduce the fraction until numerator and denominator are + coprime, and let the resulting components be $\vara$ and $\varb$ + \spfstep{Then \yield{$\eq{\intpow{\ratfrac\vara\varb}2}2$}} + \eqstep{\ratfrac{\intpow\vara2}{\intpow\varb2}} + \end{subproof} + \begin{subproof}[term=\divides{2}{\vara},method=straightforward]{Then $\vara$ is even} + \spfstep{Multiplying the equation by $\intpow\varb2$ yields $\yield{\eq{\intpow\vara2}{\inttimes2{\intpow\varb2}}}$} + \spfstep[term=\divides{2}{\intpow\vara2}]{Hence $\intpow\vara2$ is even} + \conclude[term=\divides{2}{\vara}]{Hence $\vara$ is even as well} + Hint: Think about the prime factorizations of $\vara$ and $\intpow\vara2$ + \end{subproof} + \begin{subproof}[term=\divides{2}{\varb},method=straightforward]{Then $\varb$ is also even} + \spfstep{Since $\vara$ is even, we have \yield{some $\varc$ such that $\eq{\inttimes2\varc}{\vara}$}} + \spfstep{Plugging into the above, we get \yield{$\eq{\intpow{\inttimes2\vara}2}{\inttimes2{\intpow\varb2}}$}} + \eqstep{\inttimes4{\intpow\vara2}} + \spfstep{Dividing both sides by $2$ yields \yield{$\eq{\intpow\varb2}{\inttimes2{\intpow\vara2}}$}} + \spfstep[term=\divides{2}{\intpow\varb2}]{Hence $\intpow\varb2$ is even} + \conclude[term=\divides{2}{\varb}]{Hence $\varb$ is even} + By the same argument as above + \end{subproof} + \conclude[term=\contradiction]{Contradiction to $\vara,\varb$ being \symname{coprime}.} +\end{sproof} +\end{mdframed} + +If we mark all subproofs with |hide|, we will obtain the following +instead: + +\begin{mdframed} + \begin{sassertion}[type=theorem,name=sqrt2irr] + \conclusion{\irrational{$\arg{\realroot2}$ is \comp{irrational}}}. + \end{sassertion} + + \begin{sproof}[for=sqrt2irr,method=contradiction]{By contradiction} + \assumption{Assume \yield{\rational{$\arg{\realroot2}$ is \comp{rational}}}} + \begin{subproof}[hide,method=straightforward]% + {Then \yield{$\eq{\ratfrac{\intpow \vara2}{\intpow \varb2}}{2}$ for some $\inset{\vara,\varb}\PosInt$ with \coprime{$\arg \vara,\arg \varb$ \comp{coprime}}}} + \assumption{By assumption, \yield{there are $\inset{\vara,\varb}\PosInt$ with $\realroot2=\ratfrac\vara\varb$}} + \spfstep{wlog, we can assume \coprime{$\arg{\vara},\arg{\varb}$ to be \comp{coprime}}} + If not, reduce the fraction until numerator and denominator are + coprime, and let the resulting components be $\vara$ and $\varb$ + \spfstep{Then \yield{$\eq{\intpow{\ratfrac\vara\varb}2}2$}} + \eqstep{\ratfrac{\intpow\vara2}{\intpow\varb2}} + \end{subproof} + \begin{subproof}[hide,term=\divides{2}{\vara},method=straightforward]{Then $\vara$ is even} + \spfstep{Multiplying the equation by $\intpow\varb2$ yields $\yield{\eq{\intpow\vara2}{\inttimes2{\intpow\varb2}}}$} + \spfstep[term=\divides{2}{\intpow\vara2}]{Hence $\intpow\vara2$ is even} + \conclude[term=\divides{2}{\vara}]{Hence $\vara$ is even as well} + Hint: Think about the prime factorizations of $\vara$ and $\intpow\vara2$ + \end{subproof} + \begin{subproof}[hide,term=\divides{2}{\varb},method=straightforward,]{Then $\varb$ is also even} + \spfstep{Since $\vara$ is even, we have \yield{some $\varc$ such that $\eq{\inttimes2\varc}{\vara}$}} + \spfstep{Plugging into the above, we get \yield{$\eq{\intpow{\inttimes2\vara}2}{\inttimes2{\intpow\varb2}}$}} + \eqstep{\inttimes4{\intpow\vara2}} + \spfstep{Dividing both sides by $2$ yields \yield{$\eq{\intpow\varb2}{\inttimes2{\intpow\vara2}}$}} + \spfstep[term=\divides{2}{\intpow\varb2}]{Hence $\intpow\varb2$ is even} + \conclude[term=\divides{2}{\varb}]{Hence $\varb$ is even} + By the same argument as above + \end{subproof} + \conclude[term=\contradiction]{Contradiction to $\vara,\varb$ being \symname{coprime}.} + \end{sproof} + \end{mdframed} + + However, the hidden subproofs will still be shown in the HTML, + only in an expandable section which is collapsed by default. + + +The above style of writing proofs is usually called \emph{structured proofs}. +They have a huge advantage over the traditional purely prosaic style, +in that (as the name suggests) the actual \emph{structure} of the proof +is made explicit, which almost always makes it considerably more +comprehensible. We, among many others, encourage the general use of +structured proofs. + +Alas, most proofs are not written in this style, and we would +do users a disservice by insisting on this style. For that reason, +the |spfblock| environment turns all subproofs and proof step +macros into presentationally neutral \emph{inline} annotations, +as in the induction step of the following example: + +\begin{latexcode} +\begin{sproof}[id=simple-proof,method=induction] {We prove that $\sum_{i=1}^n{2i-1}=n^{2}$ by induction over $n$} - \begin{spfcases}{For the induction we have to consider three cases:} - \begin{spfcase}{$n=1$} - \begin{spfstep}[type=inline] then we compute $1=1^2$\end{spfstep} - \end{spfcase} - \begin{spfcase}{$n=2$} - \begin{spfcomment}[type=inline] + For the induction we have to consider three cases: % <- a comment + \begin{subproof}{$n=1$} + \spfstep*{then we compute $1=1^2$} + \end{subproof} + \begin{subproof}{$n=2$} This case is not really necessary, but we do it for the fun of it (and to get more intuition). - \end{spfcomment} - \begin{spfstep}[type=inline] We compute $1+3=2^{2}=4$.\end{spfstep} - \end{spfcase} - \begin{spfcase}{$n>1$} - \begin{spfstep}[type=assumption,id=ind-hyp] + \spfstep*{We compute $1+3=2^{2}=4$.} + \end{subproof} + \begin{subproof}{$n>1$}\begin{spfblock} + \assumption[id=ind-hyp]{ Now, we assume that the assertion is true for a certain $k\geq 1$, - i.e. $\sum_{i=1}^k{(2i-1)}=k^{2}$. - \end{spfstep} - \begin{spfcomment} + i.e. \yield{$\sum_{i=1}^k{(2i-1)}=k^{2}$}. + } + We have to show that we can derive the assertion for $n=k+1$ from this assumption, i.e. $\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$. - \end{spfcomment} - \begin{spfstep} - We obtain $\sum_{i=1}^{k+1}{2i-1}=\sum_{i=1}^k{2i-1}+2(k+1)-1$ - \spfjust[method=arith:split-sum]{by splitting the sum}. - \end{spfstep} - \begin{spfstep} - Thus we have $\sum_{i=1}^{k+1}{(2i-1)}=k^2+2k+1$ - \spfjust[method=fertilize]{by inductive hypothesis}. - \end{spfstep} - \begin{spfstep}[type=conclusion] - We can \spfjust[method=simplify]{simplify} the right-hand side to + + \spfstep{ + We obtain $\yield{\sum_{i=1}^{k+1}{2i-1}= + \sum_{i=1}^k{2i-1}+2(k+1)-1}$ + \spfjust{by \splitsum{\comp{splitting the sum} + \arg*{$\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$}}}. + } + \spfstep{ + Thus we have $\yield{\sum_{i=1}^{k+1}{(2i-1)}=k^2+2k+1}$ + \spfjust{by \symname{induction-hypothesis}}. + } + \conclude{ + We can \spfjust{\simplification{\comp{simplify} the right-hand side + \arg*{k^2+2k+1}}} to ${k+1}^2$, which proves the assertion. - \end{spfstep} - \end{spfcase} - \begin{spfstep}[type=conclusion] + } + \end{spfblock}\end{subproof} + \conclude{ We have considered all the cases, so we have proven the assertion. - \end{spfstep} - \end{spfcases} + } \end{sproof} \end{latexcode} + +\symdecl{splitsum}[args=1] +\symdecl{inducthypothesis}[name=induction-hypothesis] +\symdecl{simplification}[args=1] + This yields the following result: \begin{mdframed} - \begin{sproof}[id=simple-proof] - {We prove that $\sum_{i=1}^n{2i-1}=n^{2}$ by induction over $n$} - \begin{spfcases}{For the induction we have to consider the following cases:} - \begin{spfcase}{$n=1$} - \begin{spfstep}[type=inline] then we compute $1=1^2$\end{spfstep} - \end{spfcase} - \begin{spfcase}{$n=2$} - \begin{spfcomment}[type=inline] - This case is not really necessary, but we do it for the fun - of it (and to get more intuition). - \end{spfcomment} - \begin{spfstep}[type=inline] - We compute $1+3=2^{2}=4$ - \end{spfstep} - \end{spfcase} - \begin{spfcase}{$n>1$} - \begin{spfstep}[type=hypothesis,id=ind-hyp] - Now, we assume that the assertion is true for a certain $k\geq 1$, i.e. - $\sum_{i=1}^k{(2i-1)}=k^{2}$. - \end{spfstep} - \begin{spfcomment} - We have to show that we can derive the assertion for $n=k+1$ from this - assumption, i.e. $\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$. - \end{spfcomment} - \begin{spfstep}[id=splitit] - We obtain $\sum_{i=1}^{k+1}{(2i-1)}=\sum_{i=1}^k{(2i-1)}+2(k+1)-1$ - \spfjust[method=arith:split-sum]{by splitting the sum}. - \end{spfstep} - \begin{spfstep}[id=byindhyp] - Thus we have $\sum_{i=1}^{k+1}{(2i-1)}=k^2+2k+1$ - \spfjust[method=fertilize]{by \premise[ind-hyp]{inductive hypothesis}}. - \end{spfstep} - \begin{spfstep}[type=conclusion] - We can \spfjust[method=simplify-eq]{simplify the \justarg[rhs]{right-hand side}} to - $(k+1)^2$, which proves the assertion. - \end{spfstep} - \end{spfcase} - \begin{spfstep}[type=conclusion] - We have considered all the cases, so we have proven the assertion. - \end{spfstep} - \end{spfcases} -\end{sproof} + \begin{sproof}[id=simple-proof,method=induction] + {We prove that $\sum_{i=1}^n{2i-1}=n^{2}$ by induction over $n$} + For the induction we have to consider three cases: % <- a comment + \begin{subproof}{$n=1$} + \spfstep*{then we compute $1=1^2$} + \end{subproof} + \begin{subproof}{$n=2$} + This case is not really necessary, but we do it for the + fun of it (and to get more intuition). + \spfstep*{We compute $1+3=2^{2}=4$.} + \end{subproof} + \begin{subproof}{$n>1$}\begin{spfblock} + \assumption[id=ind-hyp]{ + Now, we assume that the assertion is true for a certain $k\geq 1$, + i.e. \yield{$\sum_{i=1}^k{(2i-1)}=k^{2}$}. + } + + We have to show that we can derive the assertion for $n=k+1$ from + this assumption, i.e. $\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$. + + \spfstep{ + We obtain $\yield{\sum_{i=1}^{k+1}{2i-1}=\sum_{i=1}^k{2i-1}+2(k+1)-1}$ + \spfjust{by \splitsum{\comp{splitting the sum}\arg*{$\sum_{i=1}^{k+1}{(2i-1)}=(k+1)^{2}$}}}. + } + \spfstep{ + Thus we have $\yield{\sum_{i=1}^{k+1}{(2i-1)}=k^2+2k+1}$ + \spfjust{by \symname{induction-hypothesis}}. + } + \conclude{ + We can \spfjust{\simplification{\comp{simplify} the right-hand side + \arg*{k^2+2k+1}}} to + ${k+1}^2$, which proves the assertion. + } + \end{spfblock}\end{subproof} + \conclude{ + We have considered all the cases, so we have proven the assertion. + } + \end{sproof} \end{mdframed} +\end{smodule} + \begin{environment}{sproof} The |sproof| environment is the main container for proofs. It takes an optional |KeyVal| argument that allows to specify the |id| (identifier) and |for| (for which assertion is @@ -114,78 +322,39 @@ This yields the following result: the proof. \end{function} -\begin{environment}{spfstep} - Regular proof steps are marked up with the |step| environment, which takes an optional +\begin{function}{\spfstep} + Regular proof steps are marked up with the |\spfstep| macro, which takes an optional |KeyVal| argument for annotations. A proof step usually contains a local assertion (the text of the step) together with some kind of evidence that this can be derived from already established assertions. -\end{environment} +\end{function} + +\begin{function}{\yield} + See above +\end{function} \begin{function}{\spfjust} This evidence is marked up with the |\spfjust| macro in the \pkg{stex-proofs} package. This environment totally invisible to the formatted result; it wraps the text - in the proof step that corresponds to the evidence. The environment takes an optional - |KeyVal| argument, which can have the |method| key, whose value is the name of a proof - method (this will only need to mean something to the application that consumes the - semantic annotations). Furthermore, the justification can contain ``premises'' - (specifications to assertions that were used justify the step) and ``arguments'' - (other information taken into account by the proof method). + in the proof step that corresponds to the evidence (ideally, a + semantically marked-up term). \end{function} -\begin{function}{\premise} - The |\premise| macro allows to mark up part of the text as reference to an assertion - that is used in the argumentation. In the running example we have used the |\premise| - macro to identify the inductive hypothesis. +\begin{function}{\assumption} + The |\assumption| macro allows to mark up a (justified) assumption. \end{function} \begin{function}{\justarg} - The |\justarg| macro is very similar to |\premise| with the difference that it is used - to mark up arguments to the proof method. Therefore the content of the first argument - is interpreted as a mathematical object rather than as an identifier as in the case of - |\premise|. In our example, we specified that the simplification should take place on - the right hand side of the equation. Other examples include proof methods that - instantiate. Here we would indicate the substituted object in a |\justarg| macro. \end{function} -Note that both |\premise| and |\justarg| can be used with an empty second argument to -mark up premises and arguments that are not explicitly mentioned in the text. - \begin{environment}{subproof} - The |spfcases| environment is used to mark up a subproof. This environment takes an + The |subproof| environment is used to mark up a subproof. This environment takes an optional |KeyVal| argument for semantic annotations and a second argument that allows to specify an introductory comment (just like in the |proof| environment). The |method| key can be used to give the name of the proof method executed to make this subproof. \end{environment} -\begin{environment}{spfcases} - The |spfcases| environment is used to mark up a proof by cases. Technically it is a - variant of the |subproof| where the |method| is |by-cases|. Its contents are |spfcase| - environments that mark up the cases one by one. -\end{environment} - -\begin{environment}{spfcase} - The content of a |spfcases| environment are a sequence of case proofs marked up in the - |spfcase| environment, which takes an optional |KeyVal| argument for semantic - annotations. The second argument is used to specify the the description of the case - under consideration. The content of a |spfcase| environment is the same as that of a - |sproof|, i.e. |spfstep|s, |spfcomment|s, and |spfcases| environments. -\end{environment} - -\begin{function}{\spfcasesketch} - |\spfcasesketch| is a variant of the |spfcase| environment that takes the same - arguments, but instead of the |spfstep|s in the body uses a third argument for a proof - sketch. -\end{function} - -\begin{environment}{spfcomment} - The |spfcomment| environment is much like a |step|, only that it does not have an - object-level assertion of its own. Rather than asserting some fact that is relevant - for the proof, it is used to explain where the proof is going, what we are attempting - to to, or what we have achieved so far. As such, it cannot be the target of a - |\premise|. -\end{environment} - \begin{function}{\sproofend} Traditionally, the end of a mathematical proof is marked with a little box at the end of the last line of the proof (if there is space and on the end of the next line if there @@ -205,10 +374,14 @@ in most cases, this is desirable to make the proof structure explicit, but somet wastes space (especially, if a proof ends in a case analysis which will supply its own proof end marker). To suppress it locally, just set |proofend={}| in them or use use |\sProofEndSymbol{}|. +\end{sfragment} %%% Local Variables: %%% mode: latex %%% TeX-master: "../stex-manual" %%% End: -% LocalWords: hypothesis,id geq splitit arith:split-sum byindhyp rhs proofend +% LocalWords: hypothesis,id geq splitit arith:split-sum byindhyp rhs proofend eqstep +% LocalWords: sproofs coprime ratfrac 2,prec intpow ratpow inttimes varb varc sqrt2irr +% LocalWords: theorem,name sqrt2irr,method wlog hide,method hide,term spfblock splitsum +% LocalWords: simple-proof,method inducthypothesis diff --git a/macros/latex/contrib/stex/doc/packages/stex-references.tex b/macros/latex/contrib/stex/doc/packages/stex-references.tex index 11de003e9b..3850d644ee 100644 --- a/macros/latex/contrib/stex/doc/packages/stex-references.tex +++ b/macros/latex/contrib/stex/doc/packages/stex-references.tex @@ -1,6 +1,90 @@ -\begin{sfragment}[id=sec.references]{Referencing Symbols and Statements} -\textcolor{red}{TODO: references documentation} -\end{sfragment} +If we take features like \stexcode"\inputref" and \stexcode"\mhinput" +(and the \stexcode"sfragment"-environment, see +\sref[file=stex-document-structure]{sec:ds:intro}[in=../stex-manual,title={the \sTeX{}3 manual}]) seriously, +and build large documents modularly from individually compiling documents for sections, chapters +and so on, cross-referencing becomes an interesting problem. + +Say, we have a document |main.tex|, which \stexcode"\inputref"s a section +|section1.tex|, which references a definition with label |some_definition| in +|section2.tex| (subsequently also inputted in |main.tex|). +Then the numbering of the definition will depend on the \emph{document context} +in which the document fragment |section2.tex| occurs - in |section2.tex| itself +(as a standalone document), it might be \emph{Definition 1}, in |main.tex| it might +be \emph{Definition 3.1}, and in |section1.tex|, the definition \emph{does not even occur}, so +it needs to be referenced by some other text. + +What we would want in that instance is an equivalent of \stexcode"\autoref", that takes +the document context into account to yield something like \emph{Definition 1}, \emph{Definition 3.1} +or ``\emph{Definition 1 in the section on Foo}'' respectively. + +The \stexcode"\sref" command attempts to do precisely that. Unlike plain \stexcode"\ref", \stexcode"\autoref" +etc., \stexcode"\sref" refers to not just a \emph{label}, but instead a pair consisting of a \emph{label} +and the \emph{document} in whose context we want to refer to it. Conversely, every \emph{document} +(i.e. standalone compilable |.tex|-file) keeps track of the ``names'' (\emph{Definition 3.1} etc.) for every +label as determined in the context of the document, and stores them in a dedicated file |\jobname.sref|. +Additionally, every document has a ``\emph{reference name}'' (e.g. ``\emph{the section on Foo}''). +This allows us to refer to ``label $x$ in document $D$'' to yield ``\emph{Definition 1 in the section on Foo}''. +And of course, \sTeX can decide based on the current document to either refer to the label by its +``full name'' or directly as e.g. \emph{Definition 3.1} depending on whether the label occurs in +the current document anyway (and link to it accordingly). + +\paragraph{} For that to work, we need to supply (up to) three pieces +of information: +\begin{itemize} + \item The \emph{label} of the reference target (e.g. |some_definition|), + \item (optionally) the \emph{file}/document containing the reference target + (e.g. |section2|). + This is not strictly necessary, but allows for additional disambiguation + between possibly duplicate labels across files, and + \item (optionally) the document context, in which we want to + refer to the reference target (e.g. |main|). +\end{itemize} +Additionally, the document in which we want to reference a label needs +a title for external references. + + +\begin{function}{\sref} + \begin{syntax} \cs{sref}|[archive=|\meta{archive1}|,file=|\meta{file}|]|% + \Arg{label}|[archive=|\meta{archive2}|,in=|\meta{document-context}|,title=|\meta{title}|]| \end{syntax} + This command references \meta{label} (declared in \meta{file} in \meta{archive1}). + If the object (section, figure, etc.) with that label occurs ultimately + in the same document, \cs{sref} will ignore the second set of optional arguments + and simply defer to \cs{autoref} if that command exists, or \cs{ref} if the \pkg{hyperref} + package is not included. + + If the referenced object does \emph{not} occur in the current document however, + \cs{sref} will refer to it by the object's name as it occurs in + the file \meta{document-context} in \meta{archive2}. + +For example, the reference to the \stexcode"sfragment"-environment above +will appear as ``subsection 7.2.1 (Introduction) in the \sTeX{}3 manual'' +if you are reading this in the package documentation for |stex-references| +directly, but as a linked ``subsection 7.2.1'' in the full documentation +or manual. This is achieved using + +\stexcode"\sref[file=stex-document-structure]{sec:ds:intro}[in=../stex-manual,title={the \sTeX{}3 manual}]". + +\end{function} + +For a further example, the following: +\begin{center} + \sref[file=../stex-doc]{part:extends}[in=../stex-doc,title={the full \sTeX{}3 documentation}] +\end{center} +will say ``Part III'' (and link accordingly) in the full documentation, +and ``Part III (Extensions) in the full \sTeX{}3 documentation'' +everywhere else. This is achieved using + +\stexcode"\sref[file=../stex-doc]{part:extends}[in=../stex-doc,title={the full \sTeX{}3 documentation}]". + +\begin{function}{\extref} + \begin{syntax} \cs{sref}|[archive=|\meta{archive1}|,file=|\meta{file}|]|% + \Arg{label}|{archive=|\meta{archive2}|,in=|\meta{document-context}|,title=|\meta{title}|}| \end{syntax} + The \cs{extref}-command behaves exactly like \cs{sref}, but takes + \emph{required} the document context argument and will always use it + for generating the document text, regardless of whether the label + occurs in the current document. +\end{function} + %%% Local Variables: %%% mode: latex diff --git a/macros/latex/contrib/stex/doc/packages/stex-setup.tex b/macros/latex/contrib/stex/doc/packages/stex-setup.tex new file mode 100644 index 0000000000..7e0e1fe4a4 --- /dev/null +++ b/macros/latex/contrib/stex/doc/packages/stex-setup.tex @@ -0,0 +1,34 @@ +\begin{sfragment}{Setting up the \sTeX Package} + + \begin{sfragment}[id=sec.minimal-setup]{Minimal Setup for the \sTeX Package} + In the best of all worlds, there is no setup, as you already have a new version of + {\TeX}Live on your system as a {\LaTeX} enthusiast. If not now is the time to + install it; see \cite{TeXLive:on}. You can usually update {\TeX}Live via a package + manager or the {\TeX}Live manager \textbf{tlmgr}. + \sTeX requires a \TeX{} kernel newer than February 2022. + + Alternatively, you can install \sTeX from CTAN, the Comprehensive {\TeX} Archive + Network; see \cite{stexCTAN:on} for details. We + assume you have the \sTeX package in at least version 3.2 (September 2022). + \end{sfragment} + + \begin{sfragment}[id=sec.git-setup]{GIT-based Setup for the \sTeX Development Version} + If you want use the latest and greatest \sTeX packages + that have not even been released to CTAN, + then you can directly clone them from the \sTeX development + repository \cite{sTeX:github:on} by the following command-line instructions: + \begin{lstlisting}[language=bash] + cd + git clone https://github.com/slatex/sTeX.git + \end{lstlisting} + and keep it updated by pulling updates via \lstinline|git pull| in the cloned \sTeX + directory. + Make sure to either clone the \sTeX repository into a local texmf-tree or to update your \lstinline|TEXINPUTS| environment variable, e.g. by placing the following line in your \lstinline|.bashrc|: + \begin{lstlisting}[language=bash] + export TEXINPUTS="$(TEXINPUTS)://:" + \end{lstlisting} + \end{sfragment} + + \input{packages/stex-mathhubsetup} + +\end{sfragment} \ No newline at end of file diff --git a/macros/latex/contrib/stex/doc/packages/stex-slides.tex b/macros/latex/contrib/stex/doc/packages/stex-slides.tex deleted file mode 100644 index a900c1fcbb..0000000000 --- a/macros/latex/contrib/stex/doc/packages/stex-slides.tex +++ /dev/null @@ -1,212 +0,0 @@ -The \pkg{notesslides} document class is derived from |beamer.cls|~\cite{beamerclass:on}, -it adds a ``notes version'' for course notes that is more suited to printing than the one -supplied by |beamer.cls|. - -The \pkg{notesslides} class takes the notion of a slide frame from Till Tantau's excellent -\pkg{beamer} class and adapts its notion of frames for use in the \sTeX and \omdoc. To -support semantic course notes, it extends the notion of mixing frames and explanatory -text, but rather than treating the frames as images (or integrating their contents into -the flowing text), the \pkg{notesslides} package displays the slides as such in the course -notes to give students a visual anchor into the slide presentation in the course (and to -distinguish the different writing styles in slides and course notes). - -In practice we want to generate two documents from the same source: the slides for -presentation in the lecture and the course notes as a narrative document for home -study. To achieve this, the \pkg{notesslides} class has two modes: \emph{slides mode} and -\emph{notes mode} which are determined by the package option. - - -\begin{variable}{slides,notes,sectocframes,frameimages,fiboxed} - The \pkg{notesslides} class takes a variety of class options: - \begin{itemize} - \item The options |slides| and |notes| switch between slides mode and notes mode (see - Section~\ref{sec:user:notesslides}). - \item If the option |sectocframes| is given, then for the |sfragment|s, special frames - with the |sfragment| title (and number) are generated. - \item If the option |frameimages| is set, then slide mode also shows the - |\frameimage|-generated frames (see section~\ref{sec:user:frameimage}). If also the - |fiboxed| option is given, the slides are surrounded by a box. - \end{itemize} -\end{variable} - -\begin{environment}{frame,note} - Slides are represented with the |frame| environment just like in the \pkg{beamer} class, - see~\cite{Tantau:ugbc} for details. The \pkg{notesslides} class adds the |note| - environment for encapsulating the course note fragments.\footnote{MK: it would be very - nice, if we did not need this environment, and this should be possible in principle, - but not without intensive LaTeX trickery. Hints to the author are welcome.} -\end{environment} - -\begin{dangerbox} - Note that it is essential to start and end the |notes| environment at the start of the - line -- in particular, there may not be leading blanks -- else {\LaTeX} becomes confused - and throws error messages that are difficult to decipher. -\end{dangerbox} - -By interleaving the |frame| and |note| environments, we can build course notes as shown -here: - -\begin{latexcode} -\ifnotes\maketitle\else -\frame[noframenumbering]\maketitle\fi - -\begin{note} - We start this course with ... -\end{note} - -\begin{frame} - \frametitle{The first slide} - ... -\end{frame} -\begin{note} - ... and more explanatory text -\end{note} - -\begin{frame} - \frametitle{The second slide} - ... -\end{frame} -... -\end{latexcode} - -\begin{function}{\ifnotes} - Note the use of the |\ifnotes| conditional, which allows different treatment between - |notes| and |slides| mode -- manually setting |\notestrue| or |\notesfalse| is strongly - discouraged however. -\end{function} - -\begin{dangerbox} - We need to give the title frame the |noframenumbering| option so that the frame - numbering is kept in sync between the slides and the course notes. -\end{dangerbox} - -\begin{dangerbox} - The \pkg{beamer} class recommends not to use the |allowframebreaks| option on frames - (even though it is very convenient). This holds even more in the |notesslides| case: At - least in conjunction with |\newpage|, frame numbering behaves funnily (we have tried to - fix this, but who knows). -\end{dangerbox} - -\begin{function}{\inputref*} - If we want to transclude a the contents of a file as a note, we can use a new variant - |\inputref*| of the |\inputref| macro: |\inputref*{foo}| is equivalent to - |\begin{note}\inputref{foo}\end{note}|. -\end{function} - -\begin{environment}{nparagraph, nparagraph, ndefinition, nexample, nsproof, nassertion} - There are some environments that tend to occur at the top-level of |note| - environments. We make convenience versions of these: e.g. the |nparagraph| environment - is just an |sparagraph| inside a |note| environment (but looks nicer in the source, - since it avoids one level of source indenting). Similarly, we have the |nfragment|, - |ndefinition|, |nexample|, |nsproof|, and |nassertion| environments. -\end{environment} - -\begin{function} {\setslidelogo} - The default logo provided by the \pkg{notesslides} package is the {\sTeX} logo it can be - customized using |\setslidelogo{|\meta{logo name}|}|. -\end{function} - -\begin{function}{\setsource} - The default footer line of the \pkg{notesslides} package mentions copyright and - licensing. In the \pkg{beamer} class, |\source| stores the author's name as the - copyright holder . By default it is \emph{Michael Kohlhase} in the \pkg{notesslides} - package since he is the main user and designer of this - package. |\setsource{|\meta{name}|}| can change the writer's name. -\end{function} - -\begin{function}{\setlicensing} - For licensing, we use the Creative Commons Attribuition-ShareAlike license by default to - strengthen the public domain. If package |hyperref| is loaded, then we can attach a - hyperlink to the license logo. |\setlicensing[|\meta{url}|]{|\meta{logo name}|}| is used - for customization, where \meta{url} is optional. -\end{function} - -Sometimes, we want to integrate slides as images after all -- e.g. because we already -have a PowerPoint presentation, to which we want to add \sTeX notes. - -\begin{function}{\frameimage,\mhframeimage} - In this case we can use |\frameimage[|\meta{opt}|]{|\meta{path}|}|, where \meta{opt} are - the options of |\includegraphics| from the \pkg{graphicx} package~\cite{CarRah:tpp99} - and \meta{path} is the file path (extension can be left off like in - |\includegraphics|). We have added the |label| key that allows to give a frame label - that can be referenced like a regular |beamer| frame. - -The |\mhframeimage| macro is a variant of |\frameimage| with repository support. Instead -of writing -\begin{latexcode} -\frameimage{\MathHub{fooMH/bar/source/baz/foobar}} -\end{latexcode} - we can simply write (assuming that |\MathHub| is defined as above) -\begin{latexcode} -\mhframeimage[fooMH/bar]{baz/foobar} -\end{latexcode} - Note that the |\mhframeimage| form is more semantic, which allows more advanced document -management features in \textsf{MathHub}. -\end{function} - -If |baz/foobar| is the ``current module'', i.e. if we are on the \textsf{MathHub} path -\ldots|MathHub/fooMH/bar|\ldots, then stating the repository in the first optional -argument is redundant, so we can just use -\begin{latexcode} -\mhframeimage{baz/foobar} -\end{latexcode} - -\begin{function}{\textwarning} - The |\textwarning| macro generates a warning sign: \textwarning -\end{function} - -In course notes, we sometimes want to point to an ``excursion'' -- material that is either -presupposed or tangential to the course at the moment -- e.g. in an appendix. The typical -setup is the following: - -\begin{latexcode} -\excursion{founif}{../ex/founif}{We will cover first-order unification in} -... -\begin{appendix}\printexcursions\end{appendix} -\end{latexcode} - -\begin{function}{\excursion} - The |\excursion{|\meta{ref}|}{|\meta{path}|}{|\meta{text}|}| is syntactic sugar for - -\begin{latexcode} -\begin{nparagraph}[title=Excursion] - \activateexcursion{founif}{../ex/founif} - We will cover first-order unification in \sref{founif}. -\end{nparagraph} -\end{latexcode} -\end{function} - -\begin{function}{\activateexcursion,\printexcursion,\excursionref} - Here |\activateexcursion{|\meta{path}|}| augments the |\printexcursions| macro by a call - |\inputref{|\meta{path}|}|. In this way, the |\printexcursions| macro (usually in the - appendix) will collect up all excursions that are specified in the main text. - - Sometimes, we want to reference -- in an excursion -- part of another. We can use - |\excursionref{|\meta{label}|}| for that. -\end{function} - -\begin{function}{\excursiongroup} - Finally, we usually want to put the excursions into an |sfragment| environment and add - an introduction, therefore we provide the a variant of the |\printexcursions| macro: - |\excursiongroup[id=|\meta{id}|,intro=|\meta{path}|]| is equivalent to -\begin{latexcode} -\begin{note} -\begin{sfragment}[id=]{Excursions} - \inputref{} - \printexcursions -\end{sfragment} -\end{note} -\end{latexcode} -\end{function} - -\begin{dangerbox} - When option |book| which uses |\pagestyle{headings}| is given and semantic macros are - given in the |sfragment| titles, then they sometimes are not defined by the time the - heading is formatted. Need to look into how the headings are made. This is a problem of - the underlying \pkg{document-structure} package. -\end{dangerbox} - -%%% Local Variables: -%%% mode: latex -%%% TeX-master: "../stex-manual" -%%% End: diff --git a/macros/latex/contrib/stex/doc/packages/stex-symbols.tex b/macros/latex/contrib/stex/doc/packages/stex-symbols.tex index e7bafeda6b..67e9a32e70 100644 --- a/macros/latex/contrib/stex/doc/packages/stex-symbols.tex +++ b/macros/latex/contrib/stex/doc/packages/stex-symbols.tex @@ -413,9 +413,9 @@ Note that the precise numbers used for precedences are pretty arbitrary - what m which precedences are higher than which other precedences when used in conjunction. \begin{variable}{\infprec,\neginfprec} It is occasionally useful to have ``infinitely'' high or low precedences to enforce or - forbid automated bracketing entirely -- for those purposes, \stexcode"\infprec" and - \stexcode"\neginfprec" exist (which are implemented as the maximal and minimal integer - values accordingly). + forbid automated bracketing entirely, e.g. for bracket-like notations such as intervals + -- for those purposes, \stexcode"\infprec" and \stexcode"\neginfprec" exist (which are + implemented as the maximal and minimal integer values accordingly).g \end{variable} \begin{dangerbox} @@ -499,7 +499,7 @@ which precedences are higher than which other precedences when used in conjuncti \vardef{varx}[name=x,type=\Nat]{\comp{x}} Given a function $\varf!:\funtype{\Nat}{\Nat}$, -by $\addition{\varf!,\varn}$ we mean the function +by $\addition{\varf!,\varn}$ we mean the function\rustexBREAK $\fun{\varx}{\varf{\addition{\varx,\varn}}}$ } diff --git a/macros/latex/contrib/stex/doc/stex-doc.pdf b/macros/latex/contrib/stex/doc/stex-doc.pdf index 0d0a36720c..e53c98213a 100644 Binary files a/macros/latex/contrib/stex/doc/stex-doc.pdf and b/macros/latex/contrib/stex/doc/stex-doc.pdf differ diff --git a/macros/latex/contrib/stex/doc/stex-doc.tex b/macros/latex/contrib/stex/doc/stex-doc.tex index 7a98ff49c2..d2ff005554 100644 --- a/macros/latex/contrib/stex/doc/stex-doc.tex +++ b/macros/latex/contrib/stex/doc/stex-doc.tex @@ -1,4 +1,7 @@ -\def\bibfolder#1{../lib/bib/#1} +\def\libfolder#1{../lib/#1} +\newif\ifinidedoc\inidedocfalse +\newif\ifinfulldoc\inidedocfalse + \input{stex-docheader} \infulldoctrue @@ -9,8 +12,6 @@ } \ExplSyntaxOff -\expandafter\newif\csname if@infulldoc\expandafter\endcsname\csname @infulldoctrue\endcsname - \begin{document} \title{ The {\stex{3}} Package Collection @@ -185,7 +186,7 @@ \OmitDocInput{../source/stex/stex-others.dtx} \DocInput{../source/stex/stex-metatheory.dtx} -\part{Extensions}\label{part:extensions} +\part{Extensions}\label{part:extensions}\slabel{part:extends} \DocInput{../source/extensions/tikzinput.dtx} \DocInput{../source/extensions/document-structure.dtx} diff --git a/macros/latex/contrib/stex/doc/stex-docheader.tex b/macros/latex/contrib/stex/doc/stex-docheader.tex index d16b19703b..c6bea9b3da 100644 --- a/macros/latex/contrib/stex/doc/stex-docheader.tex +++ b/macros/latex/contrib/stex/doc/stex-docheader.tex @@ -1,4 +1,5 @@ \RequirePackage{paralist} +\ifcsname libfolder\endcsname\else\def\libfolder#1{../lib/#1}\fi \documentclass[full,kernel]{l3doc} \usepackage[dvipsnames]{xcolor} \usepackage[utf8]{inputenc} @@ -7,15 +8,14 @@ \RequirePackage{tikzinput} \usetikzlibrary{fit} -% \usepackage[debug=all,lang=en, mathhub=./tests]{stex} -\usepackage[lang=en, mathhub=./tests]{stex} -\usepackage{url,array,float,textcomp} +\usepackage[lang=en, mathhub=./tests,debug=sref]{stex} +\usepackage{url,array,float} \usepackage[show]{ed} \usepackage[hyperref=auto,style=alphabetic]{biblatex} -\addbibresource{\bibfolder{kwarcpubs.bib}} -\addbibresource{\bibfolder{extpubs.bib}} -\addbibresource{\bibfolder{kwarccrossrefs.bib}} -\addbibresource{\bibfolder{extcrossrefs.bib}} +\addbibresource{\libfolder{bib/kwarcpubs.bib}} +\addbibresource{\libfolder{bib/extpubs.bib}} +\addbibresource{\libfolder{bib/kwarccrossrefs.bib}} +\addbibresource{\libfolder{bib/extcrossrefs.bib}} \usepackage{amssymb} \usepackage{amsfonts} \usepackage{xspace} @@ -50,7 +50,9 @@ \\symbolname,\\binarysymbol,\\newbinarysymbol,\\addition, \\summation,\\ascendingchain,\\quantforall,\\set,\\funtype, \\Nat,\\successor,\\multiplication,\\Int,\\zero,\\uminus, - \\intmonoid + \\intmonoid,\\divides,\\intpow,\\ratfrac,\\ratpow,\\inttimes, + \\inset,\\eq,\\rational,\\irrational,\\coprime,\\PosInt, + \\realroot }, classoffset=2,keywordstyle=\color{blue},morekeywords={ \\symdecl,\\symdef,\\notation,\\vardef,\\varseq,\\instantiate, @@ -64,11 +66,11 @@ classoffset=4,keywordstyle=\color{Purple},morekeywords={ \\definiendum,\\definame,\\symref,\\symname,\\comp, \\compemph,\\definiens,\\svar,\\infprec,\\neginfprec,\\ellipses, - \\Symname,\\arg + \\Symname,\\arg,\\yield,\\assumption,\\spfstep,\\eqstep,\\conclude }, classoffset=5,keywordstyle=\color{magenta},morekeywords={ smodule,sdefinition,sassertion,sparagraph,sexample, - sproof,subproof,spfcases,spfcase,spfstep,spfcomment, + sproof,subproof,spfcases,spfcase,spfstep,spfcomment,spfblock, \\spfidea,\\spfsketch,\\spfcasesketch,\\sproofend, \\spfjust,\\premise,\\justarg, copymodule,interpretmodule,mathstructure,sexample @@ -88,57 +90,12 @@ }, classoffset=8,keywordstyle=\color{red},morekeywords={ frame,note + }, + classoffset=9,keywordstyle=\color{gray},morekeywords={ + \\vara,\\varb,\\varc } } -%\lstdefinestyle{mylatex}{ -% keywordstyle=\color{BurntOrange} -%} -%\lstdefinelanguage{mylatex}{ -% emphstyle=\underbar, -% alsodigit={:}, -% %alsoletter={_}, -% alsoletter={\\} -% sensitive=true, -% classoffset=0,keywordstyle=\bfseries, -% morekeywords={\\begin,\\end,\\ExplSyntaxOn,\\ExplSyntaxOff}, -% classoffset=1,keywordstyle=\color{blue}, -% morekeywords={ -% \\symdecl, -% \\symdef, -% \\notation, -% \\abbrdef, -% \\importmodule, -% \\usemodule, -% \\STEXwithbrackets, -% \\symref -% }, -% classoffset=2,keywordstyle=\color{Purple}, -% morekeywords={ -% \\stex_path_from_string:Nn, -% \\stex_path_to_string:NN, -% \\stex_path_to_string:N, -% \\stex_require_repository:n, -% \\stex_modules_current_namespace:, -% \\stex_debug:n, -% \\stex_set_current_repository:n, -% \\stex_file_in_smsmode:nn, -% \\stex_get_symbol:n, -% }, -% classoffset=3,keywordstyle=\color{SkyBlue}, -% morekeywords={ -% \\l_stex_module_ns_str, -% \\g_stex_currentfile_seq, -% \\l_stex_current_module_prop, -% \\l_stex_get_symbol_uri_str, -% } -% classoffset=0, -%%^^A morecomment=[l][\color{Gray}]{//}, -%%^^A morecomment=[s][\color{Gray}]{/*}{*/}, -% morecomment=[s][\color{Green}]{$}{$},, -% morecomment=[s][\color{OliveGreen}]{\\[}{\\]}, -%^^A morestring=[b][\color{Purple}]\$, -%} \lstnewenvironment{latexcode}[1][]{\lstset{language=sTeX,#1}}{} \def\stexcode{\lstinline[language=sTeX]} @@ -183,28 +140,6 @@ outer arc=4pt } - -%\newtcolorbox{exampleborderbox}{ -% enhanced, -% left=0pt, -% title={Example \the\example@counter}, -% right=0pt, -% top=8pt, -% bottom=8pt, -% colback=white, -% colframe=blue, -% width=\textwidth, -% enlarge left by=0mm, -% boxsep=5pt, -% fontupper=\small, -% arc=4pt, -% outer arc=4pt, -% leftupper=1.5cm, -% fonttitle=\bfseries, -% coltitle=blue, -% boxed title style={empty,size=minimal,toprule=0pt,top=1pt,left=3mm,overlay={}}, -%} - \newenvironment{example@border} { \global\advance\example@counter by 1 @@ -262,7 +197,7 @@ Output: \begin{stextest@output} - \input{stextest.tex} + \csname @ @ input\endcsname{stextest.tex} \end{stextest@output} \end{example@border} } @@ -371,7 +306,7 @@ \def\atwintoo#1#2#3{{#1 #2 #3}\atwin{#1}{#2}{#3}} \def\cT{\mathcal{T}}\def\cD{\mathcal{D}} -\def\fileversion{3.1} +\def\fileversion{3.2} \def\filedate{\today} \RequirePackage{pdfcomment} @@ -446,4 +381,4 @@ \end{mdframed}\end{remarkbox}\endlist } -\usepackage{rustex} +\usepackage{rustex} \ No newline at end of file diff --git a/macros/latex/contrib/stex/doc/stex-ide.pdf b/macros/latex/contrib/stex/doc/stex-ide.pdf new file mode 100644 index 0000000000..a04d7ddd60 Binary files /dev/null and b/macros/latex/contrib/stex/doc/stex-ide.pdf differ diff --git a/macros/latex/contrib/stex/doc/stex-ide.tex b/macros/latex/contrib/stex/doc/stex-ide.tex new file mode 100644 index 0000000000..a563d277fb --- /dev/null +++ b/macros/latex/contrib/stex/doc/stex-ide.tex @@ -0,0 +1,155 @@ +\ifcsname ifinfulldoc\endcsname\else + \expandafter\newif\csname ifinfulldoc\endcsname\infulldocfalse +\fi +\ifcsname ifinidedoc\endcsname\else + \expandafter\newif\csname ifinidedoc\endcsname\inidedoctrue +\fi + +\ifinidedoc +\input{stex-docheader} + + +\begin{document} + + \title{ + The {\stex} VSCode IDE + \thanks{Version {\fileversion} (last revised {\filedate})} + } + \author{Michael Kohlhase, Dennis Müller\\ + FAU Erlangen-Nürnberg\\ + \url{http://kwarc.info/} + } + \pagenumbering{roman} + \maketitle + + This is the user manual for the \sTeX Plugin for VSCode, available at + \url{https://marketplace.visualstudio.com/items?itemName=kwarc.stexide}. + For the manual for the \sTeX package itself, see \href{\basedocurl/stex-manual.pdf}{the \sTeX{}3 Manual}. + + \makeatletter + \renewcommand\part{% + \clearpage + \thispagestyle{plain}% + \@tempswafalse + \null\vfil + \secdef\@part\@spart% + } + \newcounter{chapter} + \numberwithin{section}{chapter} + \renewcommand\thechapter{\@arabic\c@chapter} + \renewcommand\thesection{\thechapter.\@arabic\c@section} + \newcommand*\chaptermark[1]{} + \setcounter{secnumdepth}{2} + \newcommand\@chapapp{\chaptername} + %\newcommand\chaptername{Chapter} + \def\ps@headings{% + \let\@oddfoot\@empty + \def\@oddhead{{\slshape\rightmark}\hfil\thepage}% + \let\@mkboth\markboth + \def\chaptermark##1{% + \markright{\MakeUppercase{% + \ifnum \c@secnumdepth >\m@ne + \@chapapp\ \thechapter. \ % + \fi + ##1}}% + }% + } + \newcommand\chapter{\clearpage + \thispagestyle{plain}% + \global\@topnum\z@ + \@afterindentfalse + \secdef\@chapter\@schapter% + } + \def\@chapter[#1]#2{\refstepcounter{chapter}% + \typeout{\@chapapp\space\thechapter.}% + \addcontentsline{toc}{chapter}% + {\protect\numberline{\thechapter}#1}% + \chaptermark{#1}% + \addtocontents{lof}{\protect\addvspace{10\p@}}% + \addtocontents{lot}{\protect\addvspace{10\p@}}% + \@makechapterhead{#2}% + \@afterheading% + } + \def\@makechapterhead#1{% + \vspace*{50\p@}% + {\parindent \z@ \raggedright \normalfont + \huge\bfseries \@chapapp\space \thechapter + \par\nobreak + \vskip 20\p@ + \interlinepenalty\@M + \Huge \bfseries #1\par\nobreak + \vskip 40\p@ + }% + } +\newcommand*\l@chapter[2]{% + \ifnum \c@tocdepth >\m@ne + \addpenalty{-\@highpenalty}% + \vskip 1.0em \@plus\p@ + \setlength\@tempdima{1.5em}% + \begingroup + \parindent \z@ \rightskip \@pnumwidth + \parfillskip -\@pnumwidth + \leavevmode \bfseries + \advance\leftskip\@tempdima + \hskip -\leftskip + #1\nobreak\hfil + \nobreak\hb@xt@\@pnumwidth{\hss #2% + \kern-\p@\kern\p@}\par + \penalty\@highpenalty + \endgroup + \fi} +\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.8em}} +\renewcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}} +\renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}} +\def\partname{Part} +\def\toclevel@part{-1} +\def\maketitle{\chapter{\@title}} +\let\thanks\@gobble +\let\DelayPrintIndex\PrintIndex +\let\PrintIndex\@empty +\providecommand*{\hexnum}[1]{\text{\texttt{\char`\"}#1}} +\makeatother + +\ExplSyntaxOn +\int_set:Nn \l_document_structure_section_level_int {1} +\ExplSyntaxOff + +\clearpage + +{% + \def\\{:}% fix "newlines" in the ToC + \tableofcontents +} + +\clearpage +\pagenumbering{arabic} + +\long\def\ignore#1{} + +\input{packages/stex-setup} +\input{packages/stex-idesetup} + +\fi + + + + +\ifinidedoc +\newpage +\printbibliography +\end{document} +\fi + + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: t +%%% End: + +% LocalWords: stex-docheader infulldoctrue l@subsubsection toclevel@part ExplSyntaxOff +% LocalWords: l_document_structure_section_level_int dangerbox mmtbox omdoc OBJref lmh +% LocalWords: own:fifom MueRabRot:rslffml20 sec.stexarchives stex-mathhub ngerman a,b +% LocalWords: Metatheory sec.customhighlight sproof stexthm xspace stexpatchmodule +% LocalWords: stexpatchexample stexpatchparagraph sexampleid amsthm sassertiontitle +% LocalWords: sdefinitiontitle compemph varemph srefsymuri stex-hwexam TeXLive:on tlmgr +% LocalWords: stexls:on,stexls-vscode-plugin:on diff --git a/macros/latex/contrib/stex/doc/stex-manual.pdf b/macros/latex/contrib/stex/doc/stex-manual.pdf index 32c1e047ca..2facc41ad1 100644 Binary files a/macros/latex/contrib/stex/doc/stex-manual.pdf and b/macros/latex/contrib/stex/doc/stex-manual.pdf differ diff --git a/macros/latex/contrib/stex/doc/stex-manual.tex b/macros/latex/contrib/stex/doc/stex-manual.tex index 31b9c4eaeb..547e238f54 100644 --- a/macros/latex/contrib/stex/doc/stex-manual.tex +++ b/macros/latex/contrib/stex/doc/stex-manual.tex @@ -1,19 +1,15 @@ -\makeatletter -\ifcsname if@infulldoc\endcsname\else - \expandafter\newif\csname if@infulldoc\endcsname\@infulldocfalse -\fi -\makeatother - -\csname if@infulldoc\endcsname\else - -\def\bibfolder#1{../lib/bib/#1} -\input{stex-docheader} +\ifcsname ifinfulldoc\endcsname\else + \expandafter\newif\csname ifinfulldoc\endcsname\infulldocfalse +\fi +\ifcsname ifinidedoc\endcsname\else + \expandafter\newif\csname ifinidedoc\endcsname\inidedocfalse +\fi -\infulldoctrue +\ifinfulldoc\else + \input{stex-docheader} \begin{document} - \csname if@infulldoc\endcsname\else \title{ The {\stex{3}} Manual \thanks{Version {\fileversion} (last revised {\filedate})} @@ -192,82 +188,55 @@ provided by several pieces of software: \end{itemize} \end{sfragment} - -\begin{sfragment}{Quickstart} - \begin{sfragment}{Setup} - There are two ways of using \sTeX: as a - \begin{enumerate} - \item way of writing {\LaTeX} more modularly (object-oriented Math) for creating PDF - documents or - \item foundation for authoring active documents in HTML5 instrumented with knowledge - management services. - \end{enumerate} - Both are legitimate and useful. The first requires a significantly smaller - tool-chain, so we describe it first. The second requires a much more substantial - (and experimental) toolchain of knowledge management systems. Both workflows profit - from an integrated development environment (IDE), which (also) automates setup as - far as possible (see \sref{sec.sTeX-IDE}). - - \begin{sfragment}[id=sec.minimal-setup]{Minimal Setup for the PDF-only Workflow} - In the best of all worlds, there is no setup, as you already have a new version of - {\TeX}Live on your system as a {\LaTeX} enthusiast. If not now is the time to - install it; see \cite{TeXLive:on}. You can usually update {\TeX}Live via a package - manager or the {\TeX}Live manager \textbf{tlmgr}. - - Alternatively, you can install \sTeX from CTAN, the Comprehensive {\TeX} Archive - Network; see \cite{stexCTAN:on} for details. - \end{sfragment} - - \begin{sfragment}[id=sec.git-setup]{GIT-based Setup for the \sTeX Development Version} - If you want use the latest and greatest \sTeX packages - that have not even been released to CTAN, - then you can directly clone them from the \sTeX development - repository \cite{sTeX:github:on} by the following command-line instructions: -\begin{lstlisting}[language=bash] - cd - git clone https://github.com/slatex/sTeX.git -\end{lstlisting} - and keep it updated by pulling updates via \lstinline|git pull| in the cloned \sTeX - directory. - Then update your \lstinline|TEXINPUTS| environment variable, e.g. by placing the following line in your \lstinline|.bashrc|: -\begin{lstlisting}[language=bash] -export TEXINPUTS="$(TEXINPUTS)://:" -\end{lstlisting} - \end{sfragment} - - \begin{sfragment}[id=sec.stex-archives]{\sTeX Archives (Manual Setup)} - Writing semantically annotated \sTeX becomes much easier, if we can use - well-designed libraries of already annotated content. \sTeX provides such - libraries as \sTeX archives -- i.e. GIT repositories at - \url{https://gl.mathhub.info} -- most prominently the SMGLoM libraries at - \url{https://gl.mathhub.info/smglom}. - - To do so, we set up a \textbf{local MathHub} by creating a MathHub directory - \lstinline||. Every \sTeX archive as an \textbf{archive path} - \lstinline|| and a name \lstinline||. We can clone the \sTeX - archive by the following command-line instructions: +\begin{sfragment}{Setup} + There are two ways of using \sTeX: as a + \begin{enumerate} + \item way of writing {\LaTeX} more modularly (object-oriented Math) for creating PDF + documents or + \item foundation for authoring active documents in HTML5 instrumented with knowledge + management services. + \end{enumerate} + Both are legitimate and useful. The first requires a significantly smaller + tool-chain, so we describe it first. The second requires a much more substantial + toolchain of knowledge management systems. + + Luckily, the \sTeX-IDE will take care of much of the setup required + for the full toolchain, if you are willing to use it. + + \input{packages/stex-setup} + + \input{packages/stex-idesetup} + + \begin{sfragment}{Manual Setup} + + In lieu of using the \sTeX IDE, we can do the following: + + \begin{sfragment}[id=sec.stex-archives]{\sTeX Archives (Manual Setup)} + Writing semantically annotated \sTeX becomes much easier, if we can use + well-designed libraries of already annotated content. \sTeX provides such + libraries as \sTeX archives -- i.e. GIT repositories at + \url{https://gl.mathhub.info} -- most prominently the SMGLoM libraries at + \url{https://gl.mathhub.info/smglom}. + + To do so, we set up a \textbf{local MathHub} by creating a MathHub directory + \lstinline||. Every \sTeX archive as an \textbf{archive path} + \lstinline|| and a name \lstinline||. We can clone the \sTeX + archive by the following command-line instructions: \begin{lstlisting}[language=bash] - cd / - git clone https://gl.mathhub.info/smglom/.git +cd / +git clone https://gl.mathhub.info/smglom/.git \end{lstlisting} - Note that \sTeX archives often depend on other archives, thus you should be - prepared to clone these as well -- e.g. if \texttt{pdflatex} reports missing - files. - To make sure that \sTeX too knows where to find its archives, we need to set a global - system variable |MATHHUB|, that points to your local |MathHub|-directory (see - \sref{sec.stexarchives}). + Note that \sTeX archives often depend on other archives, thus you should be + prepared to clone these as well -- e.g. if \texttt{pdflatex} reports missing + files. + To make sure that \sTeX too knows where to find its archives, we need to set a global + system variable |MATHHUB|, that points to your local |MathHub|-directory (see + \sref{sec.stexarchives}). \begin{lstlisting}[language=bash] -export MATHHUB="'' +export MATHHUB="" \end{lstlisting} - \end{sfragment} - - \begin{sfragment}[id=sec.sTeX-IDE]{The \sTeX IDE} - We are currently working on an \sTeX IDE as an \sTeX plugin for |VScode|; - see~\cite{sTeX-IDE:on}. It will feature a setup procedure that automates the setup - described above (and below). For additional functionality see the (now obsolete) - plugin for \sTeX1 \cite{stexls:on,stexls-vscode-plugin:on}. - \end{sfragment} + \end{sfragment} \begin{sfragment}{Manual Setup for Active Documents and Knowledge Management Services} Foregoing on the \sTeX IDE, we will need several additional (on top of the minimal @@ -301,11 +270,15 @@ export MATHHUB="'' \end{itemize} \end{sfragment} \end{sfragment} +\end{sfragment} - \input{stex-tutorial} - +\begin{sfragment}[id=sec.sTeX-IDE]{The \sTeX IDE} + \input{stex-ide} \end{sfragment} +\input{stex-tutorial} + + \begin{sfragment}{Creating \sTeX Content} \input{packages/stex-basics} @@ -453,7 +426,6 @@ export MATHHUB="'' \begin{sfragment}{\sTeX Statements} \input{packages/stex-statements} \input{packages/stex-proofs} -\end{sfragment} \begin{sfragment}[id=sec.customhighlight]{Highlighting and Presentation Customizations} @@ -538,7 +510,7 @@ export MATHHUB="'' \begin{latexcode} \protected\def\symrefemph@uri#1#2{ \pdftooltip{ - \srefsymuri{#2}{\symrefemph{#1}} + \symrefemph{#1} }{ URI:~\detokenize{#2} } @@ -548,6 +520,10 @@ export MATHHUB="'' other three commands). \end{function} \end{sfragment} +\end{sfragment} +\begin{sfragment}[id=sec.references]{Cross References} + \input{packages/stex-references} +\end{sfragment} \begin{sfragment}{Additional Packages} \begin{sfragment}{Tikzinput: Treating TIKZ code as images} @@ -557,7 +533,7 @@ export MATHHUB="'' \input{packages/stex-document-structure} \end{sfragment} \begin{sfragment}{Slides and Course Notes} - \input{packages/stex-slides} + \input{packages/stex-notesslides} \end{sfragment} \begin{sfragment}{Representing Problems and Solutions} \input{packages/stex-problem} @@ -567,7 +543,7 @@ export MATHHUB="'' \end{sfragment} \end{sfragment} -\csname if@infulldoc\endcsname\else +\ifinfulldoc\else \newpage \printbibliography \end{document} diff --git a/macros/latex/contrib/stex/doc/stex-tutorial.tex b/macros/latex/contrib/stex/doc/stex-tutorial.tex index dcd4c442e0..7b3b723826 100644 --- a/macros/latex/contrib/stex/doc/stex-tutorial.tex +++ b/macros/latex/contrib/stex/doc/stex-tutorial.tex @@ -21,7 +21,7 @@ \symdef{geometricSeries}[name=geometric-series]{\comp{S}} \begin{sdefinition}[for=geometricSeries] - The \definame{geometricSeries} is the \symname{?series} + The \definame{geometricSeries} is the \symname{series} \[\defeq{\geometricSeries}{\definiens{ \infinitesum{\svar{n}}{1}{ \realdivide[frac]{1}{ diff --git a/macros/latex/contrib/stex/source/extensions/document-structure.dtx b/macros/latex/contrib/stex/source/extensions/document-structure.dtx index b05e4d464c..a73e0fd856 100644 --- a/macros/latex/contrib/stex/source/extensions/document-structure.dtx +++ b/macros/latex/contrib/stex/source/extensions/document-structure.dtx @@ -9,7 +9,7 @@ % % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -42,14 +42,14 @@ % % \tableofcontents % -% \input{../../doc/packages/stex-document-structure} -% \fi -% -% % \begin{documentation}\label{pkg:documentstructure:doc} -% +% \begin{sfragment}{The User Interface} +% \input{../../doc/packages/stex-document-structure} +% \end{sfragment} % \end{documentation} % +% \fi +% % \begin{implementation}\label{pkg:documentstructure:impl} % % \begin{sfragment}{document-structure.sty Implementation} @@ -57,7 +57,7 @@ % \begin{macrocode} %<*package> %<@@=document_structure> -\ProvidesExplPackage{document-structure}{2022/05/24}{3.1.0}{Modular Document Structure} +\ProvidesExplPackage{document-structure}{2022/09/14}{3.2.0}{Modular Document Structure} \RequirePackage{l3keys2e} % \end{macrocode} % @@ -72,7 +72,7 @@ \keys_define:nn{ document-structure }{ class .str_set_x:N = \c_document_structure_class_str, - topsect .str_set_x:N = \c_document_structure_topsect_str,, + topsect .str_set_x:N = \c_document_structure_topsect_str, unknown .code:n = { \PassOptionsToClass{\CurrentOption}{stex} \PassOptionsToClass{\CurrentOption}{tikzinput} @@ -98,7 +98,7 @@ \AddToHook{begindocument}{ \ltx@ifpackageloaded{babel}{ \clist_set:Nx \l_tmpa_clist {\bbl@loaded} - \clist_if_in:NnT \l_tmpa_clist {ngerman}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{ \makeatletter\input{document-structure-ngerman.ldf}\makeatother } }{} @@ -223,7 +223,6 @@ srccite .tl_set:N = \l_@@_sfragment_srccite_tl, type .tl_set:N = \l_@@_sfragment_type_tl, short .tl_set:N = \l_@@_sfragment_short_tl, - display .tl_set:N = \l_@@_sfragment_display_tl, intro .tl_set:N = \l_@@_sfragment_intro_tl, imports .tl_set:N = \l_@@_sfragment_imports_tl, loadmodules .bool_set:N = \l_@@_sfragment_loadmodules_bool @@ -236,7 +235,6 @@ \tl_clear:N \l_@@_sfragment_srccite_tl \tl_clear:N \l_@@_sfragment_type_tl \tl_clear:N \l_@@_sfragment_short_tl - \tl_clear:N \l_@@_sfragment_display_tl \tl_clear:N \l_@@_sfragment_imports_tl \tl_clear:N \l_@@_sfragment_intro_tl \bool_set_false:N \l_@@_sfragment_loadmodules_bool diff --git a/macros/latex/contrib/stex/source/extensions/hwexam.dtx b/macros/latex/contrib/stex/source/extensions/hwexam.dtx index e166fd0397..de3538d53f 100644 --- a/macros/latex/contrib/stex/source/extensions/hwexam.dtx +++ b/macros/latex/contrib/stex/source/extensions/hwexam.dtx @@ -10,7 +10,7 @@ % \iffalse % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -32,8 +32,10 @@ % \url{http://kwarc.info/kohlhase}} % \maketitle % -%\ifinfulldoc\else -%\begin{abstract} +% \begin{documentation} +%\ifinfulldoc\else +% +%\begin{abstract}{} % The |hwexam| package and class allows individual course assignment sheets and compound % assignment documents using problem files marked up with the |problem| package. % @@ -43,12 +45,11 @@ % \end{abstract} % % \tableofcontents -% +% \begin{sfragment}{The User Intterface} % \input{../../doc/packages/stex-hwexam} +% \end{sfragment} % \fi % -% \begin{documentation} -% % \end{documentation} % %\begin{implementation} @@ -63,13 +64,14 @@ % % \begin{macrocode} %<*package> -\ProvidesExplPackage{hwexam}{2022/05/24}{3.1.0}{homework assignments and exams} +\ProvidesExplPackage{hwexam}{2022/09/14}{3.2.0}{homework assignments and exams} \RequirePackage{l3keys2e} \newif\iftest\testfalse -\DeclareOption{test}{\testtrue} +\DeclareOption{test}{\testtrue\PassOptionsToPackage{\CurrentOption}{problem}} \newif\ifmultiple\multiplefalse \DeclareOption{multiple}{\multipletrue} +\DeclareOption{lang}{\PassOptionsToPackage{\CurrentOption}{problem}} \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{problem}} \ProcessOptions % \end{macrocode} @@ -86,9 +88,8 @@ \newcommand\hwexam@assignment@kw{Assignment} \newcommand\hwexam@given@kw{Given} \newcommand\hwexam@due@kw{Due} -\newcommand\hwexam@testemptypage@kw{This~page~was~intentionally~left~ - blank~for~extra~space} - \def\hwexam@minutes@kw{minutes} +\newcommand\hwexam@testemptypage@kw{This~page~was~intentionally~left~blank~for~extra~space} +\newcommand\hwexam@minutes@kw{minutes} \newcommand\correction@probs@kw{prob.} \newcommand\correction@pts@kw{total} \newcommand\correction@reached@kw{reached} @@ -104,16 +105,16 @@ \ltx@ifpackageloaded{babel}{ \makeatletter \clist_set:Nx \l_tmpa_clist {\bbl@loaded} - \clist_if_in:NnT \l_tmpa_clist {ngerman}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{ \input{hwexam-ngerman.ldf} } - \clist_if_in:NnT \l_tmpa_clist {finnish}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{ \input{hwexam-finnish.ldf} } - \clist_if_in:NnT \l_tmpa_clist {french}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{ \input{hwexam-french.ldf} } - \clist_if_in:NnT \l_tmpa_clist {russian}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{ \input{hwexam-russian.ldf} } \makeatother @@ -265,7 +266,7 @@ }{ \global\setcounter{assignment}{\int_use:N\l_@@_assign_number_int} } - \setcounter{problem}{0} + \setcounter{sproblem}{0} \renewcommand\prob@label[1]{\assignment@number.##1} \def\current@section@level{\document@hwexamtype} %\sref@label@id{\document@hwexamtype \thesection} @@ -416,24 +417,6 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\testspace} -% \begin{macrocode} -\newcommand\testspace[1]{\iftest\vspace*{#1}\fi} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\testnewpage} -% \begin{macrocode} -\newcommand\testnewpage{\iftest\newpage\fi} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\testemptypage} -% \begin{macrocode} -\newcommand\testemptypage[1][]{\iftest\begin{center}\hwexam@testemptypage@kw\end{center}\vfill\eject\else\fi} -% \end{macrocode} -% \end{macro} -% % \begin{macro}{\@problem} % This macro acts on a problem's record in the |*.aux| file. Here we redefine it (it was % defined to do nothing in |problem.sty|) to generate the correction table. diff --git a/macros/latex/contrib/stex/source/extensions/notesslides.dtx b/macros/latex/contrib/stex/source/extensions/notesslides.dtx index ff06827660..e74693c26b 100644 --- a/macros/latex/contrib/stex/source/extensions/notesslides.dtx +++ b/macros/latex/contrib/stex/source/extensions/notesslides.dtx @@ -11,9 +11,8 @@ % \iffalse % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} - \begin{document} \DocInput{\jobname.dtx} \end{document} @@ -54,7 +53,9 @@ % see \href{\basedocurl/manual.pdf}{the \sTeX Manual} or the % \href{\basedocurl/stex.pdf}{full \sTeX documentation}. % -% \input{../../doc/packages/stex-slides} +% \begin{sfragment}{The User Interface} +% \input{../../doc/packages/stex-notesslides} +% \end{sfragment} % \fi % % \begin{documentation}\label{pkg:notesslides:doc} @@ -76,7 +77,7 @@ % \begin{macrocode} %<*cls> %<@@=notesslides> -\ProvidesExplClass{notesslides}{2022/05/24}{3.1.0}{notesslides Class} +\ProvidesExplClass{notesslides}{2022/09/14}{3.2.0}{notesslides Class} \RequirePackage{l3keys2e} \keys_define:nn{notesslides / cls}{ @@ -121,7 +122,7 @@ % now we do the same for the |notesslides| package. % \begin{macrocode} %<*package> -\ProvidesExplPackage{notesslides}{2022/05/24}{3.1.0}{notesslides Package} +\ProvidesExplPackage{notesslides}{2022/09/14}{3.2.0}{notesslides Package} \RequirePackage{l3keys2e} \keys_define:nn{notesslides / pkg}{ @@ -208,35 +209,23 @@ \RequirePackage[bookmarks,bookmarksopen,bookmarksnumbered,breaklinks,hidelinks]{hyperref} } \RequirePackage{stex-tikzinput} -\RequirePackage{etoolbox} -\RequirePackage{amssymb} -\RequirePackage{amsmath} \RequirePackage{comment} -\RequirePackage{textcomp} \RequirePackage{url} \RequirePackage{graphicx} \RequirePackage{pgf} +\RequirePackage{bookmark} % \end{macrocode} % % \subsection{Notes and Slides}\label{sec:impl:noteslides} % % For the lecture notes cases, we also provide the |\usetheme| macro that would otherwise -% come from the the |beamer| class. While the latter loads -% |beamertheme|\meta{theme}{.sty}, the notes version loads -% |beamernotestheme|\meta{theme}|.sty|.\ednote{MK: This is not ideal, but I am not sure -% that I want to be able to provide the full theme functionality there.} +% come from the the |beamer| class. % \begin{macrocode} \bool_if:NT \c_@@_notes_bool { - \renewcommand\usetheme[2][]{\usepackage[#1]{beamernotestheme#2}} + \renewcommand\usetheme[2][]{\usepackage[#1]{beamertheme#2}} } - - \NewDocumentCommand \libusetheme {O{} m} { - \bool_if:NTF \c_@@_notes_bool { - \libusepackage[#1]{beamernotestheme#2} - }{ \libusepackage[#1]{beamertheme#2} - } } % \end{macrocode} @@ -485,8 +474,6 @@ \includegraphics[#1]{\mhpath\Gin@mhrepos{#2}} } - - \bool_if:NTF \c_@@_notes_bool { \setlength{\slidelogoheight}{.4cm} }{ @@ -506,10 +493,26 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\author} +% In notes mode, we redefine the |\author| macro so that it does not disregard the +% optional argument (as \pkg{beamerarticle} does). We want to use it to set the source +% later. +% \begin{macrocode} +\bool_if:NT \c_@@_notes_bool { + \def\author{\@dblarg\ns@author} + \long\def\ns@author[#1]#2{% + \def\c_@@_shortauthor{#1}% + \def\@author{#2} + } +} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\setsource} -% |\source| stores the writer's name. By default it is {\it Michael Kohlhase} since he is the main user and designer of this package. |\setsource{|\meta{name}|}| can change the writer's name. +% |\source| stores the writer's name. By default it is {\it Michael Kohlhase} since he +% is the main user and designer of this package. |\setsource{|\meta{name}|}| can change +% the writer's name. % \begin{macrocode} -\def\source{Michael Kohlhase}% customize locally \newrobustcmd{\setsource}[1]{\def\source{#1}} % \end{macrocode} % \end{macro} @@ -521,7 +524,13 @@ % logo. |\setlicensing[|\meta{url}|]{|\meta{logo name}|}| is used for customization, % where ||\meta{url}|| is optional. % \begin{macrocode} -\def\copyrightnotice{\footnotesize\copyright :\hspace{.3ex}{\source}} +\def\copyrightnotice{% + \footnotesize\copyright :\hspace{.3ex}% + \ifcsname source\endcsname\source\else% + \ifcsname c_@@_shortauthor\endcsname\c_@@_shortauthor\else% + \PackageWarning{notesslides}{Author/Source~undefined~in~copyright~notice}% + ?source/author?\fi% + \fi} \newsavebox{\cclogo} \sbox{\cclogo}{\includegraphics[height=\slidelogoheight]{stex-cc_somerights}} \newif\ifcchref\cchreffalse @@ -617,69 +626,6 @@ % \end{macrocode} % \end{macro} % -% \subsection{Colors and Highlighting}\label{sec:impl:highlighting} -% -% We first specify sans serif fonts as the default. -% -% \begin{macrocode} -\sffamily -% \end{macrocode} -% -% Now, we set up an infrastructure for highlighting phrases in slides. Note that we use -% content-oriented macros for highlighting rather than directly using color markup. -% The first thing to to is to adapt the green so that it is dark enough for most beamers -% \begin{macrocode} -\AddToHook{begindocument}{ - \definecolor{green}{rgb}{0,.5,0} - \definecolor{purple}{cmyk}{.3,1,0,.17} -} -% \end{macrocode} -% -% We customize the |\defemph|, |\symrefemph|, |\compemph|, and |\titleemph| macros with -% colors. Furthermore we customize the |\__omtextlec| macro for the appearance of line end -% comments in |\lec|. -% -% \begin{macrocode} -% \def\STpresent#1{\textcolor{blue}{#1}} -\def\defemph#1{{\textcolor{magenta}{#1}}} -\def\symrefemph#1{{\textcolor{cyan}{#1}}} -\def\compemph#1{{\textcolor{blue}{#1}}} -\def\titleemph#1{{\textcolor{blue}{#1}}} -\def\__omtext_lec#1{(\textcolor{green}{#1})} -% \end{macrocode} -% -% I like to use the dangerous bend symbol for warnings, so we provide it here. -% \begin{macro}{\textwarning} -% as the macro can be used quite often we put it into a box register, so that it is only -% loaded once. -% \begin{macrocode} -\pgfdeclareimage[width=.8em]{miko@small@dbend}{stex-dangerous-bend} -\def\smalltextwarning{ - \pgfuseimage{miko@small@dbend} - \xspace -} -\pgfdeclareimage[width=1.2em]{miko@dbend}{stex-dangerous-bend} -\newrobustcmd\textwarning{ - \raisebox{-.05cm}{\pgfuseimage{miko@dbend}} - \xspace -} -\pgfdeclareimage[width=2.5em]{miko@big@dbend}{stex-dangerous-bend} -\newrobustcmd\bigtextwarning{ - \raisebox{-.05cm}{\pgfuseimage{miko@big@dbend}} - \xspace -} -% \end{macrocode} -% \end{macro} -% -% \begin{macrocode} -\newrobustcmd\putgraphicsat[3]{ - \begin{picture}(0,0)\put(#1){\includegraphics[#2]{#3}}\end{picture} -} -\newrobustcmd\putat[2]{ - \begin{picture}(0,0)\put(#1){#2}\end{picture} -} -% \end{macrocode} -% % \subsection{Sectioning} % % If the |sectocframes| option is set, then we make section frames. We first define @@ -744,33 +690,48 @@ \ifcase\l_document_structure_section_level_int\or \stepcounter{part} \def\@@label{{\omdoc@part@kw}~\Roman{part}} + \addcontentsline{toc}{part}{\protect\numberline{\thepart}#2} + \pdfbookmark[0]{\thepart\ #2}{part.\thepart} \def\currentsectionlevel{\omdoc@part@kw} \or \stepcounter{chapter} \def\@@label{{\omdoc@chapter@kw}~\arabic{chapter}} + \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#2} + \pdfbookmark[1]{\thechapter\ #2}{chapter.\cs_if_exist:cT{thepart}\thepart.\thechapter} \def\currentsectionlevel{\omdoc@chapter@kw} \or \stepcounter{section} \def\@@label{\part@prefix\arabic{section}} + \addcontentsline{toc}{section}{\protect\numberline{\thesection}#2} + \pdfbookmark[2]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection\ #2} + {section.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection} \def\currentsectionlevel{\omdoc@section@kw} \or \stepcounter{subsection} \def\@@label{\part@prefix\arabic{section}.\arabic{subsection}} + \addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}#2} + \pdfbookmark[3]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection\ #2} + {subsection.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection} \def\currentsectionlevel{\omdoc@subsection@kw} \or \stepcounter{subsubsection} \def\@@label{\part@prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}} + \addcontentsline{toc}{subsubsection}{\protect\numberline{\thesubsubsection}#2} + \pdfbookmark[4]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection.\thesubsubsection\ #2} + {subsubsection.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection.\thesubsubsection} \def\currentsectionlevel{\omdoc@subsubsection@kw} \or \stepcounter{paragraph} \def\@@label{\part@prefix\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}} + \addcontentsline{toc}{paragraph}{\protect\numberline{\theparagraph}#2} + \pdfbookmark[5]{\cs_if_exist:cT{thechapter}{\thechapter.}\thesection.\thesubsection.\thesubsubsection.\theparagraph\ #2} + {paragraph.\cs_if_exist:cT{thepart}{\thepart}.\cs_if_exist:cT{thechapter}{\thechapter}.\thesection.\thesubsection.\thesubsubsection.\theparagraph} \def\currentsectionlevel{\omdoc@paragraph@kw} \else \def\@@label{} \def\currentsectionlevel{\omdoc@paragraph@kw} \fi% end ifcase - \@@label%\sref@label@id\@@label - \quad #2% + \@@label\quad #2% }% \vfill% \end{frame}% diff --git a/macros/latex/contrib/stex/source/extensions/problem.dtx b/macros/latex/contrib/stex/source/extensions/problem.dtx index 75a34eaf8e..3fcc3215ef 100644 --- a/macros/latex/contrib/stex/source/extensions/problem.dtx +++ b/macros/latex/contrib/stex/source/extensions/problem.dtx @@ -10,7 +10,7 @@ % \iffalse % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \RequirePackage[hints,solutions,notes]{problem} @@ -32,6 +32,7 @@ % \maketitle % % \ifinfulldoc\else +% \begin{documentation} % \begin{abstract} % This is the documentation for the \pkg{problem} package. % For a more high-level introduction, @@ -44,12 +45,13 @@ % \end{abstract} % % \tableofcontents -% -% \input{../../doc/packages/stex-problem} +% \begin{sfragment}{User Interface} +% \input{../../doc/packages/stex-problem} +% \ednote{MK: the input does not work! it includes the commented stuff as well. } +% \end{sfragment} +% \end{documentation} % \fi % -% \begin{documentation} -% \end{documentation} % \begin{implementation} % % \section{The Implementation}\label{sec:implementation} @@ -63,8 +65,9 @@ % \begin{macrocode} %<*package> %<@@=problems> -\ProvidesExplPackage{problem}{2022/05/24}{3.1.0}{Semantic Markup for Problems} -\RequirePackage{l3keys2e,stex} +\ProvidesExplPackage{problem}{2022/09/14}{3.2.0}{Semantic Markup for Problems} +\RequirePackage{l3keys2e} +\RequirePackage{amssymb}% for \Box \keys_define:nn { problem / pkg }{ notes .default:n = { true }, @@ -81,7 +84,11 @@ min .bool_set:N = \c_@@_min_bool, boxed .default:n = { true }, boxed .bool_set:N = \c_@@_boxed_bool, - unknown .code:n = {} + test .default:n = { true }, + test .bool_set:N = \c_@@_test_bool, + unknown .code:n = { + \PassOptionsToPackage{\CurrentOption}{stex} + } } \newif\ifsolutions @@ -91,6 +98,7 @@ }{ \solutionsfalse } +\RequirePackage{stex} % \end{macrocode} % % Then we make sure that the necessary packages are loaded (in the right versions). @@ -117,6 +125,8 @@ \def\prob@gnote@kw{Grading} \def\prob@pt@kw{pt} \def\prob@min@kw{min} +\def\prob@correct@kw{Correct} +\def\prob@wrong@kw{Wrong} % \end{macrocode} % \end{macro} % @@ -126,16 +136,16 @@ \ltx@ifpackageloaded{babel}{ \makeatletter \clist_set:Nx \l_tmpa_clist {\bbl@loaded} - \clist_if_in:NnT \l_tmpa_clist {ngerman}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{ \input{problem-ngerman.ldf} } - \clist_if_in:NnT \l_tmpa_clist {finnish}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{ \input{problem-finnish.ldf} } - \clist_if_in:NnT \l_tmpa_clist {french}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{ \input{problem-french.ldf} } - \clist_if_in:NnT \l_tmpa_clist {russian}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{ \input{problem-russian.ldf} } \makeatother @@ -178,8 +188,10 @@ % Then we set up a counter for problems. % \begin{macro}{\numberproblemsin} % \begin{macrocode} -\newcounter{problem}[section] -\newcommand\numberproblemsin[1]{\@addtoreset{problem}{#1}} +\newcounter{sproblem}[section] +\newcommand\numberproblemsin[1]{\@addtoreset{sproblem}{#1}} +\def\theplainsproblem{\arabic{sproblem}} +\def\thesproblem{\thesection.\theplainsproblem} % \end{macrocode} % \end{macro} % @@ -200,10 +212,11 @@ \int_if_exist:NTF \l_@@_prob_refnum_int { \prob@label{\int_use:N \l_@@_prob_refnum_int } }{ - \prob@label\theproblem + \prob@label\theplainsproblem } } } +\def\sproblemautorefname{\prob@problem@kw} % \end{macrocode} % \end{macro} % @@ -216,10 +229,10 @@ \tl_if_exist:NTF \l_@@_inclprob_title_tl { #2 \l_@@_inclprob_title_tl #3 }{ - \tl_if_exist:NTF \l_@@_prob_title_tl { - #2 \l_@@_prob_title_tl #3 - }{ + \tl_if_empty:NTF \l_@@_prob_title_tl { #1 + }{ + #2 \l_@@_prob_title_tl #3 } } } @@ -248,7 +261,7 @@ \newenvironment{sproblem}[1][]{ \_@@_prob_args:n{#1}%\sref@target% \@in@omtexttrue% we are in a statement (for inline definitions) - \stepcounter{problem}\record@problem + \refstepcounter{sproblem}\record@problem \def\current@section@level{\prob@problem@kw} \str_if_empty:NT \l_@@_prob_name_str { @@ -315,7 +328,7 @@ } } \stex_ref_new_doc_target:n \sproblemid - \stex_smsmode_do: + \stex_if_smsmode:TF \stex_smsmode_do: \ignorespacesandpars }{ \__stex_modules_end_module: \stex_if_smsmode:F{ @@ -408,35 +421,18 @@ % \begin{macrocode} \keys_define:nn { problem / solution }{ id .str_set_x:N = \l_@@_solution_id_str , - for .tl_set:N = \l_@@_solution_for_tl , - height .dim_set:N = \l_@@_solution_height_dim , - creators .clist_set:N = \l_@@_solution_creators_clist , - contributors .clist_set:N = \l_@@_solution_contributors_clist , - srccite .tl_set:N = \l_@@_solution_srccite_tl + for .str_set_x:N = \l_@@_solution_for_str , + type .str_set_x:N = \l_@@_solution_type_str , + title .tl_set:N = \l_@@_solution_title_tl } \cs_new_protected:Nn \_@@_solution_args:n { \str_clear:N \l_@@_solution_id_str - \tl_clear:N \l_@@_solution_for_tl - \tl_clear:N \l_@@_solution_srccite_tl - \clist_clear:N \l_@@_solution_creators_clist - \clist_clear:N \l_@@_solution_contributors_clist - \dim_zero:N \l_@@_solution_height_dim + \str_clear:N \l_@@_solution_type_str + \str_clear:N \l_@@_solution_for_str + \tl_clear:N \l_@@_solution_title_tl \keys_set:nn { problem / solution }{ #1 } } % \end{macrocode} -% the next step is to define a helper macro that does what is needed to start a solution. -% \begin{macrocode} -\newcommand\@startsolution[1][]{ - \_@@_solution_args:n { #1 } - \@in@omtexttrue% we are in a statement. - \bool_if:NF \c_@@_boxed_bool { \hrule } - \smallskip\noindent - {\textbf\prob@solution@kw :\enspace} - \begin{small} - \def\current@section@level{\prob@solution@kw} - \ignorespacesandpars -} -% \end{macrocode} % % \begin{macro}{\startsolutions} % for the |\startsolutions| macro we use the |\specialcomment| macro from the |comment| @@ -445,14 +441,20 @@ % \begin{macrocode} \box_new:N \l_@@_solution_box \newenvironment{solution}[1][]{ + \_@@_solution_args:n{#1} \stex_html_backend:TF{ \stex_if_do_html:T{ \begin{stex_annotate_env}{solution}{} + \str_if_empty:NF \l_@@_solution_type_str { + \par\noindent + \stex_annotate_invisible:nnn{typestrings}{\sexampletype}{} + } + \noindent\textbf{Solution\tl_if_empty:NF\l_@@_solution_title_tl{~(\l_@@_solution_title_tl)}: }~ } }{ \setbox\l_@@_solution_box\vbox\bgroup \par\smallskip\hrule\smallskip - \noindent\textbf{Solution:}~ + \noindent\textbf{Solution\tl_if_empty:NF\l_@@_solution_title_tl{~(\l_@@_solution_title_tl)}: }~ } }{ \stex_html_backend:TF{ @@ -463,6 +465,7 @@ \smallskip\hrule \egroup \bool_if:NT \c_@@_solutions_bool { + \strut\par\noindent \box\l_@@_solution_box } } @@ -470,6 +473,7 @@ \newcommand\startsolutions{ \bool_set_true:N \c_@@_solutions_bool + \solutionstrue % \specialcomment{solution}{\@startsolution}{ % \bool_if:NF \c_@@_boxed_bool { % \hrule\medskip @@ -485,19 +489,10 @@ % % \begin{macro}{\stopsolutions} % \begin{macrocode} -\newcommand\stopsolutions{\bool_set_false:N \c_@@_solutions_bool}%\excludecomment{solution}} +\newcommand\stopsolutions{\bool_set_false:N \c_@@_solutions_bool \solutionsfalse}%\excludecomment{solution}} % \end{macrocode} % \end{macro} -% -% so it only remains to start/stop solutions depending on what option was specified. % -% \begin{macrocode} -\ifsolutions - \startsolutions -\else - \stopsolutions -\fi -% \end{macrocode} % % \begin{environment}{exnote} % \begin{macrocode} @@ -550,8 +545,10 @@ } % \end{macrocode} % \end{environment} +% +% \subsection{Markup for Added Value Services}\label{sec:impl:avs} % -% \subsection{Multiple Choice Blocks}\label{sec:impl:mcq} +% \subsubsection{Multiple Choice Blocks}\label{sec:impl:mcq} % % \begin{environment}{mcb} % \ednote{MK: maybe import something better here from a dedicated MC package} @@ -579,8 +576,8 @@ T .bool_set:N = \l_@@_mcc_t_bool , F .default:n = { false } , F .bool_set:N = \l_@@_mcc_f_bool , - Ttext .tl_set:N = \l_@@_mcc_Ttext_str , - Ftext .tl_set:N = \l_@@_mcc_Ftext_str + Ttext .tl_set:N = \l_@@_mcc_Ttext_tl , + Ftext .tl_set:N = \l_@@_mcc_Ftext_tl } \cs_new_protected:Nn \l_@@_mcc_args:n { \str_clear:N \l_@@_mcc_id_str @@ -596,12 +593,12 @@ % % \begin{macro}{\mcc} % \begin{macrocode} -\def\mccTrueText{\textbf{(true)~}} -\def\mccFalseText{\textbf{(false)~}} +\def\mccTrueText{\textbf{\prob@correct@kw!~}} +\def\mccFalseText{\textbf{\prob@wrong@kw!~}} \newcommand\mcc[2][]{ \l_@@_mcc_args:n{ #1 } \item[$\Box$] #2 - \ifsolutions + \bool_if:NT \c_@@_solutions_bool{ \\ \bool_if:NT \l_@@_mcc_t_bool { \tl_if_empty:NTF\l_@@_mcc_Ttext_tl\mccTrueText\l_@@_mcc_Ttext_tl @@ -610,13 +607,27 @@ \tl_if_empty:NTF\l_@@_mcc_Ttext_tl\mccFalseText\l_@@_mcc_Ftext_tl } \tl_if_empty:NF \l_@@_mcc_feedback_tl { - \emph{(\l_@@_mcc_feedback_tl)} + \emph{\l_@@_mcc_feedback_tl} } - \fi + } } %solutions % \end{macrocode} % \end{macro} +% +% \subsubsection{Filling in Concrete Solutions} % +% \begin{macro}{\includeproblem} +% This is embarrasingly simple, but can grow over time. +% \begin{macrocode} +\newcommand\fillinsol[2][]{% + \def\@test{#1} + \quad% + \ifsolutions\textcolor{red}{#1!}\else% + \fbox{\ifx\@test\@empty\phantom{\huge{21}}\else\hspace{#1}\fi}% + \fi} +% \end{macrocode} +% \end{macro} +% % \subsection{Including Problems}\label{sec:impl:includeproblem} % % \begin{macro}{\includeproblem} @@ -780,15 +791,45 @@ % % \end{macrocode} % \end{macro} +% +% \subsection{Testing and Spacing} +% +% \begin{macro}{\testspace} +% \begin{macrocode} +\newcommand\testspace[1]{\bool_if:NT \c_@@_boxed_bool {\vspace*{#1}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\testnewpage} +% \begin{macrocode} +\newcommand\testnewpage{\bool_if:NT \c_@@_boxed_bool {\newpage}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\testemptypage} +% \begin{macrocode} +\newcommand\testemptypage[1][]{% +\bool_if:NT \c_@@_boxed_bool {\begin{center}\hwexam@testemptypage@kw\end{center}\vfill\eject\else}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\test*space} +% \begin{macrocode} +\newcommand\testsmallspace{\testspace{1cm}} +\newcommand\testmedspace{\testspace{2cm}} +\newcommand\testbigspace{\testspace{3cm}} +% \end{macrocode} +% \end{macro} +% % \end{implementation} % \ifinfulldoc\else\printbibliography\fi \endinput -% LocalWords: GPL structuresharing STR dtx pts keyval xcomment CPERL DefKeyVal iffalse %%% Local Variables: %%% mode: doctex %%% TeX-master: t %%% End: % \fi +% LocalWords: GPL structuresharing STR dtx pts keyval xcomment CPERL DefKeyVal iffalse % LocalWords: RequirePackage Semiverbatim DefEnvironment OptionalKeyVals soln texttt baz % LocalWords: exnote DefConstructor inclprob NeedsTeXFormat omd.sty textbackslash exfig % LocalWords: stopsolution fileversion filedate maketitle setcounter tocdepth newpage diff --git a/macros/latex/contrib/stex/source/extensions/tikzinput.dtx b/macros/latex/contrib/stex/source/extensions/tikzinput.dtx index fb7bbf76c9..acb6e4bc94 100644 --- a/macros/latex/contrib/stex/source/extensions/tikzinput.dtx +++ b/macros/latex/contrib/stex/source/extensions/tikzinput.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -67,7 +67,7 @@ % \end{macrocode} % % \begin{macrocode} -\ProvidesExplPackage{tikzinput}{2022/05/24}{3.1.0}{tikzinput package} +\ProvidesExplPackage{tikzinput}{2022/09/14}{3.2.0}{tikzinput package} \RequirePackage{l3keys2e} \keys_define:nn { tikzinput } { @@ -130,7 +130,7 @@ % \end{macrocode} % % \begin{macrocode} -\ProvidesExplPackage{stex-tikzinput}{2022/05/24}{3.1.0}{stex-tikzinput} +\ProvidesExplPackage{stex-tikzinput}{2022/09/14}{3.2.0}{stex-tikzinput} \RequirePackage{stex} \RequirePackage{tikzinput} @@ -207,5 +207,14 @@ % % \PrintIndex -% LocalWords: bibfolder jobname.dtx tikzinput.dtx usetikzlibrary Gin@ewidth Gin@eheight -% LocalWords: resizebox ctikzinput mhtikzinput Gin@mhrepos mhpath +% \endinput +% Local Variables: +% mode: doctex +% TeX-master: t +% End: + +% LocalWords: libfolder jobname.dtx tikzinput.dtx usetikzlibrary Gin@ewidth Gin@eheight +% LocalWords: ctikzinput mhpath pgfkeys@spdef pgfutil@empty 1@atcode catcode l_tmpa_str +% LocalWords: pgfutil@InputIfFileExists libusetikzlibrary msg_error:nnn notinarchive +% LocalWords: seq_clear:N seq_set_eq:NN l_tmpa_seq c_stex_mathhub_seq seq_set_split:NnV +% LocalWords: l_tmpb_seq seq_if_empty_p:N tikzlibrary seq_put_right:No seq_pop_left:NN diff --git a/macros/latex/contrib/stex/source/stex/stex-basics.dtx b/macros/latex/contrib/stex/source/stex/stex-basics.dtx index d58f56a49c..0387e16439 100644 --- a/macros/latex/contrib/stex/source/stex/stex-basics.dtx +++ b/macros/latex/contrib/stex/source/stex/stex-basics.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -150,7 +150,7 @@ %%%%%%%%%%%%% basics.dtx %%%%%%%%%%%%% \RequirePackage{expl3,l3keys2e} -\ProvidesExplClass{stex}{2022/05/24}{3.1.0}{sTeX document class} +\ProvidesExplClass{stex}{2022/09/14}{3.2.0}{sTeX document class} \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{stex}} \ProcessOptions @@ -198,14 +198,14 @@ %%%%%%%%%%%%% basics.dtx %%%%%%%%%%%%% \RequirePackage{expl3,l3keys2e,ltxcmds} -\ProvidesExplPackage{stex}{2022/05/24}{3.1.0}{sTeX package} +\ProvidesExplPackage{stex}{2022/09/14}{3.2.0}{sTeX package} \bool_if_exist:NF \c_stex_document_class_bool { \bool_set_false:N \c_stex_document_class_bool \RequirePackage{standalone} } -\message{^^J*~This~is~sTeX~version~3.1.0~*^^J} +\message{^^J*~This~is~sTeX~version~3.2.0~*^^J} %\RequirePackage{morewrites} %\RequirePackage{amsmath} @@ -287,7 +287,7 @@ \msg_redirect_module:nnn{ stex }{ none }{ term } }{ \clist_map_inline:Nn \c_stex_debug_clist { - \msg_redirect_name:nnn{ stex }{ debug / ##1 }{ term } + \msg_redirect_name:nnn{ stex }{ debug / #1 }{ term } } } @@ -367,14 +367,26 @@ % the \latexml-implementations resort to perl bindings. % % \begin{macrocode} +\ifcsname if@rustex\endcsname\else + \expandafter\newif\csname if@rustex\endcsname + \@rustexfalse +\fi +\ifcsname if@latexml\endcsname\else + \expandafter\newif\csname if@latexml\endcsname + \@latexmlfalse +\fi \tl_if_exist:NF\stex@backend{ - \ifcsname if@rustex\endcsname + \if@rustex \def\stex@backend{rustex} \else - \ifcsname if@latexml\endcsname + \if@latexml \def\stex@backend{latexml} \else - \def\stex@backend{pdflatex} + \cs_if_exist:NTF\HCode{ + \def\stex@backend{tex4ht} + }{ + \def\stex@backend{pdflatex} + } \fi \fi } @@ -482,6 +494,7 @@ } } } + % \end{macrocode} % % \subsection{Persistence} diff --git a/macros/latex/contrib/stex/source/stex/stex-features.dtx b/macros/latex/contrib/stex/source/stex/stex-features.dtx index 3a5c8064b7..d770b76e42 100644 --- a/macros/latex/contrib/stex/source/stex/stex-features.dtx +++ b/macros/latex/contrib/stex/source/stex/stex-features.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -385,6 +385,9 @@ { \l_stex_import_ns_str } { \l_stex_import_archive_str } { \l_stex_import_path_str } { \l_stex_import_name_str } } + \exp_args:Nx \stex_add_import_to_current_module:n{ + \l_stex_import_ns_str ? \l_stex_import_name_str + } \seq_map_inline:Nn \l_@@_copymodule_modules_seq { \seq_map_inline:cn {c_stex_module_##1_constants}{ @@ -594,8 +597,12 @@ \str_clear:N \l_@@_name_str \keys_set:nn { stex / features / structure } { #1 } } - \NewDocumentEnvironment{mathstructure}{m O{}}{ + \begin{mathstructure_inner}{#1}[#2] + \stex_smsmode_do: + \ignorespacesandpars + }{\end{mathstructure_inner}} +\NewDocumentEnvironment{mathstructure_inner}{m O{}}{ \_@@_structure_args:n { #2 } \str_if_empty:NT \l_@@_name_str { \str_set:Nx \l_@@_name_str { #1 } @@ -617,7 +624,6 @@ \exp_args:Nnnx \begin{structural_feature_module}{ structure } { \l_@@_name_str }{} - \stex_smsmode_do: }{ \end{structural_feature_module} \_stex_reset_up_to_module:n \l_stex_last_feature_str @@ -696,7 +702,8 @@ \seq_map_inline:Nn \l_stex_all_modules_seq { \prop_if_exist:cT {c_stex_module_##1_structures} { \prop_map_inline:cn {c_stex_module_##1_structures} { - \str_if_eq:eeT { \l_tmpa_str }{ \str_range:nnn {##1?####1}{-\l_tmpa_int}{-1}}{ + \exp_args:No \str_if_eq:nnT \l_tmpa_str {####1}{ + %\str_if_eq:eeT { \l_tmpa_str }{ \str_range:nnn {##1?####1}{-\l_tmpa_int}{-1}}{ \prop_map_break:n{\seq_map_break:n{ \tl_set:Nn \l_tmpa_tl { \str_set:Nn \l_stex_get_structure_str {##1?####1} @@ -716,6 +723,12 @@ % \begin{macro}{\instantiate} % \begin{macrocode} +\NewDocumentEnvironment{usestructure}{m}{ + \stex_get_structure:n {#1} + \exp_args:Nnx \stex_debug:nn{features}{using~structure:~\l_stex_get_structure_module_str} + \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str +}{} + \keys_define:nn { stex / instantiate } { name .str_set_x:N = \l_@@_name_str } @@ -724,6 +737,37 @@ \keys_set:nn { stex / instantiate } { #1 } } +\NewDocumentEnvironment{extstructure}{m m O{}}{ + \begin{mathstructure_inner}{#1}[#3] + \seq_set_split:Nnn\_@@_extstructure_imports_seq,{#2} + \seq_map_inline:Nn\_@@_extstructure_imports_seq { + \stex_get_structure:n {##1} + \exp_args:Nnx \stex_debug:nn{features}{importing~structure:~\l_stex_get_structure_module_str{}~into~\l_stex_current_module_str} + \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str + \stex_if_smsmode:F { + \stex_annotate_invisible:nnn + {import} {\l_stex_get_structure_module_str} {} + } + \exp_args:Nx \stex_add_import_to_current_module:n { + \l_stex_get_structure_module_str + } + \exp_args:Nx \stex_add_to_current_module:n { + \exp_args:No \stex_activate_module:n \l_stex_get_structure_module_str + } + } + \stex_smsmode_do: + \ignorespacesandpars +}{ + \end{mathstructure_inner} +} + +\NewDocumentEnvironment{extstructure*}{m m O{}}{ + % TODO + \begin{extstructure}{#1}{#2}[#3] +}{ + \end{extstructure} +} + \NewDocumentCommand \instantiate {m O{} m m O{}}{ \begingroup \stex_get_structure:n {#3} @@ -775,7 +819,8 @@ name = \l_tmpa_str , args = \prop_item:cn {l_stex_symdecl_##1_prop}{args} , arity = \prop_item:cn {l_stex_symdecl_##1_prop}{arity} , - assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs} + assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs} , + argnames = {\prop_item:cn {l_stex_symdecl_##1_prop}{argnames}} } \seq_clear:c {l_stex_symdecl_\l_stex_current_module_str?\l_tmpa_str _notations} } @@ -872,7 +917,7 @@ } \cs_new_protected:Nn \_@@_symbolorvar_from_string:n { - \prop_if_exist:cTF {l_stex_variable_#1 _prop}{ + \prop_if_exist:cTF {l_stex_symdecl_var://#1 _prop}{ \bool_set_true:N \l_stex_symbol_or_var_bool \str_set:Nn \l_stex_get_symbol_uri_str { #1 } }{ @@ -935,12 +980,12 @@ \bool_if:NTF \l_stex_symbol_or_var_bool { \exp_args:Nxx \str_if_eq:nnF {\prop_item:cn{l_stex_symdecl_\l_@@_dom_str _prop}{args}} - {\prop_item:cn{l_stex_variable_\l_stex_get_symbol_uri_str _prop}{args}}{ + {\prop_item:cn{l_stex_symdecl_var://\l_stex_get_symbol_uri_str _prop}{args}}{ \msg_error:nnxxxx{stex}{error/incompatible} {\l_@@_dom_str} {\prop_item:cn{l_stex_symdecl_\l_@@_dom_str _prop}{args}} {\l_stex_get_symbol_uri_str} - {\prop_item:cn{l_stex_variable_\l_stex_get_symbol_uri_str _prop}{args}} + {\prop_item:cn{l_stex_symdecl_var://\l_stex_get_symbol_uri_str _prop}{args}} } \prop_put:Nxx \l_tmpa_prop {\seq_item:Nn \l_tmpb_seq 1} {\stex_invoke_variable:n {\l_stex_get_symbol_uri_str}} }{ @@ -974,11 +1019,12 @@ } \exp_args:NNx \tl_gput_right:Nn \g_@@_aftergroup_tl { - \prop_set_from_keyval:cn { l_stex_variable_ \l_tmpa_str _prop}{ + \prop_set_from_keyval:cn { l_stex_symdecl_ var://\l_tmpa_str _prop}{ name = \l_tmpa_str , args = \prop_item:cn {l_stex_symdecl_##1_prop}{args} , arity = \prop_item:cn {l_stex_symdecl_##1_prop}{arity} , - assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs} + assocs = \prop_item:cn {l_stex_symdecl_##1_prop}{assocs} , + argnames = {\prop_item:cn {l_stex_symdecl_##1_prop}{argnames}} , } \cs_set_eq:cc {stex_var_notation_\l_tmpa_str _cs} {g_@@_tmpa_\l_tmpa_str _cs} diff --git a/macros/latex/contrib/stex/source/stex/stex-inheritance.dtx b/macros/latex/contrib/stex/source/stex/stex-inheritance.dtx index cde0cfa5c3..109f7af5c9 100644 --- a/macros/latex/contrib/stex/source/stex/stex-inheritance.dtx +++ b/macros/latex/contrib/stex/source/stex/stex-inheritance.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -240,7 +240,9 @@ sexample, sassertion, sparagraph, - mathstructure + mathstructure, + extstructure, + extstructure* } } % \end{macrocode} @@ -643,14 +645,11 @@ \stex_debug:nn{modules}{Importing~module:~ \l_stex_import_ns_str ? \l_stex_import_name_str } - \stex_import_require_module:nnnn - { \l_stex_import_ns_str } { \l_stex_import_archive_str } - { \l_stex_import_path_str } { \l_stex_import_name_str } \stex_if_smsmode:F { \stex_annotate_invisible:nnn {import} {\l_stex_import_ns_str ? \l_stex_import_name_str} {} } - \exp_args:Nx \stex_add_to_current_module:n { + \stex_execute_in_module:x { \stex_import_require_module:nnnn { \l_stex_import_ns_str } { \l_stex_import_archive_str } { \l_stex_import_path_str } { \l_stex_import_name_str } diff --git a/macros/latex/contrib/stex/source/stex/stex-mathhub.dtx b/macros/latex/contrib/stex/source/stex/stex-mathhub.dtx index 89da6af2fb..e7749dad93 100644 --- a/macros/latex/contrib/stex/source/stex/stex-mathhub.dtx +++ b/macros/latex/contrib/stex/source/stex/stex-mathhub.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -245,6 +245,7 @@ % \begin{macro}{\stex_path_from_string:Nn} % \begin{macrocode} \cs_new_protected:Nn \stex_path_from_string:Nn { + \stex_debug:nn{files}{#2} \str_set:Nx \l_tmpa_str { #2 } \str_if_empty:NTF \l_tmpa_str { \seq_clear:N #1 @@ -260,6 +261,7 @@ } \stex_path_canonicalize:N #1 } + \stex_debug:nn{files}{Yields: \stex_path_to_string:N#1} } % \end{macrocode} @@ -438,6 +440,7 @@ } \seq_gset_eq:NN\g_stex_currentfile_seq\g_stex_currentfile_seq \exp_args:NNo\seq_gpush:Nn\g_@@_stack\g_stex_currentfile_seq + \stex_get_document_uri: } % \end{macrocode} % \end{macro} @@ -454,6 +457,7 @@ \seq_get:NN\g_@@_stack\l_tmpa_seq \seq_gset_eq:NN\g_stex_currentfile_seq\l_tmpa_seq } + \stex_get_document_uri: } % \end{macrocode} % \end{macro} @@ -462,7 +466,11 @@ % % \begin{macrocode} \AddToHook{file/before}{ - \stex_filestack_push:n{\CurrentFilePath/\CurrentFile} + \tl_if_empty:NTF\CurrentFilePath{ + \stex_filestack_push:n{\CurrentFile} + }{ + \stex_filestack_push:n{\CurrentFilePath/\CurrentFile} + } } \AddToHook{file/after}{ \stex_filestack_pop: @@ -483,6 +491,7 @@ \begingroup\escapechar=-1\catcode`\\=12 \exp_args:Nx\stex_kpsewhich:n{-expand-var~\c_percent_str MATHHUB\c_percent_str} \exp_args:NNx\str_replace_all:Nnn\l_stex_kpsewhich_return_str{\c_backslash_str}/ + \exp_args:NNx\str_if_eq:onT\l_stex_kpsewhich_return_str{\c_percent_str MATHHUB\c_percent_str}{\str_clear:N\l_stex_kpsewhich_return_str} \exp_args:Nnx\use:nn{\endgroup}{\str_set:Nn\exp_not:N\l_stex_kpsewhich_return_str{\l_stex_kpsewhich_return_str}} }{ \stex_kpsewhich:n{-var-value~MATHHUB} @@ -498,15 +507,15 @@ }{ \stex_kpsewhich:n{-var-value~HOME} } - \ior_open:NnT \l_tmpa_ior{\l_stex_kpsewhich_return_str / .stex / mathhub.path}{ + \ior_open:NnT \g_tmpa_ior{\l_stex_kpsewhich_return_str / .stex / mathhub.path}{ \begingroup\escapechar=-1\catcode`\\=12 - \ior_str_get:NN \l_tmpa_ior \l_tmpa_str + \ior_str_get:NN \g_tmpa_ior \l_tmpa_str \sys_if_platform_windows:T{ \exp_args:NNx\str_replace_all:Nnn\l_tmpa_str{\c_backslash_str}/ } \str_gset_eq:NN \c_stex_mathhub_str\l_tmpa_str \endgroup - \ior_close:N \l_tmpa_ior + \ior_close:N \g_tmpa_ior } } \str_if_empty:NTF\c_stex_mathhub_str{ diff --git a/macros/latex/contrib/stex/source/stex/stex-metatheory.dtx b/macros/latex/contrib/stex/source/stex/stex-metatheory.dtx index 8570531d17..5a9644ac5e 100644 --- a/macros/latex/contrib/stex/source/stex/stex-metatheory.dtx +++ b/macros/latex/contrib/stex/source/stex/stex-metatheory.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} diff --git a/macros/latex/contrib/stex/source/stex/stex-modules.dtx b/macros/latex/contrib/stex/source/stex/stex-modules.dtx index 5430bd153a..e76e1ead89 100644 --- a/macros/latex/contrib/stex/source/stex/stex-modules.dtx +++ b/macros/latex/contrib/stex/source/stex/stex-modules.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -857,6 +857,20 @@ % \end{macrocode} % \end{macro} % +% \begin{environment}{mmtinterface} +% \begin{macrocode} +\NewDocumentEnvironment { mmtinterface } { O{} m m } { + \begin{smodule}[#1]{#3} + \str_set:Nx \l_stex_module_mmtfor_str {#2} + \MMTinclude{#2} + \stex_reactivate_macro:N \mmtdecl + \stex_reactivate_macro:N \mmtdef +}{ + \end{smodule} +} +% \end{macrocode} +% \end{environment} +% % \begin{macrocode} % % \end{macrocode} diff --git a/macros/latex/contrib/stex/source/stex/stex-others.dtx b/macros/latex/contrib/stex/source/stex/stex-others.dtx index e22aa88590..dd07d0e65c 100644 --- a/macros/latex/contrib/stex/source/stex/stex-others.dtx +++ b/macros/latex/contrib/stex/source/stex/stex-others.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -97,6 +97,8 @@ \exp_args:Nx \stex_set_current_repository:n { \l_tmpa_str } } } + +\stex_get_document_uri: % \end{macrocode} % % diff --git a/macros/latex/contrib/stex/source/stex/stex-proofs.dtx b/macros/latex/contrib/stex/source/stex/stex-proofs.dtx index c2cdb3b54e..7c48dc2f89 100644 --- a/macros/latex/contrib/stex/source/stex/stex-proofs.dtx +++ b/macros/latex/contrib/stex/source/stex/stex-proofs.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -87,7 +87,9 @@ title .tl_set:N = \spftitle, continues .tl_set:N = \l_@@_spf_continues_tl, functions .tl_set:N = \l_@@_spf_functions_tl, - method .tl_set:N = \l_@@_spf_method_tl + term .tl_set:N = \l_@@_spf_term_tl, + method .tl_set:N = \l_@@_spf_method_tl, + hide .bool_set:N = \l_@@_spf_hide_bool } \cs_new_protected:Nn \_@@_spf_args:n { \str_clear:N \spfid @@ -97,11 +99,13 @@ \str_clear:N \spftype \tl_clear:N \spftitle \tl_clear:N \l_@@_spf_continues_tl + \tl_clear:N \l_@@_spf_term_tl \tl_clear:N \l_@@_spf_functions_tl \tl_clear:N \l_@@_spf_method_tl - \bool_set_false:N \l_@@_inc_counter_bool + \bool_set_false:N \l_@@_spf_hide_bool \keys_set:nn { stex / spf }{ #1 } } +\bool_set_true:N \l_@@_inc_counter_bool % \end{macrocode} % % \begin{macro}{\c_@@_flow_str} @@ -275,96 +279,30 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{spfeq} -% This is very similar to |\spfsketch|, but uses a computation array\ednote{This should -% really be more like a tabular with an ensuremath in it. or invoke text on the last -% column}\ednote{document above} +% \begin{macro}{\_@@_maybe_comment:,\_@@_maybe_comment_end:,\_@@_start_comment:} % \begin{macrocode} -\newenvironment{spfeq}[2][]{ - \_@@_spf_args:n{#1} - \let \premise \stex_proof_premise: - \stex_if_smsmode:TF { - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - }{ - \seq_clear:N \l_tmpa_seq - \clist_map_inline:Nn \l_@@_spf_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{spfeq}{\seq_use:Nn \l_tmpa_seq {,}} - \str_if_empty:NF \spftype { - \stex_annotate_invisible:nnn{type}{\spftype}{} - } +\bool_set_false:N \l_@@_in_spfblock_bool - \clist_set:No \l_tmpa_clist \spftype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_spfeq_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_spfeq_##1_start:}} - } - \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} { - \tl_set:Nn \l_tmpa_tl {\use:n{}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_spfeq_start: - }{ - \l_tmpa_tl - }{~#2} - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - \begin{displaymath}\begin{array}{rcll} - } - \stex_smsmode_do: -}{ - \stex_if_smsmode:F { - \end{array}\end{displaymath} - \clist_set:No \l_tmpa_clist \spftype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_spfeq_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_spfeq_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_spfeq_end: - }{ - \l_tmpa_tl - } - \end{stex_annotate_env} +\cs_new_protected:Nn \_@@_maybe_comment: { + \bool_if:NF \l_@@_in_spfblock_bool { + \par \setbox \l_tmpa_box \vbox \bgroup \everypar{\_@@_start_comment:} } } - -\cs_new_protected:Nn \_@@_spfeq_start: { - \titleemph{ - \tl_if_empty:NTF \spftitle { - \spf@proof@kw - }{ - \spftitle - } - }: +\cs_new_protected:Nn \_@@_maybe_comment_end: { + \bool_if:NF \l_@@_in_spfblock_bool { \egroup } } -\cs_new_protected:Nn \_@@_spfeq_end: {\sproofend} - -\newcommand\stexpatchspfeq[3][] { - \str_set:Nx \l_tmpa_str{ #1 } - \str_if_empty:NTF \l_tmpa_str { - \tl_set:Nn \_@@_spfeq_start: { #2 } - \tl_set:Nn \_@@_spfeq_end: { #3 } - }{ - \exp_after:wN \tl_set:Nn \csname _@@_spfeq_#1_start:\endcsname{ #2 } - \exp_after:wN \tl_set:Nn \csname _@@_spfeq_#1_end:\endcsname{ #3 } - } +\cs_new_protected:Nn \_@@_start_comment: { + \csname @ @ par\endcsname\egroup\item[]\bgroup\stexcommentfont } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\stexcommentfont} +% \begin{macrocode} +\cs_new_protected:Npn \stexcommentfont { + \small\itshape +} % \end{macrocode} % \end{macro} % @@ -373,70 +311,113 @@ % up the description environment that will take the proof steps. At the end of the % proof, we position the proof end into the last line. % \begin{macrocode} -\newenvironment{sproof}[2][]{ - \let \premise \stex_proof_premise: +\cs_new_protected:Nn \_@@_start_env:nnn { + \seq_clear:N \l_tmpa_seq + \clist_map_inline:Nn \l_@@_spf_for_clist { + \tl_if_empty:nF{ ##1 }{ + \stex_get_symbol:n { ##1 } + \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { + \l_stex_get_symbol_uri_str + } + } + } + \exp_args:Nnnx + \begin{stex_annotate_env}{#1}{\seq_use:Nn \l_tmpa_seq {,}} + \str_if_empty:NF \spftype { + \stex_annotate_invisible:nnn{type}{\spftype}{} + } + #3 {~\stex_annotate:nnn{spftitle}{}{#2}} + \str_if_empty:NF \spfid { + \stex_ref_new_doc_target:n \spfid + } + \begin{stex_annotate_env}{spfbody}{\bool_if:NTF \l_@@_spf_hide_bool {false}{true}} + \bool_if:NT \l_@@_spf_hide_bool{ + \stex_html_backend:F{\setbox\l_tmpa_box\vbox\bgroup} + } + \begin{list}{}{ + \setlength\topsep{0pt} + \setlength\parsep{0pt} + \setlength\rightmargin{0pt} + + }\_@@_maybe_comment: +} +\cs_new_protected:Nn \_@@_end_env:n { + \stex_if_smsmode:F{ + \_@@_maybe_comment_end: + \end{list} + \bool_if:NT \l_@@_spf_hide_bool{ + \stex_html_backend:F{\egroup} + } + \clist_set:No \l_tmpa_clist \spftype + #1 + \end{stex_annotate_env} + \end{stex_annotate_env} + } +} +\NewDocumentEnvironment{sproof}{s O{} m}{ \intarray_gzero:N \l_@@_counter_intarray \intarray_gset:Nnn \l_@@_counter_intarray 1 1 - \_@@_spf_args:n{#1} + \stex_reactivate_macro:N \yield + \stex_reactivate_macro:N \eqstep + \stex_reactivate_macro:N \assumption + \stex_reactivate_macro:N \conclude + \stex_reactivate_macro:N \spfstep + \_@@_spf_args:n{#2} \stex_if_smsmode:TF { \str_if_empty:NF \spfid { \stex_ref_new_doc_target:n \spfid } }{ - \seq_clear:N \l_tmpa_seq - \clist_map_inline:Nn \l_@@_spf_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \l_stex_get_symbol_uri_str + \_@@_start_env:nnn{sproof}{#3}{ + \clist_set:No \l_tmpa_clist \spftype + \tl_clear:N \l_tmpa_tl + \clist_map_inline:Nn \l_tmpa_clist { + \tl_if_exist:cT {_@@_sproof_##1_start:}{ + \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sproof_##1_start:}} + } + \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} { + \tl_set:Nn \l_tmpa_tl {\use:n{}} } } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{sproof}{\seq_use:Nn \l_tmpa_seq {,}} - \str_if_empty:NF \spftype { - \stex_annotate_invisible:nnn{type}{\spftype}{} - } - - \clist_set:No \l_tmpa_clist \spftype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sproof_##1_start:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sproof_##1_start:}} - } - \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} { - \tl_set:Nn \l_tmpa_tl {\use:n{}} + \tl_if_empty:NTF \l_tmpa_tl { + \_@@_sproof_start: + }{ + \l_tmpa_tl } } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sproof_start: - }{ - \l_tmpa_tl - }{~#2} + } + \stex_smsmode_do: +}{\_@@_end_env:n{ + \tl_clear:N \l_tmpa_tl + \clist_map_inline:Nn \l_tmpa_clist { + \tl_if_exist:cT {_@@_sproof_##1_end:}{ + \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sproof_##1_end:}} + } + } + \tl_if_empty:NTF \l_tmpa_tl { + \_@@_sproof_end: + }{ + \l_tmpa_tl + } +}} +\NewDocumentEnvironment{subproof}{s O{} m}{ + \_@@_spf_args:n{#2} + \stex_if_smsmode:TF { \str_if_empty:NF \spfid { \stex_ref_new_doc_target:n \spfid } - \begin{description} + }{ + \_@@_start_env:nnn{subproof}{\item[\sproofnumber]\ignorespacesandpars #3}{} } + \_@@_add_counter: \stex_smsmode_do: -}{ - \stex_if_smsmode:F{ - \end{description} - \clist_set:No \l_tmpa_clist \spftype - \tl_clear:N \l_tmpa_tl - \clist_map_inline:Nn \l_tmpa_clist { - \tl_if_exist:cT {_@@_sproof_##1_end:}{ - \tl_set:Nn \l_tmpa_tl {\use:c{_@@_sproof_##1_end:}} - } - } - \tl_if_empty:NTF \l_tmpa_tl { - \_@@_sproof_end: - }{ - \l_tmpa_tl - } - \end{stex_annotate_env} +}{\_@@_remove_counter:\_@@_end_env:n{} + \bool_if:NT \l_@@_inc_counter_bool { + \_@@_inc_counter: } + \aftergroup\_@@_maybe_comment: } +\AddToHook{env/subproof/before}{\_@@_maybe_comment_end:} \cs_new_protected:Nn \_@@_sproof_start: { \par\noindent\titleemph{ @@ -461,290 +442,103 @@ } % \end{macrocode} % \end{environment} -% -% \begin{macro}{\spfidea} -% \begin{macrocode} -\newcommand\spfidea[2][]{ - \_@@_spf_args:n{#1} - \titleemph{ - \tl_if_empty:NTF \spftype {Proof~Idea}{ - \spftype - }: - }~#2 - \sproofend -} -% \end{macrocode} -% \end{macro} % -% The next two environments (proof steps) and comments, are mostly semantical, they take -% |KeyVal| arguments that specify their semantic role. In draft mode, they read these -% values and show them. If the surrounding proof had |display=flow|, then no new |\item| is -% generated, otherwise it is. In any case, the proof step number (at the current level) is -% incremented. -% \begin{environment}{spfstep} +% \begin{macro}{\pstep,\conclude,\assumption,\have,\eqstep} % \begin{macrocode} -\newenvironment{spfstep}[1][]{ - \_@@_spf_args:n{#1} - \stex_if_smsmode:TF { - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - }{ - \@in@omtexttrue - \clist_set:No \l_tmpa_clist \spftype - \tl_set:Nn \l_tmpa_tl { - \item[\sproofnumber] - \bool_set_true:N \l_@@_inc_counter_bool - } - \clist_map_inline:Nn \l_tmpa_clist { - \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} { - \tl_clear:N \l_tmpa_tl - } - } - \l_tmpa_tl - \seq_clear:N \l_tmpa_seq - \clist_map_inline:Nn \l_@@_spf_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{spfstep}{\seq_use:Nn \l_tmpa_seq {,}} - \str_if_empty:NF \spftype { - \stex_annotate_invisible:nnn{type}{\spftype}{} - } - \tl_if_empty:NF \spftitle { - {(\titleemph{\spftitle})\enspace} - } - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - } - \stex_smsmode_do: - \ignorespacesandpars -}{ - \bool_if:NT \l_@@_inc_counter_bool { - \_@@_inc_counter: - } - \stex_if_smsmode:F { - \end{stex_annotate_env} - } + +\keys_define:nn { stex / spfsteps } { + id .str_set_x:N = \spfstepid, + for .clist_set:N = \l_@@_spf_for_clist , + type .str_set_x:N = \spftype, + title .tl_set:N = \spftitle, + method .tl_set:N = \l_@@_spf_method_tl, + term .tl_set:N = \l_@@_spf_term_tl } -% \end{macrocode} -% \end{environment} -% -% \begin{environment}{spfcomment} -% \begin{macrocode} -\newenvironment{spfcomment}[1][]{ - \_@@_spf_args:n{#1} - \clist_set:No \l_tmpa_clist \spftype - \tl_set:Nn \l_tmpa_tl { - \item[\sproofnumber] - \bool_set_true:N \l_@@_inc_counter_bool - } - \clist_map_inline:Nn \l_tmpa_clist { - \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} { - \tl_clear:N \l_tmpa_tl - } - } - \l_tmpa_tl -}{ - \bool_if:NT \l_@@_inc_counter_bool { - \_@@_inc_counter: - } +\cs_new_protected:Nn \_@@_spfstep_args:n { + \str_clear:N \spfstepid + \clist_clear:N \l_@@_spf_for_clist + \str_clear:N \spftype + \tl_clear:N \l_@@_spf_method_tl + \tl_clear:N \l_@@_spf_term_tl + %\bool_set_false:N \l_@@_inc_counter_bool + \keys_set:nn { stex / spfsteps }{ #1 } } -% \end{macrocode} -% \end{environment} -% -% The next two environments also take a |KeyVal| argument, but also a regular one, which -% contains a start text. Both environments start a new numbered proof level. -% -% \begin{environment}{subproof} -% In the |subproof| environment, a new (lower-level) proproofof environment is started. -% \begin{macrocode} -\newenvironment{subproof}[2][]{ - \_@@_spf_args:n{#1} - \stex_if_smsmode:TF{ - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - }{ - \seq_clear:N \l_tmpa_seq - \clist_map_inline:Nn \l_@@_spf_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{subproof}{\seq_use:Nn \l_tmpa_seq {,}} - \str_if_empty:NF \spftype { - \stex_annotate_invisible:nnn{type}{\spftype}{} - } - \clist_set:No \l_tmpa_clist \spftype - \tl_set:Nn \l_tmpa_tl { - \item[\sproofnumber] - \bool_set_true:N \l_@@_inc_counter_bool - } - \clist_map_inline:Nn \l_tmpa_clist { - \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} { - \tl_clear:N \l_tmpa_tl +\cs_new_protected:Nn \_@@_make_step_macro:Nnnnn { + \NewDocumentCommand #1 {s O{} +m} { + \_@@_maybe_comment_end: + + \_@@_spfstep_args:n{##2} + \stex_annotate:nnn{spfstep}{#2}{ + \tl_if_empty:NF \l_@@_spf_term_tl { + \stex_annotate_invisible:nnn{spfyield}{}{$\l_@@_spf_term_tl$} } + \bool_if:NTF \l_@@_in_spfblock_bool { + #4 + }{ + \item[\IfBooleanTF ##1 {}{#3}] + } + \ignorespacesandpars ##3 } - \l_tmpa_tl - \tl_if_empty:NF \spftitle { - {(\titleemph{\spftitle})\enspace} - } - {~#2} - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } - } - \_@@_add_counter: - \stex_smsmode_do: -}{ - \_@@_remove_counter: - \bool_if:NT \l_@@_inc_counter_bool { - \_@@_inc_counter: - } - \stex_if_smsmode:F{ - \end{stex_annotate_env} + \bool_if:NF \l_@@_in_spfblock_bool { \IfBooleanTF ##1 {}{ #5 } } + \_@@_maybe_comment: } + \stex_deactivate_macro:Nn #1 {sproof~environments} } -% \end{macrocode} -% \end{environment} -% -% \begin{environment}{spfcases} -% In the |pfcases| environment, the start text is displayed as the first comment of the -% proof. -% \begin{macrocode} -\newenvironment{spfcases}[2][]{ - \tl_if_empty:nTF{#1}{ - \begin{subproof}[method=by-cases]{#2} - }{ - \begin{subproof}[#1,method=by-cases]{#2} - } -}{ - \end{subproof} -} -% \end{macrocode} -% \end{environment} -% -% \begin{environment}{spfcase} -% In the |pfcase| environment, the start text is displayed specification of the case -% after the |\item| -% \begin{macrocode} -\newenvironment{spfcase}[2][]{ - \_@@_spf_args:n{#1} - \stex_if_smsmode:TF { - \str_if_empty:NF \spfid { - \stex_ref_new_doc_target:n \spfid - } + +\_@@_make_step_macro:Nnnnn \assumption {assumption} \sproofnumber {} \_@@_inc_counter: +\_@@_make_step_macro:Nnnnn \conclude {conclusion} {$\Rightarrow$} {} {} +\_@@_make_step_macro:Nnnnn \spfstep {} \sproofnumber {} \_@@_inc_counter: + +\NewDocumentCommand \eqstep {s m}{ + \_@@_maybe_comment_end: + \bool_if:NTF \l_@@_in_spfblock_bool { + $=$ }{ - \seq_clear:N \l_tmpa_seq - \clist_map_inline:Nn \l_@@_spf_for_clist { - \tl_if_empty:nF{ ##1 }{ - \stex_get_symbol:n { ##1 } - \exp_args:NNo \seq_put_right:Nn \l_tmpa_seq { - \l_stex_get_symbol_uri_str - } - } - } - \exp_args:Nnnx - \begin{stex_annotate_env}{spfcase}{\seq_use:Nn \l_tmpa_seq {,}} - \str_if_empty:NF \spftype { - \stex_annotate_invisible:nnn{type}{\spftype}{} - } - \clist_set:No \l_tmpa_clist \spftype - \tl_set:Nn \l_tmpa_tl { - \item[\sproofnumber] - \bool_set_true:N \l_@@_inc_counter_bool - } - \clist_map_inline:Nn \l_tmpa_clist { - \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} { - \tl_clear:N \l_tmpa_tl - } - } - \l_tmpa_tl - \tl_if_empty:nF{#2}{ - \titleemph{#2}:~ - } - } - \_@@_add_counter: - \stex_smsmode_do: -}{ - \_@@_remove_counter: - \bool_if:NT \l_@@_inc_counter_bool { - \_@@_inc_counter: - } - \stex_if_smsmode:F{ - \clist_set:No \l_tmpa_clist \spftype - \tl_set:Nn \l_tmpa_tl{\sproofend} - \clist_map_inline:Nn \l_tmpa_clist { - \exp_args:No \str_if_eq:nnT \c_@@_flow_str {##1} { - \tl_clear:N \l_tmpa_tl - } - } - \l_tmpa_tl - \end{stex_annotate_env} + \item[$=$] } + $\stex_annotate:nnn{spfstep}{eq}{ #2 }$ + \_@@_maybe_comment: } -% \end{macrocode} -% \end{environment} -% -% \begin{environment}{spfcase} -% similar to |spfcase|, takes a third argument. -% \begin{macrocode} -\newcommand\spfcasesketch[3][]{ - \begin{spfcase}[#1]{#2}#3\end{spfcase} +\stex_deactivate_macro:Nn \eqstep {sproof~environments} + +\NewDocumentCommand \yield {+m}{ + \stex_annotate:nnn{spfyield}{}{ #1 } } -% \end{macrocode} -% \end{environment} -% -% \subsection{Justifications} -% -% We define the actions that are undertaken, when the keys for justifications are -% encountered. Here this is very simple, we just define an internal macro with the value, -% so that we can use it later. -% \begin{macrocode} -\keys_define:nn { stex / just }{ - id .str_set_x:N = \l_@@_just_id_str, - method .tl_set:N = \l_@@_just_method_tl, - premises .tl_set:N = \l_@@_just_premises_tl, - args .tl_set:N = \l_@@_just_args_tl +\stex_deactivate_macro:Nn \yield {sproof~environments} + +\NewDocumentEnvironment{spfblock}{}{ + \item[] + \bool_set_true:N \l_@@_in_spfblock_bool +}{ + \aftergroup\_@@_maybe_comment: } -% \end{macrocode} -% -% The next three environments and macros are purely semantic, so we ignore the keyval -% arguments for now and only display the content.\ednote{need to do something about the -% premise in draft mode.} -% -% \begin{macro}{\spfjust} -% \begin{macrocode} -\newcommand\spfjust[1][]{} +\AddToHook{env/spfblock/before}{\_@@_maybe_comment_end:} + % \end{macrocode} % \end{macro} % -% \begin{macro}{\premise} +% +% \begin{macro}{\spfidea} % \begin{macrocode} -\newcommand\stex_proof_premise:[2][]{#2} +\NewDocumentCommand\spfidea{O{} +m}{ + \_@@_spf_args:n{#1} + \titleemph{ + \tl_if_empty:NTF \spftype {Proof~Idea}{ + \spftype + }: + }~#2 + \sproofend +} % \end{macrocode} % \end{macro} % -% \begin{macro}{\justarg} -% the |\justarg| macro is purely semantic, so we ignore the keyval arguments for now and -% only display the content. % \begin{macrocode} -\newcommand\justarg[2][]{#2} +\newcommand\spfjust[1]{ + #1 +} % % \end{macrocode} -% \end{macro} % \end{implementation} % \Finale % \ifinfulldoc\else\printbibliography\fi diff --git a/macros/latex/contrib/stex/source/stex/stex-references.dtx b/macros/latex/contrib/stex/source/stex/stex-references.dtx index 96506e71f1..841115fd0e 100644 --- a/macros/latex/contrib/stex/source/stex/stex-references.dtx +++ b/macros/latex/contrib/stex/source/stex/stex-references.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -47,22 +47,11 @@ % % \section{Macros and Environments}\label{pkg:sref:doc:macros} % -% \begin{function}{\STEXreftitle} -% \begin{syntax} \cs{STEXreftitle}\Arg{some title} \end{syntax} -% -% Sets the title of the current document to \meta{some title}. -% A reference to the current document from \emph{some other} -% document will then be displayed accordingly. e.g. -% if |\STEXreftitle{foo book}| is called, then referencing -% Definition 3.5 in this document in another document will display -% |Definition 3.5 in foo book|. -% \end{function} % % \begin{function}{\stex_get_document_uri:} -% Computes the current document uri from the current archive's -% |narr|-field and its location relative to the archive's -% |source|-directory. Reference targets are computed from -% this URI and the reference-id. +% Computes the current document uri from the current archive's |narr|-field and its +% location relative to the archive's |source|-directory. Reference targets are computed +% from this URI and the reference-id. % % \begin{variable}{\l_stex_current_docns_str} % Stores its result in |\l_stex_current_docns_str| @@ -70,11 +59,9 @@ % \end{function} % % \begin{function}{\stex_get_document_url:} -% Computes the current URL from the current archive's -% |docurl|-field and its location relative to the archive's -% |source|-directory. Reference targets are computed from -% this URL and the reference-id, if this document is only included -% in SMS mode. +% Computes the current URL from the current archive's |docurl|-field and its location +% relative to the archive's |source|-directory. Reference targets are computed from this +% URL and the reference-id, if this document is only included in SMS mode. % % \begin{variable}{\l_stex_current_docurl_str} % Stores its result in |\l_stex_current_docurl_str| @@ -132,7 +119,7 @@ % \begin{macrocode} %<*package> -%%%%%%%%%%%%% references.dtx %%%%%%%%%%%%% +%%%%%%%%%%%%% stex-references.dtx %%%%%%%%%%%%% %<@@=stex_refs> % \end{macrocode} @@ -140,31 +127,30 @@ % Warnings and error messages % % \begin{macrocode} - +\msg_new:nnn{stex}{error/extrefmissing}{ + Missing~in~or~cite~value~for~\detokenize{\extref}! +} +\msg_new:nnn{stex}{warning/smsmissing}{ + .sref~file~#1~doesn't~exist! +} +\msg_new:nnn{stex}{warning/smslabelmissing}{ + No~label~#2~in~.sref~file~#1! +} % \end{macrocode} % % References are stored in the file |\jobname.sref|, to enable % cross-referencing external documents. % % \begin{macrocode} -%\iow_new:N \c_@@_refs_iow +\iow_new:N \c_@@_refs_iow \AtBeginDocument{ -% \iow_open:Nn \c_@@_refs_iow {\jobname.sref} + \iow_open:Nn \c_@@_refs_iow {\jobname.sref} } \AtEndDocument{ -% \iow_close:N \c_@@_refs_iow + \iow_close:N \c_@@_refs_iow } % \end{macrocode} % -% \begin{macro}{\STEXreftitle} -% \begin{macrocode} -\str_set:Nn \g_@@_title_tl {Unnamed~Document} - -\NewDocumentCommand \STEXreftitle { m } { - \tl_gset:Nx \g_@@_title_tl { #1 } -} -% \end{macrocode} -% \end{macro} % % \subsection{Document URIs and URLs} % @@ -208,13 +194,14 @@ } \seq_if_empty:NTF \l_tmpa_seq { - \str_set_eq:NN \l_stex_current_docns_str \l_tmpa_str + \str_gset_eq:NN \l_stex_current_docns_str \l_tmpa_str }{ - \str_set:Nx \l_stex_current_docns_str { + \str_gset:Nx \l_stex_current_docns_str { \l_tmpa_str/\stex_path_to_string:N \l_tmpa_seq } } } + %\stex_get_document_url: } % \end{macrocode} % \end{macro} @@ -281,57 +268,98 @@ % @currentlabel -> number % @currentlabelname -> title % @currentHref -> name.number <- id of some kind +% @currentcounter <- name/id +% \#autorefname <- "Section" % \theH# -> \arabic{section} % \the# -> number % \hyper@makecurrent{#} \int_new:N \l_@@_unnamed_counter_int % \end{macrocode} % +% Restoring references from |.sref|-files +% +% \begin{macro}{\STEXInternalSrefRestoreTarget} +% \begin{macrocode} +\cs_new_protected:Npn \STEXInternalSrefRestoreTarget #1#2#3#4#5 {} +% \end{macrocode} +% \end{macro} +% +% % \begin{macro}{\stex_ref_new_doc_target:n} % \begin{macrocode} +\seq_new:N \g_stex_ref_files_seq + \cs_new_protected:Nn \stex_ref_new_doc_target:n { - \stex_get_document_uri: + %\stex_get_document_uri: \str_clear:N \l_@@_curr_label_str \str_set:Nx \l_tmpa_str { #1 } \str_if_empty:NT \l_tmpa_str { - \int_incr:N \l_@@_unnamed_counter_int + \int_gincr:N \l_@@_unnamed_counter_int \str_set:Nx \l_tmpa_str {REF\int_use:N \l_@@_unnamed_counter_int} } \str_set:Nx \l_@@_curr_label_str { \l_stex_current_docns_str?\l_tmpa_str } - \seq_if_exist:cF{g_@@_labels_\l_tmpa_str _seq}{ - \seq_new:c {g_@@_labels_\l_tmpa_str _seq} - } - \seq_if_in:coF{g_@@_labels_\l_tmpa_str _seq}\l_@@_curr_label_str { - \seq_gput_right:co{g_@@_labels_\l_tmpa_str _seq}\l_@@_curr_label_str - } + + \exp_args:Noo \STEXInternalAuxAddDocRef\l_stex_current_docns_str\l_tmpa_str + + %\seq_if_exist:cF{g_@@_labels_\l_tmpa_str _seq}{ + % \seq_new:c {g_@@_labels_\l_tmpa_str _seq} + %} + %\seq_if_in:coF{g_@@_labels_\l_tmpa_str _seq}\l_@@_curr_label_str { + % \seq_gput_right:co{g_@@_labels_\l_tmpa_str _seq}\l_@@_curr_label_str + %} + + \stex_if_smsmode:TF { - \stex_get_document_url: - \str_gset_eq:cN {sref_url_\l_@@_curr_label_str _str}\l_stex_current_docurl_str - \str_gset_eq:cN {sref_\l_@@_curr_label_str _type}\c_@@_url_str + %\stex_get_document_url: + %\str_gset_eq:cN {sref_url_\l_@@_curr_label_str _str}\l_stex_current_docurl_str + %\str_gset_eq:cN {sref_\l_@@_curr_label_str _type}\c_@@_url_str }{ - %\iow_now:Nx \c_@@_refs_iow { \l_tmpa_str~=~\expandafter\unexpanded\expandafter{\@currentlabel}~in~\exp_args:No\unexpanded\g_@@_title_tl,} + \iow_now:Nx \c_@@_refs_iow { + \STEXInternalSrefRestoreTarget + {\l_stex_current_docns_str} + {\l_tmpa_str} + {\@currentcounter} + {\@currentlabel} + {\tl_if_exist:NT\@currentlabelname{\exp_args:No\unexpanded\@currentlabelname}} + } + %\iow_now:Nx \c_@@_refs_iow { + % {\l_stex_current_docns_str?\l_tmpa_str}~=~{{\use:c{\@currentcounter autorefname}~\@currentlabel}~(\@currentlabelname)~in~\exp_args:No\unexpanded\g_@@_title_tl},} + \stex_debug:nn{sref}{New~label~\l_@@_curr_label_str~at~\use:c{\use:c{@currentcounter}autorefname}} \exp_args:Nx\label{sref_\l_@@_curr_label_str} - \immediate\write\@auxout{\stexauxadddocref{\l_stex_current_docns_str}{\l_tmpa_str}} - \str_gset:cx {sref_\l_@@_curr_label_str _type}\c_@@_ref_str + \immediate\write\@auxout{\STEXInternalAuxAddDocRef{\l_stex_current_docns_str}{\l_tmpa_str}} + %\str_gset:cx {sref_\l_@@_curr_label_str _type}\c_@@_ref_str } } +\NewDocumentCommand \slabel {m} {\stex_ref_new_doc_target:n {#1}} % \end{macrocode} % \end{macro} % % The following is used to set the necessary macros in the |.aux|-file. % % \begin{macrocode} -\cs_new_protected:Npn \stexauxadddocref #1 #2 { - \str_set:Nn \l_tmpa_str {#1?#2} - \str_gset_eq:cN{sref_#1?#2_type}\c_@@_ref_str - \seq_if_exist:cF{g_@@_labels_#2_seq}{ - \seq_new:c {g_@@_labels_#2_seq} - } - \seq_if_in:coF{g_@@_labels_#2_seq}\l_tmpa_str { - \seq_gput_right:co{g_@@_labels_#2_seq}\l_tmpa_str +\cs_new_protected:Npn \STEXInternalAuxAddDocRef #1 #2 { + \exp_args:NNx \seq_if_in:NnTF \g_stex_ref_files_seq {\detokenize{#1}} { + \exp_args:Nnx \seq_if_in:cnF{g_stex_ref_ #1 _seq}{\detokenize{#2}}{ + \exp_args:Nnx \seq_gput_left:cn{g_stex_ref_ #1 _seq}{\detokenize{#2}} + } + }{ + \exp_args:NNx \seq_gput_right:Nn \g_stex_ref_files_seq {\detokenize{#1}} + %\seq_if_exist:cF{g_stex_ref_ #1 _seq}{ + \seq_new:c{g_stex_ref_ #1 _seq} % <- seq_new throws errors?? + %} + \exp_args:Nnx \seq_gput_left:cn{g_stex_ref_ #1 _seq}{\detokenize{#2}} } + + %\str_set:Nn \l_tmpa_str {#1?#2} + %\str_gset_eq:cN{sref_#1?#2_type}\c_@@_ref_str + %\seq_if_exist:cF{g_@@_labels_#2_seq}{ + % \seq_new:c {g_@@_labels_#2_seq} + %} + %\seq_if_in:coF{g_@@_labels_#2_seq}\l_tmpa_str { + % \seq_gput_right:co{g_@@_labels_#2_seq}\l_tmpa_str + %} } % \end{macrocode} % To avoid resetting the same macros when the |.aux|-file is read @@ -339,122 +367,314 @@ % % \begin{macrocode} \AtEndDocument{ - \def\stexauxadddocref#1 #2 {}{} + \def\STEXInternalAuxAddDocRef#1 #2 {}{} } % \end{macrocode} % % \begin{macro}{\stex_ref_new_sym_target:n} % \begin{macrocode} \cs_new_protected:Nn \stex_ref_new_sym_target:n { - \stex_if_smsmode:TF { - \str_if_exist:cF{sref_sym_#1_type}{ - \stex_get_document_url: - \str_gset_eq:cN {sref_sym_url_#1_str}\l_stex_current_docurl_str - \str_gset_eq:cN {sref_sym_#1_type}\c_@@_url_str - } - }{ - \str_if_empty:NF \l_@@_curr_label_str { - \str_gset_eq:cN {sref_sym_#1_label_str}\l_@@_curr_label_str - \immediate\write\@auxout{ - \exp_not:N\expandafter\def\exp_not:N\csname \exp_not:N\detokenize{sref_sym_#1_label_str}\exp_not:N\endcsname{ - \l_@@_curr_label_str - } - } - } - } + +% \stex_if_smsmode:TF { +% \str_if_exist:cF{sref_sym_#1_type}{ +% \stex_get_document_url: +% \str_gset_eq:cN {sref_sym_url_#1_str}\l_stex_current_docurl_str +% \str_gset_eq:cN {sref_sym_#1_type}\c_@@_url_str +% } +% }{ +% \str_if_empty:NF \l_@@_curr_label_str { +% \str_gset_eq:cN {sref_sym_#1_label_str}\l_@@_curr_label_str +% \immediate\write\@auxout{ +% \exp_not:N\expandafter\def\exp_not:N\csname \exp_not:N\detokenize{sref_sym_#1_label_str}\exp_not:N\endcsname{ +% \l_@@_curr_label_str +% } +% } +% } +% } } % \end{macrocode} % \end{macro} % % \subsection{Using References} % -% \begin{macrocode} -\str_new:N \l_@@_indocument_str -% \end{macrocode} -% % \begin{macro}{\sref} % Optional arguments: % \begin{macrocode} -\keys_define:nn { stex / sref } { - linktext .tl_set:N = \l_@@_linktext_tl , - fallback .tl_set:N = \l_@@_fallback_tl , - pre .tl_set:N = \l_@@_pre_tl , - post .tl_set:N = \l_@@_post_tl , +\keys_define:nn { stex / sref / 1 } { + archive .str_set_x:N = \l_@@_repo_str, + file .str_set_x:N = \l_@@_file_str, + % TODO get rid of this + fallback .code:n = {}, + pre .code:n = {}, + post .code:n = {} } -\cs_new_protected:Nn \_@@_args:n { - \tl_clear:N \l_@@_linktext_tl - \tl_clear:N \l_@@_fallback_tl - \tl_clear:N \l_@@_pre_tl - \tl_clear:N \l_@@_post_tl +\cs_new_protected:Nn \_@@_args_i:n { \str_clear:N \l_@@_repo_str - \keys_set:nn { stex / sref } { #1 } + \str_clear:N \l_@@_file_str + \keys_set:nn { stex / sref / 1 } { #1 } +} +\keys_define:nn { stex / sref / 2 } { + in .str_set_x:N = \l_@@_in_str, + archive .str_set_x:N = \l_@@_repob_str, + title .tl_set:N = \l_@@_title_tl +} +\cs_new_protected:Nn \_@@_args_ii:n { + \str_clear:N \l_@@_in_str + \tl_clear:N \l_@@_title_tl + \str_clear:N \l_@@_repob_str + \keys_set:nn { stex / sref / 2 } { #1 } } % \end{macrocode} % The actual macro: % \begin{macrocode} -\NewDocumentCommand \sref { O{} m}{ - \_@@_args:n { #1 } - \str_if_empty:NTF \l_@@_indocument_str { - \str_set:Nx \l_tmpa_str { #2 } - \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq ? \l_tmpa_str - \int_compare:nNnTF {\seq_count:N \l_tmpa_seq} = 1 { - \seq_if_exist:cTF{g_@@_labels_\l_tmpa_str _seq}{ - \seq_get_left:cNF {g_@@_labels_\l_tmpa_str _seq} \l_tmpa_str { - \str_clear:N \l_tmpa_str +\NewDocumentCommand \sref { O{} m O{}}{ + \_@@_args_i:n{#1} + \_@@_args_ii:n{#3} + \str_clear:N \l_@@_uri_str + \_@@_find_uri:n{#2} + \_@@_do_sref:n{#2} +} +\NewDocumentCommand \extref { O{} m m}{ + \_@@_args_i:n{#1} + \_@@_args_ii:n{#3} + \str_if_empty:NT \l_@@_in_str { + \msg_error:nn{stex}{error/extrefmissing} + } + \str_clear:N \l_@@_uri_str + \_@@_find_uri:n{#2} + \_@@_do_sref_in:n{#2} +} + +\cs_new_protected:Nn \_@@_find_uri:n { + \stex_debug:nn{sref}{File:~\l_@@_file_str^^JRepo:\l_@@_repo_str} + \str_if_empty:NTF \l_@@_file_str { + \stex_debug:nn{sref}{Empty.~Checking~current~file~for~#1} + \seq_if_exist:cT{g_stex_ref_\l_stex_current_docns_str _seq}{ + \seq_map_inline:cn{g_stex_ref_\l_stex_current_docns_str _seq}{ + \str_if_eq:nnT{#1}{##1}{ + \str_set_eq:NN \l_@@_uri_str \l_stex_current_docns_str + \stex_debug:nn{sref}{Found.} + \seq_map_break: } - }{ - \str_clear:N \l_tmpa_str } - }{ - \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str - \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str - \int_set:Nn \l_tmpa_int { \exp_args:Ne \str_count:n {\l_tmpb_str?\l_tmpa_str} } - \seq_if_exist:cTF{g_@@_labels_\l_tmpa_str _seq}{ - \str_set_eq:NN \l_tmpc_str \l_tmpa_str - \str_clear:N \l_tmpa_str - \seq_map_inline:cn {g_@@_labels_\l_tmpc_str _seq} { - \str_if_eq:eeT { \l_tmpb_str?\l_tmpc_str }{ - \str_range:nnn { ##1 }{ -\l_tmpa_int}{ -1 } - }{ - \seq_map_break:n { - \str_set:Nn \l_tmpa_str { ##1 } - } + } + \str_if_empty:NT \l_@@_uri_str { + \stex_debug:nn{sref}{Checking~other~files} + \seq_map_inline:Nn \g_stex_ref_files_seq { + \stex_debug:nn{sref}{##1...} + \seq_map_inline:cn{g_stex_ref_##1_seq}{ + \str_if_eq:nnT{#1}{####1}{ + \stex_debug:nn{sref}{Found~##1} + \str_set:Nn \l_@@_uri_str {##1} + \seq_map_break:n{\seq_map_break:} } } + } + } + }{ + \str_if_empty:NTF \l_@@_repo_str { + \prop_if_exist:NTF \l_stex_current_repository_prop { + \prop_get:NnN \l_stex_current_repository_prop { ns } \l_@@_uri_str + \str_set:Nx \l_@@_uri_str {\l_@@_uri_str / \l_@@_file_str} + \stex_path_from_string:Nn \l_tmpb_seq \l_@@_uri_str + \str_set:Nx \l_@@_uri_str {\stex_path_to_string:N \l_tmpb_seq} }{ - \str_clear:N \l_tmpa_str + \stex_path_from_string:Nn \l_tmpb_seq { + \stex_path_to_string:N \g_stex_currentfile_seq/ .. / \l_@@_file_str + } + \str_set:Nx \l_@@_uri_str {file:/\stex_path_to_string:N \l_tmpb_seq} } + }{ + \stex_require_repository:n \l_@@_repo_str + \prop_get:cnN { c_stex_mathhub_\l_@@_repo_str _manifest_prop } { ns } \l_@@_uri_str + \str_set:Nx \l_@@_uri_str {\l_@@_uri_str / \l_@@_file_str} + \stex_path_from_string:Nn \l_tmpb_seq \l_@@_uri_str + \str_set:Nx \l_@@_uri_str {\stex_path_to_string:N \l_tmpb_seq} } - \str_if_empty:NTF \l_tmpa_str { - \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl + } +} + +\cs_new_protected:Nn \_@@_do_autoref:n{ + \cs_if_exist:cTF{autoref}{ + \exp_args:Nx\autoref{sref_#1} + }{ + \exp_args:Nx\ref{sref_#1} + } +} + +\cs_new_protected:Nn \_@@_do_sref:n { + \str_if_empty:NTF \l_@@_uri_str { + \str_if_empty:NTF \l_@@_in_str { + \stex_debug:nn{sref}{autoref~on~#1} + \_@@_do_autoref:n{#1} }{ - \str_if_eq:cNTF {sref_\l_tmpa_str _type} \c_@@_ref_str { - \tl_if_empty:NTF \l_@@_linktext_tl { - \cs_if_exist:cTF{autoref}{ - \l_@@_pre_tl\exp_args:Nx\autoref{sref_\l_tmpa_str}\l_@@_post_tl - }{ - \l_@@_pre_tl\exp_args:Nx\ref{sref_\l_tmpa_str}\l_@@_post_tl - } - }{ - \ltx@ifpackageloaded{hyperref}{ - \hyperref[sref_\l_tmpa_str]\l_@@_linktext_tl - }{ - \l_@@_linktext_tl - } - } + \stex_debug:nn{sref}{srefin~on~#1} + \_@@_do_sref_in:n{#1} + } + }{ + \exp_args:NNo \seq_if_in:NnTF \g_stex_ref_files_seq \l_@@_uri_str { + \exp_args:Nnx \seq_if_in:cnTF{g_stex_ref_\l_@@_uri_str _seq}{\detokenize{#1}}{ + \stex_debug:nn{sref}{Reference~found~in~ref~files;~autoref~on~#1} + \_@@_do_autoref:n{\l_@@_uri_str?#1} }{ - \ltx@ifpackageloaded{hyperref}{ - \href{\use:c{sref_url_\l_tmpa_str _str}}{\tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl} + \str_if_empty:NTF \l_@@_in_str { + \stex_debug:nn{sref}{in~empty;~autoref~on~#1} + \_@@_do_autoref:n{#1} }{ - \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl + \stex_debug:nn{sref}{in~non-empty;~srefin~on~#1} + \_@@_do_sref_in:n{#1} } } + }{ + \str_if_empty:NTF \l_@@_in_str { + \stex_debug:nn{sref}{in~empty;~autoref~on~#1} + \_@@_do_autoref:n{#1} + }{ + \stex_debug:nn{sref}{in~non-empty;~srefin~on~#1} + \_@@_do_sref_in:n{#1} + } + } + } +} + +\cs_new_protected:Nn \_@@_restore_target:nnnnn { + \str_if_empty:NTF \l_@@_uri_str { + \exp_args:No \str_if_eq:nnT \l_@@_id_str {#2}{ + \tl_set:Nn \l_@@_return_tl { + \use:c{#3autorefname}~#4\tl_if_empty:nF{#5}{~(#5)}~in~ + \tl_if_empty:nTF\l_@@_title_tl{ + ??? + }\l_@@_title_tl + } } }{ - % TODO + \stex_debug:nn{sref}{\l_@@_uri_str{}~ == ~ #1 ~ ?} + \exp_args:No \str_if_eq:nnT \l_@@_uri_str {#1}{ + \stex_debug:nn{sref}{\l_@@_id_str~ == ~ #2 ~ ?} + \exp_args:No \str_if_eq:nnT \l_@@_id_str {#2}{ + \stex_debug:nn{sref}{success!} + \tl_set:Nn \l_@@_return_tl { + \use:c{#3autorefname}~#4\tl_if_empty:nF{#5}{~(#5)}~in~ + \tl_if_empty:nTF\l_@@_title_tl{ + ??? + }\l_@@_title_tl + } + \endinput + } + } } } + +\cs_new_protected:Nn \_@@_do_sref_in:n { + \stex_debug:nn{sref}{In: \l_@@_in_str^^JRepo:\l_@@_repo_str} + \stex_debug:nn{sref}{URI: \l_@@_uri_str?#1} + %\msg_warning:nnn{stex}{warning/smsmissing}{} + \begingroup\catcode13=9\relax\catcode10=9\relax + \str_if_empty:NTF \l_@@_repob_str { + \prop_if_exist:NTF \l_stex_current_repository_prop { + \str_set:Nx \l_tmpa_str { + \c_stex_mathhub_str / + \prop_item:Nn \l_stex_current_repository_prop { id } + / source / \l_@@_in_str .sref + } + }{ + \str_set:Nx \l_tmpa_str { + \stex_path_to_string:N \g_stex_currentfile_seq/ .. / \l_@@_in_str . sref + } + } + }{ + \str_set:Nx \l_tmpa_str { + \c_stex_mathhub_str / \l_@@_repob_str + / source / \l_@@_in_str . sref + } + } + \stex_path_from_string:Nn \l_tmpb_seq \l_tmpa_str + \stex_path_to_string:NN \l_tmpb_seq \l_tmpa_str + \stex_debug:nn{sref}{File: \l_tmpa_str} + \exp_args:No \IfFileExists \l_tmpa_str { + \tl_clear:N \l_@@_return_tl + \str_set:Nn \l_@@_id_str {#1} + \let\STEXInternalSrefRestoreTarget\_@@_restore_target:nnnnn + \use:c{@ @ input}{\l_tmpa_str} + \exp_args:No \tl_if_empty:nTF \l_@@_return_tl { + \exp_args:Nnno \msg_warning:nnnn{stex}{warning/smslabelmissing}\l_tmpa_str{#1} + \_@@_do_autoref:n{ + \str_if_empty:NF\l_@@_uri_str{\l_@@_uri_str?}#1 + } + }{ + \l_@@_return_tl + } + }{ + \exp_args:Nnno \msg_warning:nnn{stex}{warning/smsmissing}\l_tmpa_str + \_@@_do_autoref:n{ + \str_if_empty:NF\l_@@_uri_str{\l_@@_uri_str?}#1 + } + } + \endgroup +} + + % \_@@_args:n { #1 } + % \str_if_empty:NTF \l_@@_indocument_str { + % \str_set:Nx \l_tmpa_str { #2 } + % \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq ? \l_tmpa_str + % \int_compare:nNnTF {\seq_count:N \l_tmpa_seq} = 1 { + % \seq_if_exist:cTF{g_@@_labels_\l_tmpa_str _seq}{ + % \seq_get_left:cNF {g_@@_labels_\l_tmpa_str _seq} \l_tmpa_str { + % \str_clear:N \l_tmpa_str + % } + % }{ + % \str_clear:N \l_tmpa_str + % } + % }{ + % \seq_pop_left:NN \l_tmpa_seq \l_tmpb_str + % \seq_pop_right:NN \l_tmpa_seq \l_tmpa_str + % \int_set:Nn \l_tmpa_int { \exp_args:Ne \str_count:n {\l_tmpb_str?\l_tmpa_str} } + % \seq_if_exist:cTF{g_@@_labels_\l_tmpa_str _seq}{ + % \str_set_eq:NN \l_tmpc_str \l_tmpa_str + % \str_clear:N \l_tmpa_str + % \seq_map_inline:cn {g_@@_labels_\l_tmpc_str _seq} { + % \str_if_eq:eeT { \l_tmpb_str?\l_tmpc_str }{ + % \str_range:nnn { ##1 }{ -\l_tmpa_int}{ -1 } + % }{ + % \seq_map_break:n { + % \str_set:Nn \l_tmpa_str { ##1 } + % } + % } + % } + % }{ + % \str_clear:N \l_tmpa_str + % } + % } + % \str_if_empty:NTF \l_tmpa_str { + % \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl + % }{ + % \str_if_eq:cNTF {sref_\l_tmpa_str _type} \c_@@_ref_str { + % \tl_if_empty:NTF \l_@@_linktext_tl { + % \cs_if_exist:cTF{autoref}{ + % \l_@@_pre_tl\exp_args:Nx\autoref{sref_\l_tmpa_str}\l_@@_post_tl + % }{ + % \l_@@_pre_tl\exp_args:Nx\ref{sref_\l_tmpa_str}\l_@@_post_tl + % } + % }{ + % \ltx@ifpackageloaded{hyperref}{ + % \hyperref[sref_\l_tmpa_str]\l_@@_linktext_tl + % }{ + % \l_@@_linktext_tl + % } + % } + % }{ + % \ltx@ifpackageloaded{hyperref}{ + % \href{\use:c{sref_url_\l_tmpa_str _str}}{\tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl} + % }{ + % \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl + % } + % } + % } + % }{ + % TODO + % } +%} % \end{macrocode} % \end{macro} % @@ -466,52 +686,53 @@ } \cs_new_protected:Nn \_@@_sym_aux:nn { - \str_if_exist:cTF {sref_sym_#2 _label_str }{ - \sref[#1]{\use:c{sref_sym_#2 _label_str}} - }{ - \_@@_args:n { #1 } - \str_if_empty:NTF \l_@@_indocument_str { - \tl_if_exist:cTF{sref_sym_#2 _type}{ - % doc uri in \l_tmpb_str - \str_set:Nx \l_tmpa_str {\use:c{sref_sym_#2 _type}} - \str_if_eq:NNTF \l_tmpa_str \c_@@_ref_str { - % reference - \tl_if_empty:NTF \l_@@_linktext_tl { - \cs_if_exist:cTF{autoref}{ - \l_@@_pre_tl\autoref{sref_sym_#2}\l_@@_post_tl - }{ - \l_@@_pre_tl\ref{sref_sym_#2}\l_@@_post_tl - } - }{ - \ltx@ifpackageloaded{hyperref}{ - \hyperref[sref_sym_#2]\l_@@_linktext_tl - }{ - \l_@@_linktext_tl - } - } - }{ - % URL - \ltx@ifpackageloaded{hyperref}{ - \href{\use:c{sref_sym_url_#2 _str}}{\tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl} - }{ - \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl - } - } - }{ - \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl - } - }{ - % TODO - } - } + +% \str_if_exist:cTF {sref_sym_#2 _label_str }{ +% \sref[#1]{\use:c{sref_sym_#2 _label_str}} +% }{ +% \_@@_args:n { #1 } +% \str_if_empty:NTF \l_@@_indocument_str { +% \tl_if_exist:cTF{sref_sym_#2 _type}{ +% % doc uri in \l_tmpb_str +% \str_set:Nx \l_tmpa_str {\use:c{sref_sym_#2 _type}} +% \str_if_eq:NNTF \l_tmpa_str \c_@@_ref_str { +% % reference +% \tl_if_empty:NTF \l_@@_linktext_tl { +% \cs_if_exist:cTF{autoref}{ +% \l_@@_pre_tl\autoref{sref_sym_#2}\l_@@_post_tl +% }{ +% \l_@@_pre_tl\ref{sref_sym_#2}\l_@@_post_tl +% } +% }{ +% \ltx@ifpackageloaded{hyperref}{ +% \hyperref[sref_sym_#2]\l_@@_linktext_tl +% }{ +% \l_@@_linktext_tl +% } +% } +% }{ +% % URL +% \ltx@ifpackageloaded{hyperref}{ +% \href{\use:c{sref_sym_url_#2 _str}}{\tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl} +% }{ +% \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl +% } +% } +% }{ +% \tl_if_empty:NTF \l_@@_linktext_tl \l_@@_fallback_tl \l_@@_linktext_tl +% } +% }{ +% % TODO +% } +% } } % \end{macrocode} % \end{macro} % % \begin{macro}{\srefsymuri} % \begin{macrocode} -\cs_new_protected:Npn \srefsymuri #1 #2 { - \_@@_sym_aux:nn{linktext={#2}}{#1} +\cs_new_protected:Npn \srefsymuri #1 #2 { % TODO + #2%\_@@_sym_aux:nn{linktext={#2}}{#1} } % \end{macrocode} % \end{macro} diff --git a/macros/latex/contrib/stex/source/stex/stex-statements.dtx b/macros/latex/contrib/stex/source/stex/stex-statements.dtx index 6a66eb80e7..cab2a678c8 100644 --- a/macros/latex/contrib/stex/source/stex/stex-statements.dtx +++ b/macros/latex/contrib/stex/source/stex/stex-statements.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -365,6 +365,7 @@ } } \clist_set_from_seq:NN \l_@@_sdefinition_for_clist \l_tmpb_seq + \ifvmode\noindent\fi \exp_args:Nnx \stex_annotate:nnn{definition}{\seq_use:Nn \l_tmpb_seq {,}}{ \str_if_empty:NF \sdefinitiontype { @@ -542,6 +543,7 @@ } } } + \ifvmode\noindent\fi \exp_args:Nnx \stex_annotate:nnn{assertion}{\seq_use:Nn \l_tmpb_seq {,}}{ \str_if_empty:NF \sassertiontype { @@ -705,6 +707,7 @@ } } } + \ifvmode\noindent\fi \exp_args:Nnx \stex_annotate:nnn{example}{\seq_use:Nn \l_tmpb_seq {,}}{ \str_if_empty:NF \sexampletype { @@ -926,6 +929,7 @@ } } } + \ifvmode\noindent\fi \exp_args:Nnx \stex_annotate:nnn{paragraph}{\seq_use:Nn \l_tmpb_seq {,}}{ \str_if_empty:NF \sparagraphtype { diff --git a/macros/latex/contrib/stex/source/stex/stex-symbols.dtx b/macros/latex/contrib/stex/source/stex/stex-symbols.dtx index ba9fa5f097..e5e7982abc 100644 --- a/macros/latex/contrib/stex/source/stex/stex-symbols.dtx +++ b/macros/latex/contrib/stex/source/stex/stex-symbols.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -60,9 +60,6 @@ % passed on to \mmt for semantic services. % \item |def|: An (ideally semantic) term, representing a \emph{definiens}. Not used by \sTeX, but % passed on to \mmt for semantic services. -% \item |local|: A boolean (by default false). If set, this declaration -% will not be added to the module content, i.e. importing -% the current module will not make this declaration available. % \item |args|: Specifies the ``signature'' of the semantic macro. % Can be either an integer $0 \leq n \leq 9$, or a (more precise) % sequence of the following characters: @@ -92,7 +89,6 @@ % \item |name| (string), % \item |module| (string), % \item |notations| (sequence of strings; initially empty), -% \item |local| (boolean), % \item |type| (token list), % \item |args| (string of |i|s, |a|s and |b|s), % \item |arity| (integer string), @@ -204,15 +200,14 @@ % \begin{macrocode} \keys_define:nn { stex / symdecl } { name .str_set_x:N = \l_stex_symdecl_name_str , - local .bool_set:N = \l_stex_symdecl_local_bool , args .str_set_x:N = \l_stex_symdecl_args_str , type .tl_set:N = \l_stex_symdecl_type_tl , deprecate .str_set_x:N = \l_stex_symdecl_deprecate_str , align .str_set:N = \l_stex_symdecl_align_str , % TODO(?) gfc .str_set:N = \l_stex_symdecl_gfc_str , % TODO(?) - specializes .str_set:N = \l_stex_symdecl_specializes_str , % TODO(?) def .tl_set:N = \l_stex_symdecl_definiens_tl , reorder .str_set_x:N = \l_stex_symdecl_reorder_str , + argnames .clist_set:N = \l_stex_symdecl_argnames_clist , assoc .choices:nn = {bin,binl,binr,pre,conj,pwconj} {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}} @@ -229,6 +224,7 @@ \bool_set_false:N \l_stex_symdecl_local_bool \tl_clear:N \l_stex_symdecl_type_tl \tl_clear:N \l_stex_symdecl_definiens_tl + \clist_clear:N \l_stex_symdecl_argnames_clist \keys_set:nn { stex / symdecl } { #1 } } @@ -324,6 +320,7 @@ }{##1} } } + \bool_if:NTF \l_tmpa_bool { % possibly numeric \str_if_empty:NTF \l_stex_symdecl_args_str { @@ -351,6 +348,19 @@ \prop_put:Nnx \l_tmpa_prop { defined }{ true } } + % argnames + + \clist_clear:N \l_tmpa_clist + \int_step_inline:nn {\prop_item:Nn \l_tmpa_prop {arity}} { + \clist_if_empty:NTF \l_stex_symdecl_argnames_clist { + \clist_put_right:Nn \l_tmpa_clist {##1} + }{ + \clist_pop:NN \l_stex_symdecl_argnames_clist \l_tmpa_tl + \exp_args:NNx \clist_put_right:Nn \l_tmpa_clist {\c_dollar_str\l_tmpa_tl} + } + } + \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,} + % semantic macro \bool_if:NT \l_stex_symdecl_make_macro_bool { @@ -396,7 +406,7 @@ _prop } { \bool_if:NTF \l_stex_symdecl_local_bool \stex_do_up_to_module:x \stex_execute_in_module:x { - \_@@_restore_symbol:nnnnnnn + \_@@_restore_symbol:nnnnnnnn {\l_stex_symdecl_name_str} { \prop_item:Nn \l_tmpa_prop {args} } { \prop_item:Nn \l_tmpa_prop {arity} } @@ -404,10 +414,11 @@ { \prop_item:Nn \l_tmpa_prop {defined} } {\bool_if:NT \l_stex_symdecl_make_macro_bool {#1} } {\l_stex_current_module_str} + { \prop_item:Nn \l_tmpa_prop {argnames} } } } } -\cs_new_protected:Nn \_@@_restore_symbol:nnnnnnn { +\cs_new_protected:Nn \_@@_restore_symbol:nnnnnnnn { \prop_clear:N \l_tmpa_prop \prop_put:Nnn \l_tmpa_prop { module } { #7 } \prop_put:Nnn \l_tmpa_prop { name } { #1} @@ -415,6 +426,7 @@ \prop_put:Nnn \l_tmpa_prop { arity } { #3 } \prop_put:Nnn \l_tmpa_prop { assocs } { #4 } \prop_put:Nnn \l_tmpa_prop { defined } { #5 } + \prop_put:Nnn \l_tmpa_prop { argnames } { #8 } \tl_if_empty:nF{#6}{ \tl_set:cx{#6}{\stex_invoke_symbol:n{\detokenize{#7 ? #1}}} } @@ -435,6 +447,7 @@ \cs_new_protected:Nn \_stex_textsymdecl_args:n { \str_clear:N \l_@@_name_str \tl_clear:N \l_@@_type_tl + \clist_clear:N \l_stex_symdecl_argnames_clist \keys_set:nn { stex / textsymdecl } { #1 } } @@ -450,12 +463,12 @@ \stex_execute_in_module:n{ \cs_set_nopar:cpn{#1name}{ \ifvmode\hbox_unpack:N\c_empty_box\fi - \hbox{#3}\xspace + \ifmmode\hbox{#3}\else#3\fi\xspace } \cs_set_nopar:cpn{#1}{ \ifmmode\csname#1-sym\expandafter\endcsname\else \ifvmode\hbox_unpack:N\c_empty_box\fi - \symref{#1-sym}{\hbox{#3}}\expandafter\xspace + \symref{#1-sym}{#3}\expandafter\xspace \fi } } @@ -594,12 +607,13 @@ % \begin{macrocode} \keys_define:nn { stex / notation } { % lang .tl_set_x:N = \l_@@_lang_str , - variant .tl_set_x:N = \l_@@_variant_str , - prec .str_set_x:N = \l_@@_prec_str , - op .tl_set:N = \l_@@_op_tl , - primary .bool_set:N = \l_@@_primary_bool , - primary .default:n = {true} , - unknown .code:n = \str_set:Nx + variant .tl_set_x:N = \l_@@_variant_str , + prec .str_set_x:N = \l_@@_prec_str , + op .tl_set:N = \l_@@_op_tl , + primary .bool_set:N = \l_@@_primary_bool , + primary .default:n = {true} , + hints .str_set_x:N = \l_@@_hints_str, + unknown .code:n = \str_set:Nx \l_@@_variant_str \l_keys_key_str } @@ -607,6 +621,7 @@ % \str_clear:N \l_@@_lang_str \str_clear:N \l_@@_variant_str \str_clear:N \l_@@_prec_str + \str_clear:N \l_@@_hints_str \tl_clear:N \l_@@_op_tl \bool_set_false:N \l_@@_primary_bool @@ -677,7 +692,7 @@ \exp_args:NNNo \exp_args:NNno \seq_set_split:Nnn \l_tmpa_seq {\tl_to_str:n{x} } { \l_tmpa_str } \seq_map_inline:Nn \l_tmpa_seq { - \seq_put_right:Nn \l_tmpb_seq { ##1 } + \seq_put_right:Nn \l_@@_precedences_seq { ##1 } } } }{ @@ -824,11 +839,12 @@ \seq_pop_left:NN \l_@@_remaining_precs_seq \l_tmpa_str \tl_put_right:Nx \l_stex_notation_dummyargs_tl { { - \STEXInternalTermMathAssocArgiiii - { #1\int_use:N \l_@@_currarg_int } + \STEXInternalTermMathAssocArgiiiii + { \int_use:N \l_@@_currarg_int } { \l_tmpa_str } { ####\int_use:N \l_@@_currarg_int } { \l_tmpa_cs {####1} {####2} } + {#1} } } \_@@_arguments: } @@ -1036,7 +1052,6 @@ % \begin{macrocode} \keys_define:nn { stex / symdef } { name .str_set_x:N = \l_stex_symdecl_name_str , - local .bool_set:N = \l_stex_symdecl_local_bool , args .str_set_x:N = \l_stex_symdecl_args_str , type .tl_set:N = \l_stex_symdecl_type_tl , def .tl_set:N = \l_stex_symdecl_definiens_tl , @@ -1045,6 +1060,7 @@ % lang .str_set_x:N = \l_@@_lang_str , variant .str_set_x:N = \l_@@_variant_str , prec .str_set_x:N = \l_@@_prec_str , + argnames .clist_set:N = \l_stex_symdecl_argnames_clist , assoc .choices:nn = {bin,binl,binr,pre,conj,pwconj} {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}, @@ -1060,6 +1076,7 @@ \bool_set_false:N \l_stex_symdecl_local_bool \tl_clear:N \l_stex_symdecl_type_tl \tl_clear:N \l_stex_symdecl_definiens_tl + \clist_clear:N \l_stex_symdecl_argnames_clist % \str_clear:N \l_@@_lang_str \str_clear:N \l_@@_variant_str \str_clear:N \l_@@_prec_str @@ -1086,6 +1103,70 @@ { \l_@@_prec_str} } \stex_deactivate_macro:Nn \symdef {module~environments} + +\keys_define:nn { stex / mmtdef } { + name .str_set_x:N = \l_stex_symdecl_name_str , + args .str_set_x:N = \l_stex_symdecl_args_str , + reorder .str_set_x:N = \l_stex_symdecl_reorder_str , + op .tl_set:N = \l_@@_op_tl , + % lang .str_set_x:N = \l_@@_lang_str , + variant .str_set_x:N = \l_@@_variant_str , + prec .str_set_x:N = \l_@@_prec_str , + argnames .clist_set:N = \l_stex_symdecl_argnames_clist , + assoc .choices:nn = + {bin,binl,binr,pre,conj,pwconj} + {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}}, + unknown .code:n = \str_set:Nx + \l_@@_variant_str \l_keys_key_str +} +\cs_new_protected:Nn \_stex_mmtdef_args:n { + \str_clear:N \l_stex_symdecl_name_str + \str_clear:N \l_stex_symdecl_args_str + \str_clear:N \l_stex_symdecl_assoctype_str + \str_clear:N \l_stex_symdecl_reorder_str + \bool_set_false:N \l_stex_symdecl_local_bool + \clist_clear:N \l_stex_symdecl_argnames_clist + % \str_clear:N \l_@@_lang_str + \str_clear:N \l_@@_variant_str + \str_clear:N \l_@@_prec_str + \tl_clear:N \l_@@_op_tl + + \keys_set:nn { stex / mmtdef } { #1 } +} + +\NewDocumentCommand \mmtdef {m O{} }{ + \_stex_mmtdef_args:n{ #2 } + \bool_set_true:N \l_stex_symdecl_make_macro_bool + \str_if_empty:NT \l_stex_symdecl_name_str { + \str_set:Nx \l_stex_symdecl_name_str { #1 } + } + %\tl_set:Nx \l_stex_symdecl_definiens_tl { + % \stex_annotate:nnn{ OMID }{ + % \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str + % }{} + %} + \stex_symdecl_do:n { #1 } + \MMTrule{rules.stex.mmt.kwarc.info?SubstitutionRule}{ + \stex_annotate:nnn{ OMID }{ + \l_stex_current_module_str ? \l_stex_symdecl_name_str + }{}, + \stex_annotate:nnn{ OMID }{ + \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str + }{} + } + \tl_set:Nn \l_stex_notation_after_do_tl { + \_@@_final: + \stex_smsmode_do:\ignorespacesandpars + } + \str_set:Nx \l_stex_get_symbol_uri_str { + \l_stex_current_module_str ? \l_stex_symdecl_name_str + } + \exp_args:Nx \stex_notation_do:nnnnn + { \prop_item:cn {l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { args } } + { \prop_item:cn { l_stex_symdecl_\l_stex_get_symbol_uri_str _prop } { arity } } + { \l_@@_variant_str } + { \l_@@_prec_str} +} % \end{macrocode} % \end{macro} % @@ -1102,6 +1183,7 @@ op .tl_set:N = \l_@@_op_tl , prec .str_set_x:N = \l_@@_prec_str , reorder .str_set_x:N = \l_@@_reorder_str , + argnames .clist_set:N = \l_@@_argnames_clist , assoc .choices:nn = {bin,binl,binr,pre,conj,pwconj} {\str_set:Nx \l_@@_assoctype_str {\l_keys_choice_tl}}, @@ -1120,6 +1202,7 @@ \tl_clear:N \l_@@_type_tl \tl_clear:N \l_@@_def_tl \tl_clear:N \l_@@_op_tl + \clist_clear:N \l_@@_argnames_clist \keys_set:nn { stex / vardef } { #1 } } @@ -1176,7 +1259,21 @@ \prop_put:Nnx \l_tmpa_prop { assocs } { \int_use:N \l_tmpb_int } \tl_set:cx { #1 }{ \stex_invoke_variable:n { \l_@@_name_str } } - \prop_set_eq:cN { l_stex_variable_\l_@@_name_str _prop} \l_tmpa_prop + % argnames + + \clist_clear:N \l_tmpa_clist + \int_step_inline:nn {\prop_item:Nn \l_tmpa_prop {arity}} { + \clist_if_empty:NTF \l_@@_argnames_clist { + \clist_put_right:Nn \l_tmpa_clist {##1} + }{ + \clist_pop:NN \l_@@_argnames_clist \l_tmpa_tl + \exp_args:NNx \clist_put_right:Nn \l_tmpa_clist {\c_dollar_str\l_tmpa_tl} + } + } + \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,} + + + \prop_set_eq:cN { l_stex_symdecl_var://\l_@@_name_str _prop} \l_tmpa_prop \tl_if_empty:NF \l_@@_op_tl { \cs_set:cpx { @@ -1352,6 +1449,17 @@ \cs_generate_from_arg_count:cNnn {stex_varseq_\l_@@_name_str _cs} \cs_set:Npn {\int_use:N \l_@@_args_int} { #5 } + + % argnames + + \clist_clear:N \l_tmpa_clist + \int_step_inline:nn {\l_@@_args_int} { + \clist_put_right:Nn \l_tmpa_clist {##1} + } + \prop_put:Nnx \l_tmpa_prop {argnames} {\clist_use:Nn \l_tmpa_clist ,} + + + \exp_args:NNo \tl_set:No \l_tmpa_tl {\use:c{stex_varseq_\l_@@_name_str _cs}} \int_step_inline:nn \l_@@_args_int { @@ -1399,6 +1507,8 @@ \expandafter\meaning\csname stex_varseq_\l_@@_name_str _cs\endcsname\\~\\ \prop_to_keyval:N \l_tmpa_prop } + \prop_set_eq:cN {l_stex_symdecl_varseq://\l_@@_name_str _prop}\l_tmpa_prop + \stex_if_do_html:T{\stex_annotate_invisible:nnn{varseq}{\l_@@_name_str}{ \tl_if_empty:NF \l_@@_type_tl { \stex_annotate:nnn {type}{}{$\l_@@_type_tl$} @@ -1428,10 +1538,63 @@ }} - \prop_set_eq:cN {stex_varseq_\l_@@_name_str _prop}\l_tmpa_prop \ignorespacesandpars } + +\keys_define:nn { stex / mmtdecl } { + name .str_set_x:N = \l_stex_symdecl_name_str , + args .str_set_x:N = \l_stex_symdecl_args_str , + deprecate .str_set_x:N = \l_stex_symdecl_deprecate_str , + reorder .str_set_x:N = \l_stex_symdecl_reorder_str , + argnames .clist_set:N = \l_stex_symdecl_argnames_clist , + assoc .choices:nn = + {bin,binl,binr,pre,conj,pwconj} + {\str_set:Nx \l_stex_symdecl_assoctype_str {\l_keys_choice_tl}} +} + +\cs_new_protected:Nn \_stex_mmtdecl_args:n { + \str_clear:N \l_stex_symdecl_name_str + \str_clear:N \l_stex_symdecl_args_str + \str_clear:N \l_stex_symdecl_deprecate_str + \str_clear:N \l_stex_symdecl_reorder_str + \str_clear:N \l_stex_symdecl_assoctype_str + \bool_set_false:N \l_stex_symdecl_local_bool + \clist_clear:N \l_stex_symdecl_argnames_clist + + \keys_set:nn { stex / symdecl } { #1 } +} + +\NewDocumentCommand \mmtdecl { s m O{}} { + \_stex_mmtdecl_args:n{#3} + \IfBooleanTF #1 { + \bool_set_false:N \l_stex_symdecl_make_macro_bool + } { + \bool_set_true:N \l_stex_symdecl_make_macro_bool + } + \str_if_empty:NT \l_stex_symdecl_name_str { + \str_set:Nx \l_stex_symdecl_name_str { #1 } + } + %\tl_set:Nx \l_stex_symdecl_definiens_tl { + % \stex_annotate:nnn{ OMID }{ + % \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str + % }{} + %} + \stex_symdecl_do:n{#2} + \MMTrule{rules.stex.mmt.kwarc.info?SubstitutionRule}{ + \stex_annotate:nnn{ OMID }{ + \l_stex_current_module_str ? \l_stex_symdecl_name_str + }{}, + \stex_annotate:nnn{ OMID }{ + \l_stex_module_mmtfor_str?\l_stex_symdecl_name_str + }{} + } + \stex_smsmode_do: +} + +\stex_deactivate_macro:Nn \mmtdecl {mmtinterface~environments} +\stex_deactivate_macro:Nn \mmtdef {mmtinterface~environments} + % \end{macrocode} % % \begin{macrocode} diff --git a/macros/latex/contrib/stex/source/stex/stex-terms.dtx b/macros/latex/contrib/stex/source/stex/stex-terms.dtx index 3827466f14..500372bcb4 100644 --- a/macros/latex/contrib/stex/source/stex/stex-terms.dtx +++ b/macros/latex/contrib/stex/source/stex/stex-terms.dtx @@ -10,7 +10,7 @@ % TODO update copyright % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \begin{document} @@ -89,8 +89,8 @@ % with (downwards) argument precedence \meta{prec}. % \end{function} % -% \begin{function}{\STEXInternalTermMathAssocArgiiii} -% \begin{syntax} \cs{stex_term_arg:nnn}\meta{int}\meta{prec}\meta{notation}\meta{body} \end{syntax} +% \begin{function}{\STEXInternalTermMathAssocArgiiiii} +% \begin{syntax} \cs{stex_term_arg:nnn}\meta{int}\meta{prec}\meta{notation}\meta{type}\meta{body} \end{syntax} % Annotates \meta{body} as the \meta{int}th (associative) \emph{sequence} argument % (as comma-separated list of terms) of the current |OMA| or |OMBIND|, % with (downwards) argument precedence \meta{prec} and associative @@ -267,8 +267,10 @@ \def\comp{\_comp} \str_set:Nn \STEXInternalCurrentSymbolStr { #1 } \bool_set_false:N \l_stex_allow_semantic_bool - \_stex_term_oms:nnn {#1}{#1 \c_hash_str CUSTOM-}{ - \comp{ #2 } + \stex_mathml_intent:nn{#1}{ + \_stex_term_oms:nnn {#1}{#1 \c_hash_str CUSTOM-}{ + \comp{ #2 } + } } }{ \_stex_reset:N \comp @@ -382,6 +384,8 @@ } \prop_new:N \l_@@_custom_args_prop +\clist_new:N \l_stex_argnames_seq +\seq_new:N \l_@@_tmp_seq \cs_new_protected:Nn\_@@_custom_comp:n{\bool_set_false:N \l_stex_allow_semantic_bool\_comp{#1}\bool_set_true:N \l_stex_allow_semantic_bool} @@ -394,23 +398,47 @@ \prop_get:cnN { l_stex_symdecl_#1 _prop }{ args } \l_tmpa_str + \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq { + \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames} + } \prop_put:Nno \l_@@_custom_args_prop {args} \l_tmpa_str \tl_set:Nn \arg { \_@@_arg: } \str_if_empty:NTF \l_tmpa_str { - \_stex_term_oms:nnn {#1}{#1\c_hash_str CUSTOM-}{\ignorespaces#2} + \stex_mathml_intent:nn{#1}{ + \_stex_term_oms:nnn {#1}{#1\c_hash_str CUSTOM-}{\ignorespaces#2} + } }{ - \str_if_in:NnTF \l_tmpa_str b { - \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2} + \seq_clear:N \l_@@_tmp_seq + \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{ + \tl_set:Nx \l_@@_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}} + \bool_lazy_or:nnT{ + \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}} + }{ + \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}} + }{ + \tl_put_right:Nn \l_@@_tmp_tl + + } + \seq_put_right:No \l_@@_tmp_seq \l_@@_tmp_tl + } + \stex_mathml_intent:nn{ + #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }]( + \seq_use:Nn \l_@@_tmp_seq , + ) }{ - \str_if_in:NnTF \l_tmpa_str B { + \str_if_in:NnTF \l_tmpa_str b { \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2} }{ - \_stex_term_oma:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2} + \str_if_in:NnTF \l_tmpa_str B { + \_stex_term_ombind:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2} + }{ + \_stex_term_oma:nnn {#1}{#1\c_hash_str CUSTOM-\l_tmpa_str}{\ignorespaces#2} + } } } } % TODO check that all arguments exist }{ + \_stex_reset:N \l_stex_argnames_seq \_stex_reset:N \STEXInternalCurrentSymbolStr \_stex_reset:N \arg \_stex_reset:N \comp @@ -452,15 +480,21 @@ } } \exp_args:NNx \prop_put:Nnn \l_@@_custom_args_prop {\int_use:N \l_tmpa_int} {\ignorespaces#3} - \bool_set_true:N \l_stex_allow_semantic_bool - \IfBooleanTF#1{ - \stex_annotate_invisible:n { %TODO + \bool_if:NTF \l_stex_allow_semantic_bool \use_i:nn { + \bool_set_true:N \l_stex_allow_semantic_bool + \use:nn + } + { + \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq \l_tmpa_int}{ + \IfBooleanTF#1{ + \stex_annotate_invisible:n { %TODO + \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3} + } + }{ %TODO \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3} } - }{ %TODO - \exp_args:No \_stex_term_arg:nn {\l_tmpa_str\int_use:N \l_tmpa_int}{\ignorespaces#3} - } - \bool_set_false:N \l_stex_allow_semantic_bool + }} + {\bool_set_false:N \l_stex_allow_semantic_bool} } @@ -473,35 +507,37 @@ \cs_new_protected:Npn \STEXInternalTermMathArgiii #1#2#3 { \exp_args:Nnx \use:nn { \int_set:Nn \l_@@_downprec { #2 } + \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq \l_tmpa_int}{ \_stex_term_arg:nn { #1 }{ #3 } + } } { \int_set:Nn \exp_not:N \l_@@_downprec { \int_use:N \l_@@_downprec } } } % \end{macrocode} % \end{macro} % -% \begin{macro}{\STEXInternalTermMathAssocArgiiii} +% \begin{macro}{\STEXInternalTermMathAssocArgiiiii} % \begin{macrocode} -\cs_new_protected:Npn \STEXInternalTermMathAssocArgiiii #1#2#3#4 { +\cs_new_protected:Npn \STEXInternalTermMathAssocArgiiiii #1#2#3#4#5 { \cs_set:Npn \l_tmpa_cs ##1 ##2 { #4 } - \tl_set:Nn \l_tmpb_tl {\STEXInternalTermMathArgiii{#1}{#2}} + \tl_set:Nn \l_tmpb_tl {\STEXInternalTermMathArgiii{#5#1}{#2}} \tl_if_empty:nTF { #3 }{ - \STEXInternalTermMathArgiii{#1}{#2}{} + \STEXInternalTermMathArgiii{#5#1}{#2}{} }{ \exp_args:Nx \tl_if_empty:nTF { \tl_tail:n{ #3 }}{ \expandafter\if\expandafter\relax\noexpand#3 - \tl_set:Nn \l_tmpa_tl {\_@@_math_assoc_arg_maybe_sequence:Nn#3{#1}} + \tl_set:Nn \l_tmpa_tl {\_@@_math_assoc_arg_maybe_sequence:Nnn#3{#1}{#5}} \else - \tl_set:Nn \l_tmpa_tl {\_@@_math_assoc_arg_simple:nn{#1}{#3}} + \tl_set:Nn \l_tmpa_tl {\_@@_math_assoc_arg_simple:nnn{#1}{#3}{#5}} \fi \l_tmpa_tl }{ - \_@@_math_assoc_arg_simple:nn{#1}{#3} + \_@@_math_assoc_arg_simple:nnn{#1}{#3}{#5} } } } -\cs_new_protected:Nn \_@@_math_assoc_arg_maybe_sequence:Nn { +\cs_new_protected:Nn \_@@_math_assoc_arg_maybe_sequence:Nnn { \str_set:Nx \l_tmpa_str { \cs_argument_spec:N #1 } \str_if_empty:NTF \l_tmpa_str { \exp_args:Nx \cs_if_eq:NNTF { @@ -509,7 +545,7 @@ } \stex_invoke_sequence:n { \tl_set:Nx \l_tmpa_tl {\tl_tail:N #1} \str_set:Nx \l_tmpa_str {\exp_after:wN \use:n \l_tmpa_tl} - \tl_set:Nx \l_tmpa_tl {\prop_item:cn {stex_varseq_\l_tmpa_str _prop}{notation}} + \tl_set:Nx \l_tmpa_tl {\prop_item:cn {l_stex_symdecl_varseq://\l_tmpa_str _prop}{notation}} \exp_args:NNo \seq_set_from_clist:Nn \l_tmpa_seq \l_tmpa_tl \tl_set:Nx \l_tmpa_tl {{\exp_not:N \exp_not:n{ \exp_not:n{\exp_args:Nnx \use:nn} { @@ -525,7 +561,7 @@ } } }}} - \exp_args:Nno \use:nn {\seq_set_map:NNn \l_tmpa_seq \l_tmpa_seq} \l_tmpa_tl + \exp_args:Nno \use:n {\seq_set_map:NNn \l_tmpa_seq \l_tmpa_seq} \l_tmpa_tl \seq_reverse:N \l_tmpa_seq \seq_pop:NN \l_tmpa_seq \l_tmpa_tl \seq_map_inline:Nn \l_tmpa_seq { @@ -541,28 +577,38 @@ } \exp_args:No\l_tmpb_tl\l_tmpa_tl }{ - \_@@_math_assoc_arg_simple:nn{#2} { #1 } + \_@@_math_assoc_arg_simple:nnn{#2} { #1 }{#3} } } { - \_@@_math_assoc_arg_simple:nn{#2} { #1 } + \_@@_math_assoc_arg_simple:nnn{#2} { #1 }{#3} } } -\cs_new_protected:Nn \_@@_math_assoc_arg_simple:nn { +\cs_new_protected:Nn \_@@_math_assoc_arg_simple:nnn { \clist_set:Nn \l_tmpa_clist{ #2 } \int_compare:nNnTF { \clist_count:N \l_tmpa_clist } < 2 { - \tl_set:Nn \l_tmpa_tl { \_stex_term_arg:nn{A#1}{ #2 } } + \tl_set:Nn \l_tmpa_tl { + \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{ + \_stex_term_arg:nn{A#3#1}{ #2 } } + } }{ \clist_reverse:N \l_tmpa_clist \clist_pop:NN \l_tmpa_clist \l_tmpa_tl - \tl_set:Nx \l_tmpa_tl { \_stex_term_arg:nn{A#1}{ - \exp_args:No \exp_not:n \l_tmpa_tl + \tl_set:Nx \l_tmpa_tl { + \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{ + \_stex_term_arg:nn{A#3#1}{ + \exp_args:No \exp_not:n \l_tmpa_tl + } }} \clist_map_inline:Nn \l_tmpa_clist { \exp_args:NNNo \exp_args:NNo \tl_set:No \l_tmpa_tl { \exp_args:Nno - \l_tmpa_cs { \_stex_term_arg:nn{A#1}{##1} } \l_tmpa_tl + \l_tmpa_cs { + \stex_mathml_arg:nn{\seq_item:Nn \l_stex_argnames_seq #1}{ + \_stex_term_arg:nn{A#3#1}{##1} + } + } \l_tmpa_tl } } } @@ -679,7 +725,9 @@ \cs_new_protected:Npn \STEXInternalTermMathOMSiiii #1#2#3#4 { \_@@_maybe_brackets:nn { #3 }{ - \_stex_term_oms:nnn { #1 } { #1\c_hash_str#2 } { #4 } + \stex_mathml_intent:nn{#1} { + \_stex_term_oms:nnn { #1 } { #1\c_hash_str#2 } { #4 } + } } } % \end{macrocode} @@ -704,8 +752,35 @@ } \cs_new_protected:Npn \STEXInternalTermMathOMAiiii #1#2#3#4 { + \exp_args:Nnx \use:nn { + \seq_clear:N \l_@@_tmp_seq + \prop_if_exist:cT{l_stex_symdecl_#1 _prop}{ + \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq { + \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames} + } + \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{ + \tl_set:Nx \l_@@_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}} + \bool_lazy_or:nnT{ + \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}} + }{ + \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}} + }{ + \tl_put_right:Nn \l_@@_tmp_tl + + } + \seq_put_right:No \l_@@_tmp_seq \l_@@_tmp_tl + } + } \_@@_maybe_brackets:nn { #3 }{ - \_stex_term_oma:nnn { #1 } { #1\c_hash_str#2 } { #4 } + \stex_mathml_intent:nn{ + #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }]( + \seq_use:Nn \l_@@_tmp_seq , + ) + }{ + \_stex_term_oma:nnn { #1 } { #1\c_hash_str#2 } { #4 } + } + } + }{ + \_stex_reset:N \l_stex_argnames_seq } } % \end{macrocode} @@ -720,8 +795,35 @@ } \cs_new_protected:Npn \STEXInternalTermMathOMBiiii #1#2#3#4 { + \exp_args:Nnx \use:nn { + \seq_clear:N \l_@@_tmp_seq + \prop_if_exist:cT{l_stex_symdecl_#1 _prop}{ + \exp_args:NNx \seq_set_from_clist:Nn \l_stex_argnames_seq { + \prop_item:cn {l_stex_symdecl_#1 _prop}{argnames} + } + \exp_args:Nx\int_step_inline:nn{\prop_item:cn{l_stex_symdecl_#1 _prop}{arity}}{ + \tl_set:Nx \l_@@_tmp_tl {\seq_item:Nn \l_stex_argnames_seq {##1}} + \bool_lazy_or:nnT{ + \str_if_eq_p:nn{a}{\str_item:Nn\l_tmpa_str{##1}} + }{ + \str_if_eq_p:nn{B}{\str_item:Nn\l_tmpa_str{##1}} + }{ + \tl_put_right:Nn \l_@@_tmp_tl + + } + \seq_put_right:No \l_@@_tmp_seq \l_@@_tmp_tl + } + } \_@@_maybe_brackets:nn { #3 }{ - \_stex_term_ombind:nnn { #1 } { #1\c_hash_str#2 } { #4 } + \stex_mathml_intent:nn{ + #1[\prop_item:cn {l_stex_symdecl_#1 _prop}{ args }]( + \seq_use:Nn \l_@@_tmp_seq , + ) + }{ + \_stex_term_ombind:nnn { #1 } { #1\c_hash_str#2 } { #4 } + } + } + }{ + \_stex_reset:N \l_stex_argnames_seq } } % \end{macrocode} @@ -990,7 +1092,7 @@ \_stex_reset:N \STEXInternalCurrentSymbolStr } }{ - \int_compare:nNnTF {\prop_item:cn {l_stex_variable_#1_prop}{arity}} = 0{ + \int_compare:nNnTF {\prop_item:cn {l_stex_symdecl_var://#1_prop}{arity}} = 0{ \_@@_invoke_math_ii:n {#1} }{ \msg_error:nnxx{stex}{error/noop}{variable~#1}{} @@ -1024,7 +1126,7 @@ \prop_clear:N \l__stex_terms_custom_args_prop \prop_put:Nnn \l__stex_terms_custom_args_prop {currnum} {1} \prop_get:cnN { - l_stex_variable_#1 _prop + l_stex_symdecl_var://#1 _prop }{ args } \l_tmpa_str \prop_put:Nno \l__stex_terms_custom_args_prop {args} \l_tmpa_str \tl_set:Nn \arg { \__stex_terms_arg: } @@ -1063,7 +1165,7 @@ \exp_args:Nnx \use:nn { \def\comp{\_varcomp} \str_set:Nn \STEXInternalCurrentSymbolStr {varseq://#1} - \prop_item:cn{stex_varseq_#1_prop}{notation} + \prop_item:cn{l_stex_symdecl_varseq://#1_prop}{notation} }{ \_stex_reset:N \comp \_stex_reset:N \STEXInternalCurrentSymbolStr diff --git a/macros/latex/contrib/stex/tex/etc/beamernotesthemesTeX.sty b/macros/latex/contrib/stex/tex/etc/beamernotesthemesTeX.sty deleted file mode 100644 index af1c0c2a4c..0000000000 --- a/macros/latex/contrib/stex/tex/etc/beamernotesthemesTeX.sty +++ /dev/null @@ -1,14 +0,0 @@ -% Beamer sTeX notes theme; -% Copyright (c) 2022 Michael Kohlhase . -\ProvidesPackage{beamernotestheme-sTeX} -\typeout{Beamer sTeX notes theme} -\setbeamertemplate{theorem begin} -{% - \inserttheoremheadfont - \inserttheoremname - \inserttheoremnumber - \ifx \inserttheoremaddition \empty \else\ (\inserttheoremaddition)\fi - \inserttheorempunctuation\xspace - \inserttheorembodyfont -} -\setbeamertemplate{theorem end}{} diff --git a/macros/latex/contrib/stex/tex/etc/beamerthemesTeX.sty b/macros/latex/contrib/stex/tex/etc/beamerthemesTeX.sty index d7b861086a..85fd253eeb 100644 --- a/macros/latex/contrib/stex/tex/etc/beamerthemesTeX.sty +++ b/macros/latex/contrib/stex/tex/etc/beamerthemesTeX.sty @@ -1,25 +1,58 @@ % Beamer sTeX slide theme; % Copyright (c) 20 Michael Kohlhase . -\ProvidesPackage{beamertheme-sTeX} +\ProvidesPackage{beamerthemesTeX} \typeout{Beamer sTeX theme} \RequirePackage{xspace} +\RequirePackage{xcolor} +\RequirePackage{stex} -% General appearance of theorems, like "ams style", but without the block env. -\setbeamertemplate{theorem begin} -{% - \inserttheoremheadfont - \inserttheoremname - \inserttheoremnumber - \ifx \inserttheoremaddition \empty \else\ (\inserttheoremaddition)\fi - \inserttheorempunctuation\xspace - \inserttheorembodyfont +\ExplSyntaxOn +\protected\def\stexbeamerthm#1#2#3#4#5#6#7#8{ + \newcounter{#1} + \tl_if_empty:nF{#4}{ + \tl_set:cn{the#1}{ + \use:c{the#4}.\arabic{#1} + } + } + \tl_set:cn{#1autorefname}{#6} + + \newenvironment{#1}{ + \ifhmode\par\fi + + \tl_if_empty:nF{#5}{ + \setcounter{#1}{\value{#5}} + \stepcounter{#5} + } + \refstepcounter{#1} + \noindent#7{ + #6~\use:c{the#1} + \tl_if_empty:cF{s#2title}{ + {}~(\csname s#2title\endcsname) + }. + } + #8 + }{\par} + \csname stexpatch#2\endcsname[#3]{\begin{#1}}{\end{#1}} } -\setbeamertemplate{theorem end}{} +\ExplSyntaxOff + +\stexbeamerthm{theorem}{assertion}{theorem}{section}{}{Theorem}\textbf\itshape +\stexbeamerthm{observation}{assertion}{observation}{section}{theorem}{Observation}\textbf\itshape +\stexbeamerthm{corollary}{assertion}{corollary}{section}{theorem}{Corollary}\textbf\itshape +\stexbeamerthm{lemma}{assertion}{lemma}{section}{theorem}{Lemma}\textbf\itshape +\stexbeamerthm{axiom}{assertion}{axiom}{section}{theorem}{Axiom}\textbf\itshape +\stexbeamerthm{remark}{assertion}{remark}{section}{theorem}{Remark}\emph{} +\stexpatchparagraph[remark]{\begin{remark}}{\end{remark}} +\stexbeamerthm{example}{example}{}{section}{theorem}{Example}\textbf{} +\stexbeamerthm{definition}{definition}{}{section}{theorem}{Definition}\textbf{} + % THEME \mode +\sffamily + \ifcsname slidelogo\endcsname\else \newsavebox\slidelogo \sbox\slidelogo{\sTeX} @@ -64,3 +97,42 @@ \setlength\leftmarginii{1em} \setlength\leftmarginiii{1em} \providecommand{\vstretch}[1]{\vspace*{\stretch{#1}}} + +%% set the colors for sTeX content highlighting + +\def\compemph#1{\ifcsname textcolor\endcsname\textcolor{SteelBlue}{#1}\else#1\fi} +\def\symrefemph#1{\ifcsname textcolor\endcsname\textcolor{SteelBlue}{#1}\else#1\fi} +\def\defemph#1{\ifcsname textcolor\endcsname\textcolor{magenta}{#1}\else\textbf{#1}\fi} +\def\varemph#1{\ifcsname textcolor\endcsname\textcolor{gray}{#1}\else#1\fi} +\def\titleemph#1{\ifcsname textcolor\endcsname\textcolor{blue}{#1}\else\textbf{#1}\fi} + +%% set PDF tooltips +\RequirePackage{pdfcomment} +\protected\def\compemph@uri#1#2{% + \pdftooltip{% + \srefsymuri{#2}{\compemph{#1}}% + }{% + URI:~\detokenize{#2}% + }% +} +\protected\def\symrefemph@uri#1#2{% + \pdftooltip{% + \srefsymuri{#2}{\symrefemph{#1}}% + }{% + URI:~\detokenize{#2}% + }% +} +\protected\def\defemph@uri#1#2{% + \pdftooltip{% + \defemph{#1}% + }{% + URI:~\detokenize{#2}% + }% +} +\protected\def\varemph@uri#1#2{% + \pdftooltip{% + \varemph{#1}% + }{% + Variable~\detokenize{#2}% + }% +} \ No newline at end of file diff --git a/macros/latex/contrib/stex/tex/etc/stex-backend-pdflatex.cfg b/macros/latex/contrib/stex/tex/etc/stex-backend-pdflatex.cfg index bdd2810d09..484f930db6 100644 --- a/macros/latex/contrib/stex/tex/etc/stex-backend-pdflatex.cfg +++ b/macros/latex/contrib/stex/tex/etc/stex-backend-pdflatex.cfg @@ -1,6 +1,8 @@ \tl_const:Nx \c_stex_html_emptyarg_tl {~} \cs_new_protected:Nn \stex_annotate:nnn {#3} +\cs_new_protected:Nn \stex_mathml_intent:nn { #2 } +\cs_new_protected:Nn \stex_mathml_arg:nn { #2 } \cs_new_protected:Nn \stex_annotate_invisible:n {} \cs_new_protected:Nn \stex_annotate_invisible:nnn {} \NewDocumentEnvironment{stex_annotate_env} { m m } {}{} diff --git a/macros/latex/contrib/stex/tex/etc/stex-backend-rustex.cfg b/macros/latex/contrib/stex/tex/etc/stex-backend-rustex.cfg index 3f48631e40..c9ad36613b 100644 --- a/macros/latex/contrib/stex/tex/etc/stex-backend-rustex.cfg +++ b/macros/latex/contrib/stex/tex/etc/stex-backend-rustex.cfg @@ -20,6 +20,16 @@ } } } +\cs_new_protected:Nn \stex_mathml_intent:nn { + \rustex_annotate_HTML:nn { + mml:intent="#1" + }{ #2 } +} +\cs_new_protected:Nn \stex_mathml_arg:nn { + \rustex_annotate_HTML:nn { + mml:arg="#1" + }{ #2 } +} \cs_new_protected:Nn \stex_annotate_invisible:n { \_stex_html_checkempty:n { #1 } diff --git a/macros/latex/contrib/stex/tex/etc/stex-backend-tex4ht.cfg b/macros/latex/contrib/stex/tex/etc/stex-backend-tex4ht.cfg new file mode 100644 index 0000000000..b4c39b50b7 --- /dev/null +++ b/macros/latex/contrib/stex/tex/etc/stex-backend-tex4ht.cfg @@ -0,0 +1,13 @@ +% TODO +\tl_const:Nx \c_stex_html_emptyarg_tl {~} + +\cs_new_protected:Nn \stex_annotate:nnn {#3} % TODO +\cs_new_protected:Nn \stex_mathml_intent:nn { #2 } % TODO +\cs_new_protected:Nn \stex_mathml_arg:nn { #2 } % TODO +\cs_new_protected:Nn \stex_annotate_invisible:n {} % TODO +\cs_new_protected:Nn \stex_annotate_invisible:nnn {} % TODO +\NewDocumentEnvironment{stex_annotate_env} { m m } {}{} % TODO + +\prg_new_conditional:Nnn \stex_html_backend: {p, T, F, TF} { + \prg_return_true: +} \ No newline at end of file diff --git a/macros/latex/contrib/stex/tex/etc/stexthm.sty b/macros/latex/contrib/stex/tex/etc/stexthm.sty index 16931b514a..c81b6358df 100644 --- a/macros/latex/contrib/stex/tex/etc/stexthm.sty +++ b/macros/latex/contrib/stex/tex/etc/stexthm.sty @@ -4,51 +4,53 @@ \RequirePackage{amsthm} \RequirePackage{thmtools} +\ExplSyntaxOn + \declaretheorem[parent=section]{theorem} \stexpatchassertion[theorem] -{\ifx\sassertiontitle\@empty\begin{theorem}\else\begin{theorem}[\sassertiontitle]\fi} +{\ifx\sassertiontitle\@empty\begin{theorem}\else\exp_args:Nno\use:nn{\begin{theorem}[}\sassertiontitle]\fi} {\end{theorem}} \declaretheorem[sibling=theorem]{observation} \stexpatchassertion[observation] -{\ifx\sassertiontitle\@empty\begin{observation}\else\begin{observation}[\sassertiontitle]\fi} +{\ifx\sassertiontitle\@empty\begin{observation}\else\exp_args:Nno\use:nn{\begin{observation}[}\sassertiontitle]\fi} {\end{observation}} \declaretheorem[sibling=theorem]{corollary} \stexpatchassertion[corollary] -{\ifx\sassertiontitle\@empty\begin{corollary}\else\begin{corollary}[\sassertiontitle]\fi} +{\ifx\sassertiontitle\@empty\begin{corollary}\else\exp_args:Nno\use:nn{\begin{corollary}[}\sassertiontitle]\fi} {\end{corollary}} \declaretheorem[sibling=theorem]{lemma} \stexpatchassertion[lemma] -{\ifx\sassertiontitle\@empty\begin{lemma}\else\begin{lemma}[\sassertiontitle]\fi} +{\ifx\sassertiontitle\@empty\begin{lemma}\else\exp_args:Nno\use:nn{\begin{lemma}[}\sassertiontitle]\fi} {\end{lemma}} \declaretheorem[sibling=theorem]{axiom} \stexpatchassertion[axiom] -{\ifx\sassertiontitle\@empty\begin{axiom}\else\begin{axiom}[\sassertiontitle]\fi} +{\ifx\sassertiontitle\@empty\begin{axiom}\else\exp_args:Nno\use:nn{\begin{axiom}[}\sassertiontitle]\fi} {\end{axiom}} \declaretheorem[sibling=theorem,style=remark]{remark} \stexpatchassertion[remark] -{\ifx\sassertiontitle\@empty\begin{remark}\else\begin{remark}[\sassertiontitle]\fi} +{\ifx\sassertiontitle\@empty\begin{remark}\else\exp_args:Nno\use:nn{\begin{remark}[}\sassertiontitle]\fi} {\end{remark}} \stexpatchparagraph[remark] -{\ifx\sparagraphtitle\@empty\begin{remark}\else\begin{remark}[\sparagraphtitle]\fi} +{\ifx\sparagraphtitle\@empty\begin{remark}\else\exp_args:Nno\use:nn{\begin{remark}[}\sparagraphtitle]\fi} {\end{remark}} \declaretheorem[sibling=theorem,style=definition]{example} \stexpatchexample -{\ifx\sexampletitle\@empty\begin{example}\else\begin{example}[\sexampletitle]\fi} +{\ifx\sexampletitle\@empty\begin{example}\else\exp_args:Nno\use:nn{\begin{example}[}\sexampletitle]\fi} {\end{example}} \declaretheorem[sibling=theorem,style=definition]{definition} \stexpatchdefinition -{\ifx\sdefinitiontitle\@empty\begin{definition}\else\begin{definition}[\sdefinitiontitle]\fi} +{\ifx\sdefinitiontitle\@empty\begin{definition}\else\exp_args:Nno\use:nn{\begin{definition}[}\sdefinitiontitle]\fi} {\end{definition}} - -\RequirePackage{pdfcomment} +\ExplSyntaxOff + \RequirePackage{xcolor} \def\compemph#1{\ifcsname textcolor\endcsname\textcolor{blue}{#1}\else#1\fi} @@ -56,31 +58,32 @@ \def\defemph#1{\ifcsname textcolor\endcsname\textcolor{blue}{\textbf{#1}}\else\textbf{#1}\fi} \def\varemph#1{\ifcsname textcolor\endcsname\textcolor{gray}{#1}\else#1\fi} +\RequirePackage{pdfcomment} \protected\def\compemph@uri#1#2{% - \pdftooltip{% - \srefsymuri{#2}{\compemph{#1}}% - }{% - URI:~\detokenize{#2}% - }% + \pdftooltip{% + \srefsymuri{#2}{\compemph{#1}}% + }{% + URI:~\detokenize{#2}% + }% } \protected\def\symrefemph@uri#1#2{% - \pdftooltip{% - \srefsymuri{#2}{\symrefemph{#1}}% - }{% - URI:~\detokenize{#2}% - }% -} + \pdftooltip{% + \srefsymuri{#2}{\symrefemph{#1}}% + }{% + URI:~\detokenize{#2}% + }% + } \protected\def\defemph@uri#1#2{% - \pdftooltip{% - \defemph{#1}% - }{% - URI:~\detokenize{#2}% - }% + \pdftooltip{% + \defemph{#1}% + }{% + URI:~\detokenize{#2}% + }% } \protected\def\varemph@uri#1#2{% - \pdftooltip{% - \varemph{#1}% - }{% - Variable~\detokenize{#2}% - }% -} \ No newline at end of file + \pdftooltip{% + \varemph{#1}% + }{% + Variable~\detokenize{#2}% + }% +} diff --git a/macros/latex/contrib/stex/tex/ldf/problem-ngerman.ldf b/macros/latex/contrib/stex/tex/ldf/problem-ngerman.ldf index d53bed5591..6cadab0850 100644 --- a/macros/latex/contrib/stex/tex/ldf/problem-ngerman.ldf +++ b/macros/latex/contrib/stex/tex/ldf/problem-ngerman.ldf @@ -14,4 +14,6 @@ \def\prob@note@kw{Bewertung} \def\prob@pt@kw{Pkt} \def\prob@min@kw{Min} +\def\prob@correct@kw{Korrekt} +\def\prob@wrong@kw{Falsch} } diff --git a/macros/luatex/latex/luatruthtable/README.txt b/macros/luatex/latex/luatruthtable/README.txt new file mode 100644 index 0000000000..60217b2ce6 --- /dev/null +++ b/macros/luatex/latex/luatruthtable/README.txt @@ -0,0 +1,9 @@ +# Introduction +The luatruthtable package is developed to generate Truth Tables of boolean values in LaTeX. It provides an easy way for generating truth tables in LaTeX . There is no need of special environment in the package for generation of Truth Tables. It is written in lua and tex file is to be compiled with LuaLatex engine. The time required for operations is no issue while compiling with LuaLaTeX. There is no need to install lua on users system as tex distributions (TeXLive or MikTeX) come bundled with LuaLaTeX. It is useful for generation of Truth Tables in tex file itself. The package supports nesting of commands for multiple operations. It can be modified or extended by writing custom lua programs. + +# License +The luatruthtable package is released under the LaTeX Project Public License v1.3c or later. The complete license text is available at http://www.latex-project.org/lppl.txt. +It is developed in lua. Lua is certified open source software available. Its license is simple and liberal which is compatible with GPL. + +#Installation and Inclusion +The installation of luatruthtable package is similar to plain latex package where luatruthtable.sty file is in LaTeX directory of texmf tree. The package can be used by including the command \usepackage{luatruthtable} in the preamble of latex document.The tex file is to be compiled using the LuaLaTeX engine. \ No newline at end of file diff --git a/macros/luatex/latex/luatruthtable/luatruthtable.bib b/macros/luatex/latex/luatruthtable/luatruthtable.bib new file mode 100644 index 0000000000..81ee09ad4d --- /dev/null +++ b/macros/luatex/latex/luatruthtable/luatruthtable.bib @@ -0,0 +1,20 @@ + + + +@online{online.latextruthtable, + title = {Macro for automating truth tables in LaTeX}, + url = {https://tex.stackexchange.com/questions/505994}, + note = {visited on 2022-02-22} +} + + +@online{online.luacustomoperator, + title = {Lua Custom Operator}, + url = {http://lua-users.org/wiki/CustomOperators}, + note = {visited on 2022-02-22} +} + + + + + diff --git a/macros/luatex/latex/luatruthtable/luatruthtable.pdf b/macros/luatex/latex/luatruthtable/luatruthtable.pdf new file mode 100644 index 0000000000..3e8a60bf51 Binary files /dev/null and b/macros/luatex/latex/luatruthtable/luatruthtable.pdf differ diff --git a/macros/luatex/latex/luatruthtable/luatruthtable.sty b/macros/luatex/latex/luatruthtable/luatruthtable.sty new file mode 100644 index 0000000000..1b940c48c9 --- /dev/null +++ b/macros/luatex/latex/luatruthtable/luatruthtable.sty @@ -0,0 +1,286 @@ +% luaset package +% version 1.0 +% Licensed under LaTeX Project Public License v1.3c or later. The complete license text is available at http://www.latex-project.org/lppl.txt. +%Authors: Chetan Shirore and Dr. Ajit Kumar + +\ProvidesPackage{luatruthtable}[1.0] +\RequirePackage{xkeyval} +\RequirePackage{amsmath} +\RequirePackage{luacode} +\begin{luacode*} +local function toBinary(x,y) + y = y or math.max(1, select(2, math.frexp(x))) + local res = {} + for i = y, 1, -1 do + res[i] = math.fmod(x, 2) + x = math.floor((x - res[i]) / 2) + end + return res +end + +local function _not(a) + if a ==0 then return 1 + else return 0 end +end + +local lognot = {} + +local not_mt= { + __mul = function(a,b) + return _not(b) + + end +} + +setmetatable(lognot, not_mt) +_G.lognot = lognot + +local function _and(a, b) + if a == 1 and b == 1 then return 1 + else return 0 end +end + +local tmp1 = {} +local logand = {} + +local and_mt= { + __mul = function(a,b) + if b==logand then + tmp1[1]=a + return tmp1 + elseif a == tmp1 then + return _and(tmp1[1], b) + end + end +} + +setmetatable(tmp1, and_mt) +setmetatable(logand, and_mt) +_G.logand = logand + +local function _or(a, b) + if a == 0 and b == 0 then return 0 + else return 1 end +end + +local tmp2 = {} +local logor = {} + +local or_mt= { + __mul = function(a,b) + if b==logor then + tmp2[1]=a + return tmp2 + elseif a == tmp2 then + return _or(tmp2[1], b) + end + end +} + +setmetatable(tmp2, or_mt) +setmetatable(logor, or_mt) +_G.logor = logor + +local function _imp(a, b) + if a == 1 and b == 0 then return 0 + else return 1 end +end + +local tmp3 = {} +local imp = {} + +local imp_mt= { + __mul = function(a,b) + if b==imp then + tmp3[1]=a + return tmp3 + elseif a == tmp3 then + return _imp(tmp3[1], b) + end + end +} + +setmetatable(tmp3, imp_mt) +setmetatable(imp, imp_mt) +_G.imp = imp + +local function _iff(a, b) + if a == b then return 1 + else return 0 end +end + +local tmp4 = {} +local iff = {} + +local iff_mt= { + __mul = function(a,b) + if b==iff then + tmp4[1]=a + return tmp4 + elseif a == tmp4 then + return _iff(tmp4[1], b) + end + end +} + +setmetatable(tmp4, iff_mt) +setmetatable(iff, iff_mt) +_G.iff = iff + +local function _xor(a, b) + if a ~= b then return 1 + else return 0 end +end + +local tmp5 = {} +local logxor = {} + +local xor_mt= { + __mul = function(a,b) + if b==logxor then + tmp5[1]=a + return tmp5 + elseif a == tmp5 then + return _xor(tmp5[1], b) + end + end +} + +setmetatable(tmp5, xor_mt) +setmetatable(logxor, xor_mt) +_G.logxor = logxor + +local function _nand(a, b) + if a ==1 and b == 1 then return 0 + else return 1 end +end + +local tmp6 = {} +local lognand = {} + +local nand_mt= { + __mul = function(a,b) + if b==lognand then + tmp6[1]=a + return tmp6 + elseif a == tmp6 then + return _nand(tmp6[1], b) + end + end +} + +setmetatable(tmp6, nand_mt) +setmetatable(lognand, nand_mt) +_G.lognand = lognand + +local function _nor(a, b) + if a ==0 and b == 0 then return 1 + else return 0 end +end + +local tmp7 = {} +local lognor = {} + +local nor_mt= { + __mul = function(a,b) + if b==lognor then + tmp7[1]=a + return tmp7 + elseif a == tmp7 then + return _nor(tmp7[1], b) + end + end +} + +setmetatable(tmp7, nor_mt) +setmetatable(lognor, nor_mt) +_G.lognor = lognor + +local function _xnor(a, b) + if a == b then return 1 + else return 0 end +end + +local tmp8 = {} +local logxnor = {} + +local xnor_mt= { + __mul = function(a,b) + if b==logxnor then + tmp8[1]=a + return tmp8 + elseif a == tmp8 then + return _xnor(tmp8[1], b) + end + end +} + +setmetatable(tmp8, xnor_mt) +setmetatable(logxnor, xnor_mt) +_G.logxnor = logxnor + +function truthTable(str0,str,trtext,fltext) +local eval="" +local names={lognot=lognot,logand=logand,logor=logor, imp=imp, + iff=iff, logxor=logxor,lognand=lognand,lognor=lognor, logxnor=logxnor} +local vars={} +local expr={} +local countexp = 1 +local countvars =1 +local res="" +local sep=" & " +trtext = trtext or "$T$" +fltext = fltext or "$F$" +for variables in string.gmatch(str0, '([^,]+)') do + vars[countvars] = variables + countvars = countvars + 1 +end + +for subexp in string.gmatch(str, '([^,]+)') do + expr[countexp] = subexp + countexp = countexp + 1 +end + +local n =#vars +for i =1,2^n do + itr = toBinary(i,n) + + for j=1, #itr do + names[vars[j]] = itr[j] +end + + for k = 1, #expr do + res= res ..sep.. load("return " .. expr[k],nil,"t",names)() + end +if i~=2^n then +eval = eval .. table.concat(toBinary(i,n)," & ") .. res .."\\\\" +else +eval = eval .. table.concat(toBinary(i,n)," & ") .. res +end + res="" +end + +if trtext:gsub("%s+", "") =="0" or trtext:gsub("%s+", "") == "$0$" +or fltext:gsub("%s+", "") =="1" or fltext:gsub("%s+", "") == "$1$" +then +eval=eval +else +eval=eval:gsub(0,fltext):gsub(1,trtext) +end +return eval +end + +\end{luacode*} + +% ========= KEY DEFINITIONS ========= +\define@key{luatruthtable}{trtext}{\def\luatrtbl@trtext{#1}} +\define@key{luatruthtable}{fltext}{\def\luatrtbl@fltext{#1}} + +% ========= KEY DEFAULTS ========= +\setkeys{luatruthtable}{trtext=$T$,fltext=$F$}% +% ========= Defining Command ========= +\newcommand{\luaTruthTable}[3][]{% + \setkeys{luatruthtable}{#1} + \directlua{tex.sprint(truthTable(\luastringN{#2},\luastringN{#3},'\luatrtbl@trtext','\luatrtbl@fltext'))}} % + +\endinput diff --git a/macros/luatex/latex/luatruthtable/luatruthtable.tex b/macros/luatex/latex/luatruthtable/luatruthtable.tex new file mode 100644 index 0000000000..f50267f6f8 --- /dev/null +++ b/macros/luatex/latex/luatruthtable/luatruthtable.tex @@ -0,0 +1,358 @@ +\documentclass{article} +\usepackage{listings,color,parskip,booktabs,longtable,array, +hyperref,multirow,multicol,luatruthtable, enumitem} +\usepackage[top=1.1in, bottom=1.1in, left=1in, right=1in]{geometry} +\hypersetup{colorlinks,urlcolor=blue} +\lstset{frame=none, + language=[LaTeX]{TeX}, + aboveskip=3mm, + belowskip=3mm, + showstringspaces=false, + columns=flexible, + basicstyle={\ttfamily}, + numbers=none, + numberstyle=\tiny\color{gray}, + stringstyle=\color{mauve}, + breaklines=true, + breakatwhitespace=true, + tabsize=1 +} +\usepackage[backend=bibtex]{biblatex} +\addbibresource{luatruthtable} +\begin{document} +\title{luatruthtable Package} +\author{Chetan Shirore and Dr. Ajit Kumar} +\maketitle +\section{luatruthtable Package} +The \emph{luatruthtable} package is developed to generate Truth Tables of boolean values in LaTeX. It provides an easy way for generating truth tables in LaTeX . There is no need of special environment in the package for generation of Truth Tables. It is written in lua and tex file is to be compiled with LuaLatex engine. The time required for operations is no issue while compiling with LuaLaTeX. There is no need to install lua on users system as tex distributions (TeXLive or MikTeX) come bundled with LuaLaTeX. It is useful for generation of Truth Tables in tex file itself. The package supports nesting of commands for multiple operations. It can be modified or extended by writing custom lua programs. + +The progamming capabilities of Lua are effectively used in the development of pacakage. The other approaches of generating Truth Table in LaTeX get weired \cite{online.latextruthtable} and probably without using Lua it can't be done in an easier way in LaTeX. The \emph{xkeyval} package is used in its development apart from the \emph{luacode*} package. + +\section{License} The \emph{luatruthtable} package is released under the LaTeX Project Public License v1.3c or later. The complete license text is available at \url{http://www.latex-project.org/lppl.txt}. +It is developed in lua. Lua is certified open source software available. Its license is simple and liberal which is compatible with GPL. +\section{Installation and Inclusion} +The installation of \emph{luatruthtable} package is similar to plain latex package where \texttt{.sty} file is in \LaTeX directory of texmf tree. The package can be used by including the command \texttt{\textbackslash usepackage\{luatruthtable\}} in the preamble of latex document. The tex file is to be compiled using the LuaLaTeX engine. +\section{Core Ideas used in the development of the package} The function \verb|toBinary(x,y)| is used to produce sequence of \emph{True} and \emph{False} values of boolean variables. This function converts the decimal number \verb|x| to a binary number by adding \verb|y| number of leading zeroes. The result of this is stored in a table in Lua. Here \verb|y| corresponds to number of boolean variables. As \(2^y\) permutations of boolean variables are to be produced, the function \verb|toBinary(x,y)| runs inside a loop where \verb|x| takes values from \(1\) to \(y\). The splitting of variables and expressions is done using string methods available in Lua. The nested \emph{metamethods} in Lua are used to define several logical operators. The \emph{load} function in Lua is used to evaluate logical expressions. +\section{Command luaTruthTable in luatruthtable package} +The \verb|\luaTruthTable| command is the main command in the \emph{luatruthtable} package which generates truth tables. It has the following syntax. +\begin{lstlisting} +\luaTruthTable[trtext,fltext]{list of boolean / logical variables}{list of expressions} +\end{lstlisting} +The command has two mandatory arguments. \\ +i) \verb|list of boolean / logical variables| : The list of boolean or logical variables should be separated by comma. \\ +ii) \verb|list of expressions| : The list of logical expressions that are to be evaluated should be separated by comma. \\ +The command has two optional arguments. \\ +i) \verb|trtext| : The \verb|trtext| is the display value for the boolean value \emph{True}. It has the default value \verb|$T$| in the package. It can be any string or number. Assigning value \(0\) should be avoided to \verb|trtext| variable. \\ +ii) \verb|fltext| : The \verb|fltext| is the display value for the boolean value \emph{False}. It has the default value \verb|$F$| in the package. It can be any string or number. Assigning value \(1\) should be avoided to \verb|fltext| variable. + +The \verb|\luaTruthTable| command should be used within in the environment \verb|\begin{tabular} ... \end{tabular}| or any other environment in LaTeX for Tables. The sequence of column heads should be same as sequence of \verb|list of boolean / logical variables| and \verb|list of expressions|. Without these correct inputs, the command \verb|\luaTruthTable| can't produce the expected output. + +\section{Operations in luatruthtable package} +\begin{enumerate}[label=\alph*)] +\item \emph{not}: The value of \emph{ not p} is False when \(p\) is True and it is True when \(p\) is False. +\begin{center} +\begin{tabular}{|c|c|} +\hline +\(p\) & not \(p\) \\ +\hline +\luaTruthTable{p}{lognot*p} \\ +\hline +\end{tabular} +\end{center} + +The command \verb|lognot*| is used in the package to generate truth table for \emph{not} operation. +\item \emph{and}: The value of \emph{p AND q} is True if and only if both \(p\) and \(q\) are True. +\begin{center} +\begin{tabular}{|cc|c|} +\hline +\(p\) & \(q\) & \(p\) and \(q\) \\ +\hline +\luaTruthTable{p,q}{p*logand*q} \\ +\hline +\end{tabular} +\end{center} +The command \verb|*logand*| is used in the package to generate truth table for \emph{and} operation . +\item \emph{or}: The value of \emph{p or q} is False if and only if both \(p\) and \(q\) are False. +\begin{center} +\begin{tabular}{|cc|c|} +\hline +\(p\) & \(q\) & \(p\) or \(q\) \\ +\hline +\luaTruthTable{p,q}{p*logor*q} \\ +\hline +\end{tabular} +\end{center} +The command \verb|*logor*| is used in the package to generate truth table for \emph{or} operation. +\item \emph{implies}: The value of \emph{p implies q} is False if and only if \(p\) is True and \(q\) is False. +\begin{center} +\begin{tabular}{|cc|c|} +\hline +\(p\) & \(q\) & \(p\) implies \(q\) \\ +\hline +\luaTruthTable{p,q}{p*imp*q} \\ +\hline +\end{tabular} +\end{center} + +The command \verb|*imp*| is used in the package to generate truth table for \emph{implies} operation. +\item \emph{if and only if} : The value of \emph{p if and only if q} is True if and only if both \(p\) and \(q\) have same truth values. +\begin{center} +\begin{tabular}{|cc|c|} +\hline +\(p\) & \(q\) & \(p\) iff \(q\) \\ +\hline +\luaTruthTable{p,q}{p*iff*q} \\ +\hline +\end{tabular} +\end{center} + +The command \verb|*iff*| is used in the package to generate truth table for \emph{if and only if} operation. +\item \emph{NAND} : The value of \emph{p NAND q} is \(0\) if and only if both \(p\) and \(q\) have value \(1\). +\begin{center} +\begin{tabular}{|cc|c|} +\hline +\(p\) & \(q\) & \(p\) NAND \(q\) \\ +\hline +\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{p*lognand*q} \\ +\hline +\end{tabular} +\end{center} + +The command \verb|*lognand*| is used in the package to generate truth table for \emph{NAND} operation. +\item \emph{XOR} : The value of \emph{p XOR q} is \(0\) if and only if \(p\) and \(q\) have same values. +\begin{center} +\begin{tabular}{|cc|c|} +\hline +\(p\) & \(q\) & \(p\) XOR \(q\) \\ +\hline +\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{p*logxor*q} \\ +\hline +\end{tabular} +\end{center} + + +The command \verb|*logxor*| is used in the package to generate truth table for \emph{XOR} operation. +\item \emph{NOR}: The value of \emph{p NOR q} is \(1\) if and only if both \(p\) and \(q\) have value \(0\). +\begin{center} +\begin{tabular}{|cc|c|} +\hline +\(p\) & \(q\) & \(p\) NOR \(q\) \\ +\hline +\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{p*lognor*q} \\ +\hline +\end{tabular} +\end{center} + +The command \verb|*lognor*| is used in the package to generate truth table for \emph{NOR} operation. +\item \emph{XNOR}: The value of \emph{p XNOR q} is \(1\) if and only if both \(p\) and \(q\) have same values. +\begin{center} +\begin{tabular}{|cc|c|} +\hline +\(p\) & \(q\) & \(p\) XNOR \(q\) \\ +\hline +\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{p*logxnor*q} \\ +\hline +\end{tabular} +\end{center} + +The command \verb|*logxnor*| is used in the package to generate truth table for \emph{XNOR} operation. +\end{enumerate} +The following table summarises logical operators in the package. +\begin{center} +\begin{longtable}{llm{8cm}} +\toprule +\multicolumn{1}{c}{\textcolor{blue}{Operator}} & \multicolumn{1}{l}{\textcolor{blue}{Syntax}} & \multicolumn{1}{c}{\textcolor{blue}{Description}} \\ +\toprule +\begin{lstlisting} +lognot* +\end{lstlisting} & +\begin{lstlisting} +lognot*p +\end{lstlisting} & Negates the boolean variable \(p\)\\ +\midrule +\begin{lstlisting} +*logand* +\end{lstlisting} & +\begin{lstlisting} +p*logand*q +\end{lstlisting} & Gives the truth of the expression \emph{p and q} for boolean variables \(p\) and \(q\).\\ +\midrule +\begin{lstlisting} +*logor* +\end{lstlisting} & +\begin{lstlisting} +p*logor*q +\end{lstlisting} & Gives the truth of the expression \emph{p or q} for boolean variables \(p\) and \(q\).\\ +\midrule +\begin{lstlisting} +*imp* +\end{lstlisting} & +\begin{lstlisting} +p*imp*q +\end{lstlisting} & Gives the truth of the expression \emph{if p then q} for boolean variables \(p\) and \(q\).\\ +\midrule +\begin{lstlisting} +*iff* +\end{lstlisting} & +\begin{lstlisting} +p*iff*q +\end{lstlisting} & Gives the truth of the expression \emph{p if and only if q} for boolean variables \(p\) and \(q\).\\ +\midrule +\begin{lstlisting} +*lognand* +\end{lstlisting} & +\begin{lstlisting} +p*lognand*q +\end{lstlisting} & Gives the truth of the expression \emph{ p NAND q} for boolean variables \(p\) and \(q\).\\ +\midrule +\begin{lstlisting} +*logxor* +\end{lstlisting} & +\begin{lstlisting} +p*logxor*q +\end{lstlisting} & Gives the truth of the expression \emph{ p XOR q} for boolean variables \(p\) and \(q\).\\ +\midrule +\begin{lstlisting} +*lognor* +\end{lstlisting} & +\begin{lstlisting} +p*lognor*q +\end{lstlisting} & Gives the truth of the expression \emph{ p NOR q} for boolean variables \(p\) and \(q\).\\ +\midrule +\begin{lstlisting} +*logxnor* +\end{lstlisting} & +\begin{lstlisting} +p*logxnor*q +\end{lstlisting} & Gives the truth of the expression \emph{ p XNOR q} for boolean variables \(p\) and \(q\).\\ + +\bottomrule +\end{longtable} +\end{center} + +\section{Examples and Usage} The \emph{luatruthtable} package can accept finite number of variables. It supports finite number of variables that one would practically need. Few examples of usage are given here. +\begin{lstlisting} +\begin{tabular}{|cc|c|c|c|c|c|c|c|c|c|} +\hline +\(p\) & \(q\) & \(\neg p\) & \(p \land q\) & \(p\lor q\) & \(p \rightarrow q\) + & \(p \leftrightarrow q\) & \( p\) nand \(q\) & \(p\) xor \(q\) & \( p\) nor \(q\) & \(p\) xnor \(q\) \\ +\hline +\luaTruthTable{p,q}{lognot*p,p*logand*q, p*logor*q, p*imp*q, p*iff*q, +p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\ +\hline +\end{tabular} +\end{lstlisting} +With the packages \emph{luatruthtable},the above code outputs to +\ \\ \ \\ +\begin{tabular}{|cc|c|c|c|c|c|c|c|c|c|} +\hline +\(p\) & \(q\) & \(\neg p\) & \(p \land q\) & \(p\lor q\) & \(p \rightarrow q\) + & \(p \leftrightarrow q\) & \( p\) nand \(q\) & \(p\) xor \(q\) & \( p\) nor \(q\) & \(p\) xnor \(q\) \\ +\hline +\luaTruthTable{p,q}{lognot*p,p*logand*q, p*logor*q, p*imp*q, p*iff*q, +p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\ +\hline +\end{tabular} +\ \\ \\ +The following is the code generated by the command \verb|\luaTruthTable| in above code. + \begin{lstlisting} +$F$ & $T$ & $T$ & $F$ & $T$ & $T$ & $F$ & $T$ & $T$ & $F$ & $F$\\ +$T$ & $F$ & $F$ & $F$ & $T$ & $F$ & $F$ & $T$ & $T$ & $F$ & $F$\\ +$T$ & $T$ & $F$ & $T$ & $T$ & $T$ & $T$ & $F$ & $F$ & $F$ & $T$\\ +$F$ & $F$ & $T$ & $F$ & $F$ & $T$ & $T$ & $T$ & $F$ & $T$ & $T$ + \end{lstlisting} + The following example illustrates the use use of \emph{trtext} and \emph{fltext}. Here \(0\) is assigned to \emph{trtext} and \(1\) is assigned to \emph{fltext}. + \begin{lstlisting} + \begin{tabular}{|cc|c|c|c|c|c|c|c|c|c|} +\hline +\(p\) & \(q\) & \(\neg p\) & \(p \land q\) & \(p\lor q\) & \(p \rightarrow q\) + & \(p \leftrightarrow q\) & \( p\) nand \(q\) & \(p\) xor \(q\) & \( p\) nor \(q\) & \(p\) xnor \(q\) \\ +\hline +\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{lognot*p,p*logand*q, p*logor*q, p*imp*q, p*iff*q, +p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\ +\hline +\end{tabular} + \end{lstlisting} + + With the packages \emph{luatruthtable},the above code outputs to +\ \\ \ \\ + \begin{tabular}{|cc|c|c|c|c|c|c|c|c|c|} +\hline +\(p\) & \(q\) & \(\neg p\) & \(p \land q\) & \(p\lor q\) & \(p \rightarrow q\) + & \(p \leftrightarrow q\) & \( p\) nand \(q\) & \(p\) xor \(q\) & \( p\) nor \(q\) & \(p\) xnor \(q\) \\ +\hline +\luaTruthTable[trtext=$1$,fltext=$0$]{p,q}{lognot*p,p*logand*q, p*logor*q, p*imp*q, p*iff*q, +p*lognand*q, p*logxor*q, p*lognor*q, p*logxnor*q } \\ +\hline +\end{tabular} +\ \\ \\ +The following is the code generated by the command \verb|\luaTruthTable| in above code. +\begin{lstlisting} +$0$ & $1$ & $1$ & $0$ & $1$ & $1$ & $0$ & $1$ & $1$ & $0$ & $0$\\ +$1$ & $0$ & $0$ & $0$ & $1$ & $0$ & $0$ & $1$ & $1$ & $0$ & $0$\\ +$1$ & $1$ & $0$ & $1$ & $1$ & $1$ & $1$ & $0$ & $0$ & $0$ & $1$\\ +$0$ & $0$ & $1$ & $0$ & $0$ & $1$ & $1$ & $1$ & $0$ & $1$ & $1$ +\end{lstlisting} +The following example involves three variables. +\begin{lstlisting} +\begin{tabular}{|ccc|c|} +\hline +\(p\) & \(q\) & \(r\) & \((p \land q)\) \rightarrow \(\neg r\) \\ +\hline +\luaTruthTable{p,q,r}{(p*logand*q) *imp* (lognot*r)} \\ +\hline +\end{tabular} +\end{lstlisting} + With the packages \emph{luatruthtable},the above code outputs to +\ \\ \ \\ +\begin{tabular}{|ccc|c|} +\hline +\(p\) & \(q\) & \(r\) & \((p \land q)\) \rightarrow \(\neg r\) \\ +\hline +\luaTruthTable{p,q,r}{(p*logand*q) *imp* (lognot*r)} \\ +\hline +\end{tabular} +\ \\ \\ +Here \emph{lognot*r} should be enclosed in parenthesis in order to produce correct results in generated truth table. +\ \\ +The following is the code generated by the command \verb|\luaTruthTable| in above code. +\begin{lstlisting} +$F$ & $F$ & $T$ & $T$\\ +$F$ & $T$ & $F$ & $T$\\ +$F$ & $T$ & $T$ & $T$\\ +$T$ & $F$ & $F$ & $T$\\ +$T$ & $F$ & $T$ & $T$\\ +$T$ & $T$ & $F$ & $T$\\ +$T$ & $T$ & $T$ & $F$\\ +$F$ & $F$ & $F$ & $T$ +\end{lstlisting} +With the use of optional arguments \verb|[trtext=True, fltext=False]| in the previous example, one gets the following output. +\ \\ \ \\ \ \\ +\begin{tabular}{|ccc|c|} +\hline +\(p\) & \(q\) & \(r\) & \((p \land q)\) \rightarrow \(\neg r\) \\ +\hline +\luaTruthTable[trtext=True, fltext=False]{p,q,r}{(p*logand*q) *imp* (lognot*r)} \\ +\hline +\end{tabular} +\ \\ \\ + +It is possible to input \emph{trtext} and \emph{trfalse} in mathematics environment. So with the use of optional arguments \verb|[trtext=$True$, fltext=$False$]| in the previous example, one gets the following output. +\ \\ \ \\ \ \\ +\begin{tabular}{|ccc|c|} +\hline +\(p\) & \(q\) & \(r\) & \((p \land q)\) \rightarrow \(\neg r\) \\ +\hline +\luaTruthTable[trtext=$True$, fltext=$False$]{p,q,r}{(p*logand*q) *imp* (lognot*r)} \\ +\hline +\end{tabular} +\ \\ \ \\ \ \\ +Since \emph{luacode*} package is used, the backslash is to be escaped while assigning values to \emph{trtext} and \emph{trfalse}. For example \verb|[trtext=\\(True\\), fltext=\\(False\\)]| + + +\section{Known Issues,Limitations and Scope of the package} The associativity and precedence of operator is not yet supported. The package can give appropriate results only when parentheses are used for each of the operation. It gives eraneous result when parentheses are not used. This point is of utmost importance in using the package. These issues are there is no native way of defining custom operations in Lua \cite{online.luacustomoperator}. However some metamethods can be nested in a way to glimpse the operators. All operators defined in this package are instances of such nestings. The question may be raised that is there better way of accomplishing this in Lua. The answer to the point is that there are alternative ways of doing this. They may be better in some or other sense. For example, instead of defining \emph{*logand*} operator and using it in the fashion \emph{p*logand*q}, one could define function \emph{logand} that takes two arguments and use it in a way \emph{logand(p,q)}. But when it comes to embedding it in LaTeX, again one has to use more and more nested parentheses as number of statements and operations increase. This is the exact reason why such approach is not used in the development of package. Instead of using \emph{implies(logand(p,logor(q,r)),s)} it sounds more natural to use \emph{(p *logand* (q*logor*r) )*implies* s}. + +Apart from these issues, there is no error handling mechanism used in the package. It relies on the error handling of Lua and TeX itself. The package currently supports 9 operations viz. \emph{not,and,nand,or, xor, implies, iff, nor, xnor}. The error handling and extending number of operations may be considered in future versions of the package. + +\printbibliography +\end{document} diff --git a/macros/luatex/latex/piton/README.md b/macros/luatex/latex/piton/README.md new file mode 100644 index 0000000000..c9ad487bcc --- /dev/null +++ b/macros/luatex/latex/piton/README.md @@ -0,0 +1,26 @@ +# Readme for the package piton + +Author: F. Pantigny (`fpantigny@wanadoo.fr`). + +CTAN page: `https://ctan.org/pkg/piton` + +## License +The LaTeX extension `piton` is distributed under the LPPL 1.3 license. + +## Presentation + +The LaTeX package `piton` provides a command `\piton` and an environment `{Piton}` to typeset Python codes by using the Lua library LPEG. It requires the use of `lualatex`. It won't work with `xelatex` nor `pdflatex`. + + + +## Installation + + +For a manual installation: + +* put the files `piton.ins` and `piton.dtx` in the same directory; +* run `latex piton.ins` in that directory. + +The file `piton.sty` will be generated. + +The file `piton.sty` is *not* the only file necessary to use the extension `piton`. The file `piton.lua` is also required. You have to put both in the same directory as your document or (best) in a `texmf` tree. diff --git a/macros/luatex/latex/piton/piton-french.pdf b/macros/luatex/latex/piton/piton-french.pdf new file mode 100644 index 0000000000..ef7a5a1964 Binary files /dev/null and b/macros/luatex/latex/piton/piton-french.pdf differ diff --git a/macros/luatex/latex/piton/piton-french.tex b/macros/luatex/latex/piton/piton-french.tex new file mode 100644 index 0000000000..5e9ee11c7a --- /dev/null +++ b/macros/luatex/latex/piton/piton-french.tex @@ -0,0 +1,361 @@ +% -*- coding: utf-8 ; -*- +\documentclass[dvipsnames]{article} +\usepackage[french]{babel} +\frenchsetup{og = « , fg = »} + +\usepackage[escape-inside=$$]{piton} + +\usepackage{xcolor} + +\usepackage{geometry} +\geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}} + +\usepackage{enumitem} +\usepackage{verbatim} +\usepackage{amsmath} +\usepackage{tabularx} +\usepackage{booktabs} + +\usepackage{caption} +\captionsetup{labelfont = bf} + +% We use \MakeShortVerb of shortvrb and not \DefineShortVerb of fancyvrb +% because we don't want the contents of short verbatim colored in gray +\usepackage{shortvrb} +\MakeShortVerb{\|} + + +\skip\footins = 2\bigskipamount + +\usepackage{fancyvrb} +\fvset{commandchars=\~\#\@,formatcom=\color{gray}} +\def\emphase{\bgroup\color{RoyalPurple}\let\next=} + + +\usepackage{titlesec} +\titlespacing*{\section}{0pt}{6.5ex plus 1ex minus .2ex}{4.3ex plus .2ex} +\titlespacing*{\subsection}{0pt}{4.5ex plus 1ex minus .2ex}{2ex plus .2ex} + +\def\interitem{\vspace{7mm plus 2 mm minus 3mm}} + + +\usepackage{footnote} + +\usepackage[hyperfootnotes = false]{hyperref} + +\hypersetup + { + pdfinfo = + { + Title = L’extension piton , + Subject = Une extension LaTeX , + Author = F. Pantigny + } + } + + +\NewDocumentEnvironment {scope} {} {} {} + +\NewDocumentCommand {\pkg} {m} {\textsf{#1}} +\NewDocumentCommand {\cls} {m} {\textsf{#1}} + +\setlength{\parindent}{0pt} + + +\begin{document} + +\VerbatimFootnotes + + +\title{L'extension LaTeX \pkg{piton}\thanks{Ce document correspond à la +version~\myfileversion\space de \pkg{piton}, à la date du~\myfiledate.}} +\author{F. Pantigny \\ \texttt{fpantigny@wanadoo.fr}} + +\maketitle + +\begin{abstract} +L'extension \pkg{piton} propose des outils pour composer du code Python avec une coloration syntaxique +en utilisant la bibliothèque Lua LPEG. L'extension \pkg{piton} nécessite l'emploi de LuaLaTeX. +\end{abstract} + +\section{Présentation} + +L'extension \pkg{piton} utilise la librarie Lua nommée LPEG\footnote{LPEG est une librairie de capture de motifs + (\emph{pattern-matching} en anglais) pour Lua, écrite en C, fondée sur les PEG (\emph{parsing expression + grammars}): \url{http://www.inf.puc-rio.br/~roberto/lpeg/}} pour «parser» le code Python et le composer avec un +coloriage syntaxique. Comme elle utilise du code Lua, elle fonctionne uniquement avec |lualatex| (et ne va pas +fonctionner avec les autres moteurs de compilation LaTeX, que ce soit |latex|, |pdflatex| ou |xelatex|). Elle +n'utilise aucun programme extérieur et la compilation ne requiert donc pas |--shell-escape|. La compilation est +très rapide puisque tout le travail du parseur est fait par la librairie LPEG, écrite en C. + +\bigskip +Voici un exemple de code Python composé avec l'environnement |{Piton}| proposé par \pkg{piton}. + +\bigskip +\begin{Piton} +from math import pi + +def arctan(x,n=10): + """Compute the value of arctan(x) + n is the number of terms if the sum""" + if x < 0: + return -arctan(-x) # recursive call + elif x > 1: + return pi/2 - arctan(1/x) + ## (on a utilisé le fait que $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ pour $x>0$)\footnote{Cet échappement vers LaTeX a été obtenu en débutant par \ttfamily\#\#.} + else + s = 0 + for k in range(n): + s += (-1)**k/(2*k+1)*x**(2*k+1) + return s +\end{Piton} + + + +\section{Installation} + +L'extension \pkg{piton} est composée de deux fichiers : |piton.sty| et |piton.lua| (le fichier LaTeX |piton.sty| +chargé par |\usepackage| va à son tour charger le fichier |piton.lua|). Les deux fichiers doivent être présents +dans un répertoire où LaTeX pourra les trouver. Le mieux est de les installer dans une arborescence |texmf|. + + +\section{Utilisation de l'extension} + +Pour utiliser l'extension \pkg{piton}, l'utilisateur final a seulement à charger l'extension dans son document avec +la commande classique |\usepackage| et se souvenir que la compilation doit être faite avec LuaLaTeX. + +\medskip +L'extension \pkg{piton} fournit trois outils pour composer du code Python: la commande |\piton|, l'environnement +|{Piton}| et la commande |\PitonInputFile|. + +\begin{itemize} +\item La commande |\piton| doit être utilisée pour composer de petits éléments de code à l'intérieur d'un +paragraphe. \emph{Attention} : Cette fonction prend son argument en mode \emph{verbatim} (comme la commande +\verb|\verb|) et, de ce fait, cette fonction ne peut pas être utilisée à l'intérieur d'un argument d'une autre +fonction (on peut néanmoins l'utiliser à l'intérieur d'un environnement). + +\item L'environnement |{Piton}| doit être utilisé pour composer des codes de plusieurs lignes. + +\item La commande |\PitonInputFile| doit être utilisée pour insérer et composer un fichier extérieur. +\end{itemize} + +\bigskip +Il est possible de composer des commentaires en LaTeX en commençant par |##| (c'est un échappement vers LaTeX). Les +caractères |##| eux-mêmes ne seront pas imprimés. + + +\section{Personnalisation} + +\subsection{La commande \textbackslash PitonOptions} + +La commande |\PitonOptions| propose quatre clés : |gobble|, |auto-gobble|, |line-numbers| et |all-line-numbers|. + +\begin{itemize} +\item La clé |gobble| peut comme valeur un entier positif $n$ : les $n$ premiers caractères de chaque ligne sont +alors retirés (avant formatage du code) dans les environnements |{Piton}|. + +\item Quand la clé |auto-gobble| est activée, l'extension \pkg{piton} détermine la valeur minimale $n$ du nombre +d'espaces successifs débutant chaque ligne (non vide) de l'environnment |{Piton}| et applique |gobble| avec cette +valeur de~$n$. + +\item Avec la clé |line-numbers|, les lignes \emph{non vides} sont numérotées dans les environnements \verb|{Piton}| +et dans les listings produits par la commande |\PitonInputFile|. + +\item Avec la clé |all-line-numbers|, \emph{toutes} les lignes sont numérotées, y compris les lignes vides. +\end{itemize} + +\bigskip + +\begingroup +\fvset{commandchars=\~\&\@,formatcom=\small\color{gray}} +\begin{Verbatim} +~emphase&\PitonOptions{line-numbers,auto-gobble}@ +\begin{Piton} + from math import pi + + def arctan(x,n=10): + """Compute the value of arctan(x) + n is the number of terms if the sum""" + if x < 0: + return -arctan(-x) # recursive call + elif x > 1: + return pi/2 - arctan(1/x) + ## (on a utilisé le fait que $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ pour $x>0$) + else + s = 0 + for k in range(n): + s += (-1)**k/(2*k+1)*x**(2*k+1) + return s +\end{Piton} +\end{Verbatim} +\endgroup + +\begingroup +\PitonOptions{line-numbers,auto-gobble} +\begin{Piton} + from math import pi + + def arctan(x,n=10): + """Compute the value of arctan(x) + n is the number of terms if the sum""" + if x < 0: + return -arctan(-x) # recursive call + elif x > 1: + return pi/2 - arctan(1/x) + ## (on a utilisé le fait que $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ pour $x>0$) + else + s = 0 + for k in range(n): + s += (-1)**k/(2*k+1)*x**(2*k+1) + return s +\end{Piton} +\endgroup + +\subsection{L'option escape-inside} + +L'option |escape-inside| doit être utilisée au chargement de \pkg{piton} (c'est-à-dire dans l'instruction +|\usepackage|). Pour des raisons techniques, elle ne peut pas être fixée dans |\PitonOptions|. Elle prend comme +valeur deux caractères qui seront utilisés pour délimiter des parties qui seront composées en LaTeX. + + +\bigskip +Dans l'exemple suivant, on suppose que l'extension \pkg{piton} a été chargée de la manière suivante : + +\smallskip +\begin{Verbatim} +\usepackage[~emphase#escape-inside=$$@]{piton} +\end{Verbatim} + +\medskip +Dans le code suivant, qui est une programmation récursive de la factorielle, on décide de surligner en jaune +l'instruction qui contient l'appel récursif. +\begin{Verbatim} +\begin{Piton} +def fact(n): + if n==0: + return 1 + else: + ~emphase#$\colorbox{yellow!50}{$@return n*fact(n-1)~emphase#$}$@ +\end{Piton} +\end{Verbatim} + +\begin{Piton} +def fact(n): + if n==0: + return 1 + else: + $\colorbox{yellow!50}{$return n*fact(n-1)$}$ +\end{Piton} + +\bigskip +\emph{Attention} : L'échappement vers LaTeX permis par les caractères de |escape-inside| n'est pas actif dans les +chaînes de caractères ni dans les commentaires (pour avoir un commentaire entièrement en échappement vers LaTeX, +il suffit de le faire débuter par |##|). + +\subsection{Les styles} + +L'extension \pkg{piton} fournit la commande |\SetPitonStyle| pour personnaliser les différents styles utilisés pour +formater les éléments syntaxiques des listings Python. Ces personnalisations ont une portée qui correspond au +groupe TeX courant. + +\bigskip +La commande |\SetPitonStyle| prend en argument une liste de couples \textsl{clé=valeur}. Les clés sont les noms des +styles et les valeurs sont les instructions LaTeX de formatage correspondantes. + +\bigskip +Ces instructions LaTeX doivent être des instructions de formatage du type de |\color{...}|, |\bseries|, +|\slshape|, etc. (les commandes de ce type sont parfois qualifiées de \emph{semi-globales}). Il est aussi possible +de mettre, \emph{à la fin de la liste d'instructions}, une commande LaTeX prenant exactement un +argument. + +\bigskip +Voici un exemple qui change le style utilisé pour le nom d'une fonction Python, au moment de sa définition +(c'est-à-dire après le mot-clé |def|). + +\begin{Verbatim} +\SetPitonStyle + { Name.Function = \bfseries \setlength{\fboxsep}{1pt}\colorbox{yellow!50} } +\end{Verbatim} + +Dans cet exemple, |\colorbox{yellow!50}| doit être considéré comme le nom d'une fonction LaTeX qui prend exactement +un argument, puisque, habituellement, elle est utilisée avec la syntaxe |\colorbox{yellow!50}{text}|. + +\medskip +\begingroup +\SetPitonStyle + { Name.Function = \bfseries \setlength{\fboxsep}{1pt}\colorbox{yellow!50} } +Avec ce réglage, on obtient : \piton{def cube(x) : return x * x * x } +\endgroup + + + +\medskip +Les différents styles sont décrits dans la table \ref{Semantic}. + +\begin{table}[htb] +\centering +\caption{Usage des différents styles} +\label{Semantic} +\begin{tabularx}{0.9\textwidth}{@{}>{\ttfamily}l>{\raggedright\arraybackslash}X@{}} +\toprule +\normalfont Style & Usage \\ +\midrule +Number & les nombres \\ +String.Short & les chaînes de caractères courtes (entre \texttt{'} ou \texttt{"}) \\ +String.Long & les chaînes de caractères longues (entre \texttt{'''} ou \texttt{"""}) sauf les chaînes de + documentation \\ +String & cette clé fixe à la fois |String.Short| et |String.Long| \\ +String.Doc & les chaînes de documentation \\ +String.Interpol & les éléments syntaxiques des champs des f-strings (c'est-à-dire les caractères \texttt{\{}, \texttt{\}} et \texttt{:}) \\ +Operator & les opérateurs suivants : \texttt{!= == << >> - \~{} + / * \% = < > \& .} \verb+|+ \verb|@| \\ +Operator.Word & les opérateurs suivants : |in|, |is|, |and|, |or| et |not| \\ +Name.Builtin & la plupart des fonctions prédéfinies par Python \\ +Name.Function & le nom des fonctions définies par l'utilisateur \emph{au moment de leur définition}, c'est-à-dire + après le mot-clé \verb|def| \\ +Name.Decorator & les décorateurs (instructions débutant par \verb|@| dans les classes) \\ +Name.Namespace & le nom des modules (= bibliothèques extérieures) \\ +Name.Class & le nom des classes au moment de leur définition \\ +Exception & le nom des exceptions prédéfinies (eg: SyntaxError) \\ +Comment & les commentaires commençant par \texttt{\#} \\ +Comment.LaTeX & les commentaires commençant par \texttt{\#\#} qui sont composés en LaTeX par \pkg{piton} + (\texttt{\#\#} est une séquence d'échappement vers LaTeX) \\ +Keyword.Constant & |True|, |False| et |None| \\ +Keyword & les mots-clés suivants : + \ttfamily assert, break, case, continue, del, + elif, else, except, exec, finally, for, from, + global, if, import, lambda, non local, + pass, raise, return, try, while, + with, yield, yield from.\\ + \bottomrule +\end{tabularx} +\end{table} + + + +\subsection{Définition de nouveaux environnements} + +Comme l'environnement |{Piton}| a besoin d'absorber son contenu d'une manière spéciale (à peu près comme du texte +verbatim), il n'est pas possible de définir de nouveaux environnements directement au-dessus de l'environnement +|{Piton}|. + +C'est pourquoi \pkg{piton} propose une commande |\NewPitonEnvironment|. Cette commande a la même syntaxe que la +commande classique |\NewDocumentEnvironment|. + +\bigskip +Par exemple, avec l'instruction suivante, un nouvel environnement |{Python}| sera défini avec le même comportement +que l'environnement |{Piton}|: + +\verb|\NewPitonEnvironment{Python}{}{}{}| + +\bigskip +Si on souhaite un environnement |{Python}| qui compose le code inclus dans une boîte de \pkg{tcolorbox}, on peut +écrire: + +\begin{verbatim} +\NewPitonEnvironment{Python}{} + {\begin{tcolorbox}} + {\end{tcolorbox}} +\end{verbatim} + + +\end{document} \ No newline at end of file diff --git a/macros/luatex/latex/piton/piton.dtx b/macros/luatex/latex/piton/piton.dtx new file mode 100644 index 0000000000..48e6f777e5 --- /dev/null +++ b/macros/luatex/latex/piton/piton.dtx @@ -0,0 +1,810 @@ +% \iffalse meta-comment +% +% Copyright (C) 2022 by F. Pantigny +% ----------------------------------- +% +% This file may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in: +% +% http://www.latex-project.org/lppl.txt +% +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% \fi +% \iffalse +\def\myfileversion{0.6} +\def\myfiledate{2022/09/14} +% +% +%<*batchfile> +\begingroup +\input l3docstrip.tex +\keepsilent +\usedir{tex/latex/cascade} +\preamble + +Copyright (C) 2022 by F. Pantigny +----------------------------------- + +This file may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3 +of this license or (at your option) any later version. +The latest version of this license is in: + +http://www.latex-project.org/lppl.txt + +and version 1.3 or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +\endpreamble +\askforoverwritefalse +\endgroup +% +% +%<@@=piton> +%<*driver> +\documentclass{l3doc} +\usepackage{geometry} +\geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}} +\usepackage{fontspec} +\usepackage[dvipsnames]{xcolor} +\usepackage{caption,tabularx} +\def\emphase{\bgroup\color{RoyalPurple}\let\next=} +\fvset{commandchars=\~\#\@,formatcom=\color{gray}} +\captionsetup{labelfont = bf} +\usepackage{ragged2e} +\usepackage[escape-inside=$$]{piton} % $$ + +\def\interitem{\vskip 7mm plus 2 mm minus 3mm} +\parindent 0pt +\skip\footins = 2\bigskipamount + +\begin{filecontents}[noheader,overwrite]{example1.txt} +from math import pi + +def arctan(x,n=10): + """Compute the value of arctan(x) + n is the number of terms if the sum""" + if x < 0: + return -arctan(-x) # recursive call + elif x > 1: + return pi/2 - arctan(1/x) + ## (we have used that $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ for $x>0$)\footnote{This LaTeX escape has been done by beginning the comment by \ttfamily\#\#} + else + s = 0 + for k in range(n): + s += (-1)**k/(2*k+1)*x**(2*k+1) + return s +\end{filecontents} + +\begin{filecontents}[noheader,overwrite]{example2.txt} +def fact(n): + if n==0: + return 1 + else: + $\colorbox{yellow!50}{$return n*fact(n-1)$}$ +\end{filecontents} + + +\EnableCrossrefs + +\begin{document} +\DocInput{piton.dtx} +\end{document} +% + +% \fi +% \title{The package \pkg{piton}\thanks{This document corresponds to the +% version~\myfileversion\space of \pkg{piton}, at the date of~\myfiledate.}} +% \author{F. Pantigny \\ \texttt{fpantigny@wanadoo.fr}} +% +% \maketitle +% +% \begin{abstract} +% The package \pkg{piton} provides tools to typeset Python listings with +% syntactic highlighting by using the Lua library LPEG. It requires LuaLaTeX. +% \end{abstract} +% +% +% \section{Presentation} +% +% +% The package \pkg{piton} uses the Lua library LPEG\footnote{LPEG is a +% pattern-matching library for Lua, written in C, based on \emph{parsing +% expression grammars}: \url{http://www.inf.puc-rio.br/~roberto/lpeg/}} for +% parsing Python listings and typeset them with syntactic highlighting. Since it +% uses Lua code, it works with |lualatex| only (and won't work with the other +% engines: |latex|, |pdflatex| and |xelatex|). It does not use external program +% and the compilation does not require |--shell-escape|. The compilation is very +% fast since all the parsing is done by the library LPEG, written in C. +% +% \bigskip +% Here is an exemple of code typeset by \pkg{piton}, with the environment |{Piton}|. +% +% \bigskip +% \PitonInputFile{Example1.txt} +% +% +% \section{Installation} +% +% The package \pkg{piton} is contained in two files: |piton.sty| and +% |piton.lua| (the LaTeX file |piton.sty| loaded by |\usepackage| will load the +% Lua file |piton.lua|). Both files must be in a repertory where LaTeX will be +% able to find them. The best way is to install them in a |texmf| tree. +% +% +% \section{Use of the package} +% +% In order to use the package \pkg{piton}, one has only to load the package in +% its document with the standard command |\usepackage| and remember that the +% compilation must be done with |lualatex| (and no other LaTeX engine). +% +% \medskip +% The package \pkg{piton} provides three tools to typeset Python code: the +% command |\piton|, the environment |{Piton}| and the command |\PitonInputFile|. +% +% \begin{itemize} +% \item The command |\piton| should be used to typeset small pieces of code +% inside a paragraph. \emph{Caution}: That fonction takes in its argument +% \emph{verbatim}. Therefore, it cannot be used in the argument of another +% command (however, it can be used within an environment). +% \item The environment |{Piton}| should be used to typeset multi-lines code. +% +% \item The command |\PitonInputFile| is used to insert and typeset a whole +% external file. +% \end{itemize} +% +% \bigskip +% It's possible to compose comments in LaTeX by beginning with |##| (it's a +% ``LaTeX escape''). The characters |##| themselves won't be printed. +% +% \section{Customization} +% +% \subsection{The command \textbackslash PitonOptions} +% +% The command |\PitonOptions| provides four keys: |gobble|, |auto-gobble|, +% |line-numbers| and |all-line-numbers|. +% +% \begin{itemize} +% \item The key |gobble| takes in as value a positive integer~$n$: the first $n$ +% characters are discarded (before the process of hightlighning of the code) for +% each line of the environment |{Piton}|. +% +% \item Then the key |auto-gobble| is in force, the extnsion \pkg{piton} compute +% the minimal value $n$ of the number of consecutives space beginning each (non +% empty) line of the environment |{Piton}| and applies |gobble| with that value +% of~$n$. +% +% \item With the key |line-numbers|, the \emph{non empty} lines are numbered in +% the environments |{Piton}| and in the listings resulting from the use of +% |\PitonInputFile|. +% +% \item With the key |all-line-numbers|, \emph{all} the lines are numbered, +% including the empty ones. +% \end{itemize} +% +% \bigskip +% +% \begingroup +% \fvset{commandchars=\~\&\@,formatcom=\small\color{gray}} +% \begin{Verbatim} +% ~emphase&\PitonOptions{line-numbers,auto-gobble}@ +% \begin{Piton} +% from math import pi +% +% def arctan(x,n=10): +% """Compute the value of arctan(x) +% n is the number of terms if the sum""" +% if x < 0: +% return -arctan(-x) # recursive call +% elif x > 1: +% return pi/2 - arctan(1/x) +% ## (on a utilisé le fait que $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ pour $x>0$) +% else +% s = 0 +% for k in range(n): +% s += (-1)**k/(2*k+1)*x**(2*k+1) +% return s +% \end{Piton} +% \end{Verbatim} +% \endgroup +% +% +% \begingroup +% \PitonOptions{line-numbers,auto-gobble} +% \PitonInputFile{Example1.txt} +% \endgroup +% +% \subsection{The option escape-inside} +% +% The option |escape-inside| must be used when loading the package \pkg{piton} +% (that is to say in the instruction |\usepackage|). For technical reasons, it +% can't be used in the command |\PitonOptions|. That option takes in as value +% two characters which will be used to delimit pieces of code which will +% composed in LaTeX. +% +% \medskip +% In the following example, we assume that the extension \pkg{piton} has been +% loaded by the following instruction. +% +% \begin{Verbatim} +% \usepackage[~emphase#escape-inside=$$@]{piton} +% \end{Verbatim} +% +% \medskip +% In the following code, which is a recursive programmation of the mathematical +% factorial, we decide to highlight in yellow the instruction which contains the +% recursive call. +% \begin{Verbatim} +% \begin{Piton} +% def fact(n): +% if n==0: +% return 1 +% else: +% ~emphase#$\colorbox{yellow!50}{$@return n*fact(n-1)~emphase#$}$@ +% \end{Piton} +% \end{Verbatim} +% +% \PitonInputFile{Example2.txt} +% +% \bigskip +% +% \emph{Caution} : The escape to LaTeX allowed by the characters of +% |escape-inside| is not active in the strings nor in the Python comments +% (however, it's possible to have a whole Python comment composed in LaTeX by +% beginning it with |##|). +% +% +% \subsection{The styles} +% +% The package \pkg{piton} provides the command |\SetPitonStyle| to customize the +% different styles used to format the syntactic elements of the Python listings. +% The customizations done by that command are limited to the current TeX group. +% +% \bigskip +% The command |\SetPitonStyle| takes in as argument a comma-separated list of +% \textsl{key=value} pairs. The keys are names of styles and the value are LaTeX +% formatting instructions. +% +% \bigskip +% These LaTeX instructions must be formatting instructions such as +% |\color{...}|, |\bfseries|, |\slshape|, etc. (the commands of this kind are +% sometimes called \emph{semi-global} commands). It's also possible to put, +% \emph{at the end of the list of instructions}, a LaTeX command taking exactly +% one argument. +% +% \bigskip +% Here an example which changes the style used to highlight, in the definition +% of a Python function, the name of the function which is defined. +% +% \begin{verbatim} +% \SetPitonStyle +% { Name.Function = \bfseries \setlength{\fboxsep}{1pt}\colorbox{yellow!50} } +% \end{verbatim} +% +% In that example, |\colorbox{yellow!50}| must be considered as the name of a +% LaTeX command which takes in exactly one argument, since, usually, it is used +% with the syntax |\colorbox{yellow!50}{text}|. +% +% \medskip +% \begingroup +% \SetPitonStyle +% { Name.Function = \bfseries \setlength{\fboxsep}{1pt}\colorbox{yellow!50} } +% With that setting, we will have : \piton{def cube(x) : return x * x * x } +% \endgroup +% +% \medskip +% The different styles are described in the table \ref{Semantic}. +% +% +% +% \begin{table}[b] +% \centering +% \caption{Usage of the different styles} +% \label{Semantic} +% \begin{tabular}{@{}>{\ttfamily}l>{\RaggedRight\arraybackslash}p{9cm}@{}} +% \toprule +% \normalfont Style & Usage \\ +% \midrule +% Number & the numbers \\ +% String.Short & the short strings (between \texttt{'} or \verb|"|) \\ +% String.Long & the long strings (between \texttt{'''} or \verb|"""|) except the +% documentation strings \\ +% String & that keys sets both |String.Short| and |String.Long| \\ +% String.Doc & the documentation strings \\ +% String.Interpol & the syntactic elements of the fields of the f-strings (that +% is to say the characters \texttt{\{}, \texttt{\}} and \texttt{:}) \\ +% Operator & the following operators : \texttt{!= == << >> - \~{} + / * \% = < > \& .} \verb+|+ \verb|@|\\ +% Operator.Word & the following operators : \texttt{in}, \texttt{is}, +% \texttt{and}, \texttt{or} et \texttt{not} \\ +% Name.Builtin & the predefined functions of Python \\ +% Name.Function & the name of the functions defined by the user, at the point of +% their definition (that is to say after the keyword |def|) \\ +% Name.Decorator & the decorators (instructions beginning by \verb|@| in the classes) \\ +% Name.Namespace & the name of the modules (= external libraries) \\ +% Name.Class & the name of the classes at the point of their definition \\ +% Exception & the names of the exceptions (eg: \texttt{SyntaxError}) \\ +% Comment & the comments beginning with \verb|#| \\ +% LaTeX & the comments beginning by \verb|##| which are composed in LaTeX by +% \pkg{piton} (\verb|##| is an espace sequence to LaTeX) \\ +% Keyword.Constant & |True|, |False| and |None| \\ +% Keyword & the following keywords : +% \ttfamily assert, break, case, continue, del, +% elif, else, except, exec, finally, for, from, +% global, if, import, lambda, non local, +% pass, raise, return, try, while, +% with, yield, yield from.\\ +% \bottomrule +% \end{tabular} +% \end{table} +% +% +% +% +% \subsection{Creation of new environments} +% +% Since the environment |{Piton}| has to catch its body in a special way (more +% or less as verbatim text), it's not possible to construct new environments +% directly over the environment |{Piton}| +% +% That's why \pkg{piton} provides a command |\NewPitonEnvironment|. That +% command takes in three mandatory arguments. + +% That command has the same syntax as the classical environment +% |\NewDocumentEnvironment|. +% +% \bigskip +% With the following instruction, a new environment |{Python}| will be +% constructed with the same behaviour as |{Piton}|: +% +% \verb|\NewPitonEnvironment{Python}{}{}{}| +% +% \bigskip +% If on wished to format Python code in a box in a box of \pkg{tcolorbox}, it's +% possible to define an environment |{Python}| with the following code: +% +%\begin{verbatim} +% \NewPitonEnvironment{Python}{} +% {\begin{tcolorbox}} +% {\end{tcolorbox}} +% \end{verbatim} +% +% +% \clearpage +% +% \section{Implementation} +% +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e} +\RequirePackage{l3keys2e} +\ProvidesExplPackage + {piton} + {\myfiledate} + {\myfileversion} + {Highlight Python codes with LPEG on LuaLaTeX} +% \end{macrocode} +% +% \bigskip +% We define a set of keys |piton/package| for these options. +% \begin{macrocode} +\keys_define:nn { piton / package } + { + escape-inside .tl_set:N = \c_@@_escape_inside_tl , + unknown .code:n = \msg_error:nn { piton } { unknown~key~for~package } + } +% \end{macrocode} +% +% \begin{macrocode} +\msg_new:nnn { piton } { unknown~key~for~package } + { + Unknown~key\\ + You~have~used~the~key~'\l_keys_key_str'~but~the~only~key~available~here~ + is~the~key~'escape-inside'.\\ + That~key~will~be~ignored. + } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\tl_clear_new:N \c_@@_escape_inside_tl +% \end{macrocode} +% +% We process the options when the package is loaded (with |\usepackage|). +% \begin{macrocode} +\ProcessKeysOptions { piton / package } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\begingroup +\cs_new_protected:Npn \@@_set_escape_char:nn #1 #2 + { + \directlua { begin_escape = "#1" } + \directlua { end_escape = "#2" } + } +\cs_generate_variant:Nn \@@_set_escape_char:nn { x x } +\@@_set_escape_char:xx + { \tl_head:V \c_@@_escape_inside_tl } + { \tl_tail:V \c_@@_escape_inside_tl } +\endgroup +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\msg_new:nnn { piton } { LuaLaTeX~mandatory } + { The~package~'piton'~must~be~used~with~LuaLaTeX.\\ It~won't~be~loaded. } +\sys_if_engine_luatex:F { \msg_critical:nn { piton } { LuaLaTeX~mandatory } } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\RequirePackage { luatexbase } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\msg_new:nnn { piton } { piton.lua~not~found } + { + The~file~'piton.lua'~can't~be~found.\\ + The package~'piton'~won't be loaded. + } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\file_if_exist:nF { piton.lua } + { \msg_critical:nn { piton } { piton.lua~not~found} } +% \end{macrocode} +% +% \begin{macrocode} +\lua_now:e { require("piton.lua") } +% \end{macrocode} +% +% \bigskip +% The following function has not a name with the conventions of L3 because it +% will be used in the Lua code. +% \begin{macrocode} +\cs_new:Npn \pitonEOL + { + \par \leavevmode + \@@_print_number: + } +% \end{macrocode} +% +% \medskip +% \begin{macrocode} +\cs_new_protected:Npn \@@_print_number: + { \bool_if:NT \l_@@_line_numbers_bool \@@_actually_print_number: } +% \end{macrocode} +% +% \medskip +% \begin{macrocode} +\cs_new_protected:Npn \@@_actually_print_number: + { +% \end{macrocode} +% The empty lines in the code are not numbered. +% \begin{macrocode} + \bool_if:NF \l_@@_all_line_numbers_bool + { \peek_meaning:NF \pitonEOL } + \@@_actually_print_number_i: + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_actually_print_number_i: + { + \int_incr:N \l_@@_lineno_int + \hbox_overlap_left:n + { + { \color{gray} \footnotesize \int_to_arabic:n \l_@@_lineno_int } + \quad + } + } +% \end{macrocode} +% +% \bigskip +% The following counter will be used to count the lines in the code when the +% user requires the numbers of the lines to be printed. +% \begin{macrocode} +\int_new:N \l_@@_lineno_int +% \end{macrocode} +% +% \bigskip +% The following integer is the number of characters to gobble on the left side +% of the Python listings. Of course, the initial value is $0$. +% \begin{macrocode} +\int_new:N \l_@@_gobble_int +% \end{macrocode} +% +% +% \bigskip +% \begin{macrocode} +\cs_new_protected:Npn \@@_define_trim_syntax:n #1 + { \lua_now:n { define_trim_syntax(#1) } } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\NewDocumentCommand { \piton } { v } + { + \group_begin: + \ttfamily + \lua_now:e { Parse(token.scan_argument()) } { #1 } + \group_end: + } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\NewDocumentCommand { \PitonInputFile } { m } + { + \group_begin: + \ttfamily + \bool_if:NT \l_@@_line_numbers_bool + { + \@@_actually_print_number: + \vspace{-\baselineskip} + } + \lua_now:e { ParseFile(token.scan_argument()) } { #1 } + \group_end: + } +% \end{macrocode} +% +% \subsection{PitonOptions} +% +% \begin{macrocode} +\bool_new:N \l_@@_line_numbers_bool +\bool_new:N \l_@@_all_line_numbers_bool +% \end{macrocode} +% +% \begin{macrocode} +\keys_define:nn { piton / PitonOptions } + { + gobble .int_set:N = \l_@@_gobble_int , + gobble .value_required:n = true , + auto-gobble .code:n = \int_set:Nn \l_@@_gobble_int { -1 } , + auto-gobble .value_forbidden:n = true , + line-numbers .bool_set:N = \l_@@_line_numbers_bool , + line-numbers .default:n = true , + all-line-numbers .code:n = + \bool_set_true:N \l_@@_line_numbers_bool + \bool_set_true:N \l_@@_all_line_numbers_bool , + all-line-numbers .value_forbidden:n = true + } +% \end{macrocode} +% +% \bigskip +% The argument of |\PitonOptions| is provided by currification. +% \begin{macrocode} +\NewDocumentCommand \PitonOptions { } + { \keys_set:nn { piton / PitonOptions } } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\NewDocumentCommand { \NewPitonEnvironment } { m m m m } + { +% \end{macrocode} +% We construct a TeX macro which will catch as its argument all the tokens +% until \textsl{\texttt{newline}} + |\end{Piton}| with, in that +% \textsl{\texttt{newline}}| + \end{Piton}|, the catcode of +% \textsl{\texttt{newline}}, |\|, |{| and |}| equal to 12 (``\texttt{other}''). +% The latter explains why the definition of that function is a bit complicated. +% \begin{macrocode} + \use:x + { + \cs_set_protected:Npn + \use:c { __piton_collect_ #1 :w } + ####1 + \c_backslash_str end \c_left_brace_str #1 \c_right_brace_str + } + { + \group_end: + \par \addvspace { 0.5 em } + { + \dim_set_eq:NN \parindent \c_zero_dim + \ttfamily + \bool_if:NT \l_@@_line_numbers_bool + { + \@@_actually_print_number: + \vspace{-\baselineskip} + } + \int_case:nnF \l_@@_gobble_int + { + 0 +% \end{macrocode} +% Be careful: the last argument is provided by currification. +% \begin{macrocode} + { \lua_now:e { Parse(token.scan_argument()) } } + { -1 } + { \lua_now:e { AutoGobbleParse(token.scan_argument()) } } + } + { + \exp_args:NV \@@_define_trim_syntax:n \l_@@_gobble_int + \lua_now:e { GobbleParse(token.scan_argument()) } + } + { ##1 } + } + \par \addvspace { 0.5 em } +% \end{macrocode} +% The following |\end{#1}| is only for the groups and the stack of +% environments of LaTeX. +% \begin{macrocode} + \end { #1 } + } +% \end{macrocode} +% +% +% \bigskip +% We can now define the new environment by defining the two TeX macros +% characteristic to the LaTeX environment. +% \begin{macrocode} + \NewDocumentEnvironment { #1 } { #2 } + { + #3 + \group_begin: + \tl_map_function:nN + { \ \\ \{ \} \$ \& \# \^ \_ \% \~ \^^M } + \char_set_catcode_other:N + \use:c { __piton_collect_ #1 :w } + } + { #4 } + } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\NewPitonEnvironment { Piton } { } { } { } +% \end{macrocode} +% +% \bigskip +% +% \begin{macrocode} +\NewDocumentCommand { \PitonStyle } { m } { \csname pitonStyle#1\endcsname } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\NewDocumentCommand { \SetPitonStyle } { } { \keys_set:nn { piton } } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_math_scantokens:n #1 + { \normalfont \scantextokens { $#1$ } } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\keys_define:nn { piton } + { + String.Interpol .tl_set:c = pitonStyle String.Interpol , + String.Interpol .value_required:n = true , + FormattingType .tl_set:c = pitonStyle FormattingType , + FormattingType .value_required:n = true , + Dict.Value .tl_set:c = pitonStyle Dict.Value , + Dict.Value .value_required:n = true , + Name.Decorator .tl_set:c = pitonStyle Name.Decorator , + Name.Decorator .value_required:n = true , + Name.Function .tl_set:c = pitonStyle Name.Function , + Name.Function .value_required:n = true , + Keyword .tl_set:c = pitonStyle Keyword , + Keyword .value_required:n = true , + Keyword.Constant .tl_set:c = pitonStyle Keyword.Constant , + Keyword.constant .value_required:n = true , + String.Doc .tl_set:c = pitonStyle String.Doc , + String.Doc .value_required:n = true , + Interpol.Inside .tl_set:c = pitonStyle Interpol.Inside , + Interpol.Inside .value_required:n = true , + String.Long .tl_set:c = pitonStyle String.Long , + String.Long .value_required:n = true , + String.Short .tl_set:c = pitonStyle String.Short , + String.Short .value_required:n = true , + String .meta:n = { String.Long = #1 , String.Short = #1 } , + Comment.Math .tl_set:c = pitonStyle Comment.Math , + Comment.Math .default:n = \@@_math_scantokens:n , + Comment.Math .initial:n = , + Comment .tl_set:c = pitonStyle Comment , + Comment .value_required:n = true , + InitialValues .tl_set:c = pitonStyle InitialValues , + InitialValues .value_required:n = true , + Number .tl_set:c = pitonStyle Number , + Number .value_required:n = true , + Name.Namespace .tl_set:c = pitonStyle Name.Namespace , + Name.Namespace .value_required:n = true , + Name.Class .tl_set:c = pitonStyle Name.Class , + Name.Class .value_required:n = true , + Name.Builtin .tl_set:c = pitonStyle Name.Builtin , + Name.Builtin .value_required:n = true , + Name.Type .tl_set:c = pitonStyle Name.Type , + Name.Type .value_required:n = true , + Operator .tl_set:c = pitonStyle Operator , + Operator .value_required:n = true , + Operator.Word .tl_set:c = pitonStyle Operator.Word , + Operator.Word .value_required:n = true , + Post.Function .tl_set:c = pitonStyle Post.Function , + Post.Function .value_required:n = true , + Exception .tl_set:c = pitonStyle Exception , + Exception .value_required:n = true , + Comment.LaTeX .tl_set:c = pitonStyle Comment.LaTeX , + Comment.LaTeX .value_required:n = true , + unknown .code:n = \msg_error:nn { piton }{ Unknown~key~for~SetPitonStyle } + } +% \end{macrocode} +% +% +% \bigskip +% \begin{macrocode} +\msg_new:nnn { piton } { Unknown~key~for~SetPitonStyle } { + The~style~'\l_keys_key_str'~is~unknown.\\ + This~key~will~be~ignored.\\ + The~available~styles~are~(in~alphabetic~order):~ + Comment,~ + Comment.LaTeX,~ + Dict.Value,~ + Exception,~ + InitialValues,~ + Keyword,~ + Keyword.Constant,~ + Name.Builtin,~ + Name.Class,~ + Name.Decorator,~ + Name.Function,~ + Name.Namespace,~ + Number,~ + Operator,~ + Operator.Word,~ + String,~ + String.Doc,~ + String.Long,~ + String.Short,~and~ + String.Interpol. } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\SetPitonStyle + { + Comment = \color[HTML]{0099FF} \itshape , + Exception = \color[HTML]{CC0000} , + Keyword = \color[HTML]{006699} \bfseries , + Keyword.Constant = \color[HTML]{006699} \bfseries , + Name.Builtin = \color[HTML]{336666} , + Name.Decorator = \color[HTML]{9999FF}, + Name.Class = \color[HTML]{00AA88} \bfseries , + Name.Function = \color[HTML]{CC00FF} , + Name.Namespace = \color[HTML]{00CCFF} , + Number = \color[HTML]{FF6600} , + Operator = \color[HTML]{555555} , + Operator.Word = \bfseries , + String = \color[HTML]{CC3300} , + String.Doc = \color[HTML]{CC3300} \itshape , + String.Interpol = \color[HTML]{AA0000} , + Comment.LaTeX = \normalfont \color[rgb]{.468,.532,.6} , + Name.Type = \color[HTML]{336666} , + InitialValues = \piton , + Dict.Value = \piton , + Post.Function = \piton , + Interpol.Inside = \color{black}\piton , + } +% \end{macrocode} +% +% +% \vspace{1cm} +% \tableofcontents +% \end{document} +% +% Local Variables: +% TeX-fold-mode: t +% TeX-fold-preserve-comments: nil +% flyspell-mode: nil +% fill-column: 80 +% End: + + + + + + diff --git a/macros/luatex/latex/piton/piton.ins b/macros/luatex/latex/piton/piton.ins new file mode 100644 index 0000000000..04c653960d --- /dev/null +++ b/macros/luatex/latex/piton/piton.ins @@ -0,0 +1,47 @@ +%% +%% Copyright (C) 2022 by F. Pantigny +%% +%% +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +\input l3docstrip.tex +\keepsilent +\usedir{tex/latex/cascade} +\preamble + +Copyright (C) 2022 by F. Pantigny + +This file may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either +version 1.3 of this license or (at your option) any later +version. The latest version of this license is in: + + http://www.latex-project.org/lppl.txt + +and version 1.3 or later is part of all distributions of +LaTeX version 2005/12/01 or later. + +\endpreamble +\generate{\file{piton.sty}{\from{piton.dtx}{package}}} +\Msg{*********************************************************} +\Msg{*} +\Msg{* To finish the installation you have to move the} +\Msg{* following files into a directory searched by TeX:} +\Msg{*} +\Msg{* \space\space piton.sty\space\space and\space\space piton.lua} +\Msg{*} +\Msg{* To produce the documentation run the file piton.dtx} +\Msg{* through LuaLaTeX.} +\Msg{*} +\Msg{* Happy TeXing!} +\Msg{*********************************************************} +\endbatchfile + diff --git a/macros/luatex/latex/piton/piton.lua b/macros/luatex/latex/piton/piton.lua new file mode 100644 index 0000000000..8ef48f45b1 --- /dev/null +++ b/macros/luatex/latex/piton/piton.lua @@ -0,0 +1,473 @@ +-- -*- coding: utf-8 ; -*- +-- +-- This is file 'piton.lua' which is a part of the Latex package 'piton' +-- Copyright (C) 2022 by F. Pantigny + +-- This file may be distributed and/or modified under the +-- conditions of the Latex Project Public License, either +-- version 1.3 of this license or (at your option) any later +-- version. The latest version of this license is in: +-- +-- http://www.Latex-project.org/lppl.txt +-- +-- and version 1.3 or later is part of all distributions of +-- Latex version 2005/12/01 or later. + + +-- This file is part of the version 0.55 of the package 'piton' + +local P, S, V , C , Ct, Cc, Cf = lpeg.P, lpeg.S, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cc, lpeg.Cf + + +--[[ By convention, a capture which provides as value a table (and not a string), provides, in fact, +a string (the first element of the table) which is a formatting LaTeX instruction (it will be +thrown back to TeX with normal catcodes (ant not ``other'' catcode for everybody).]] + +local function L(string) + return lpeg.Cc ( { string } ) +end + +local function K(pattern, style) + return + L ( "{\\PitonStyle{" .. style .. "}{" ) + * lpeg.C(pattern) + * L ( "}}" ) +end + + +--[[ The text in "escape" (between begin_escape and end_escape) is captured +and put in a table (with only one component). Indeed, we have decided that a capture +which is encapsulated in a table must be transmitted to TeX with the normal TeX catcodes.]] + +local Escape = P(begin_escape) + * Ct ( C ( ( 1 - P(end_escape) ) ^ 1 ) ) + * P(end_escape) + +local EOL = ( P "\r" ) * L ( "\\pitonEOL" ) + + + +lpeg.locale(lpeg) -- mandatory + +local alpha , digit , space , punct = lpeg.alpha , lpeg.digit , lpeg.space , lpeg.punct + +local letter = alpha + S"âàçéèêëïîôûüÂÀÇÉÈÊËÏÎÔÛÜ_" + +local alphanum = letter + digit + +local identifier = letter * alphanum ^ 0 + +local Identifier = C ( identifier ) + +local Space = C ( ( space - P "\r" ) ^ 1 ) + +local SkipSpace = C ( ( space - P "\r" ) ^ 0 ) + +local Punct = C ( punct ) + + +local Number = + K ( + ( digit^1 * P "." * digit^0 + digit^0 * P "." * digit^1 + digit^1 ) + * ( S "eE" * S "+-" ^ -1 * digit^1 ) ^ -1 + + digit^1 + , 'Number' ) + +local Word = C ( ( ( 1 - space ) - S "'\"\r[()]" - digit ) ^ 1 ) + +local Delim = C ( S "[()]" ) + + +local Keyword = + K ( P "assert" + P "break" + P "case" + P "continue" + P "del" + + P "elif" + P "else" + P "except" + P "exec" + P "finally" + P "for" + P "from" + + P "global" + P "if" + P "import" + P "lambda" + P "non local" + + P "pass" + P "return" + P "try" + P "while" + + P "with" + P "yield" + P "yield from" , + 'Keyword' ) + + K ( P "True" + P "False" + P "None" , 'Keyword.Constant' ) + + +local Builtin = + K ( P "__import__" + P "abs" + P "all" + P "any" + P "bin" + P "bool" + P "bytearray" + + P "bytes" + P "chr" + P "classmethod" + P "compile" + P "complex" + P "delattr" + + P "dict" + P "dir" + P "divmod" + P "enumerate" + P "eval" + P "filter" + + P "float" + P "format" + P "frozenset" + P "getattr" + P "globals" + P "hasattr" + + P "hash" + P "hex" + P "id" + P "input" + P "int" + P "isinstance" + P "issubclass" + + P "iter" + P "len" + P "list" + P "locals" + P "map" + P "max" + P "memoryview" + P "min" + + P "next" + P "object" + P "oct" + P "open" + P "ord" + P "pow" + P "print" + P "property" + + P "range" + P "repr" + P "reversed" + P "round" + P "set" + P "setattr" + P "slice" + + P "sorted" + P "staticmethod" + P "str" + P "sum" + P "super" + P "tuple" + P "type" + + P "vars" + P "zip" , + 'Name.Builtin' ) + + +local Exception = + K ( "ArithmeticError" + P "AssertionError" + P "AttributeError" + + P "BaseException" + P "BufferError" + P "BytesWarning" + P "DeprecationWarning" + + P "EOFError" + P "EnvironmentError" + P "Exception" + P "FloatingPointError" + + P "FutureWarning" + P "GeneratorExit" + P "IOError" + P "ImportError" + + P "ImportWarning" + P "IndentationError" + P "IndexError" + P "KeyError" + + P "KeyboardInterrupt" + P "LookupError" + P "MemoryError" + P "NameError" + + P "NotImplementedError" + P "OSError" + P "OverflowError" + + P "PendingDeprecationWarning" + P "ReferenceError" + P "ResourceWarning" + + P "RuntimeError" + P "RuntimeWarning" + P "StopIteration" + + P "SyntaxError" + P "SyntaxWarning" + P "SystemError" + P "SystemExit" + + P "TabError" + P "TypeError" + P "UnboundLocalError" + P "UnicodeDecodeError" + + P "UnicodeEncodeError" + P "UnicodeError" + P "UnicodeTranslateError" + + P "UnicodeWarning" + P "UserWarning" + P "ValueError" + P "VMSError" + + P "Warning" + P "WindowsError" + P "ZeroDivisionError" + + P "BlockingIOError" + P "ChildProcessError" + P "ConnectionError" + + P "BrokenPipeError" + P "ConnectionAbortedError" + P "ConnectionRefusedError" + + P "ConnectionResetError" + P "FileExistsError" + P "FileNotFoundError" + + P "InterruptedError" + P "IsADirectoryError" + P "NotADirectoryError" + + P "PermissionError" + P "ProcessLookupError" + P "TimeoutError" + + P "StopAsyncIteration" + P "ModuleNotFoundError" + P "RecursionError" , + 'Exception' ) + +local RaiseException = K ( P "raise" , 'Keyword' ) * SkipSpace * Exception * C ( P "(" ) + +local ExceptionInConsole = Exception * C ( ( 1 - P "\r" ) ^ 0 ) * EOL + + +local Namespace = + K ( P "from" , 'Keyword' ) * Space * K ( alphanum^1 , 'Name.Namespace' ) + * ( Space * K ( P "import" , 'Keyword' ) ) ^ -1 + + +local ImportAs = K ( P "import" , 'Keyword' ) + * Space + * K ( identifier , 'Name.Namespace' ) + * ( SkipSpace * C ( P "," ) * SkipSpace * K ( identifier , 'Name.Namespace' ) ) ^ 0 + * ( + Space * K ( P "as" , 'Keyword' ) * Space * K ( identifier , 'Name.Namespace' ) + ) ^ 0 + +local Class = K ( P "class" , 'Keyword' ) * Space * K ( identifier , 'Name.Class' ) + +local Decorator = K ( P "@" * letter^1 , 'Name.Decorator' ) + +local SingleShortInterpol = + K ( P "{" , 'String.Interpol') + * K ( ( 1 - S "}':" ) ^ 0 , 'Interpol.Inside' ) + * C ( P ":" * (1 - S "}:'") ^ 0 ) ^ -1 + * K ( P "}" , 'String.Interpol' ) + +local DoubleShortInterpol = + K ( P "{" , 'String.Interpol' ) + * K ( ( 1 - S "}\":" ) ^ 0 , 'Interpol.Inside' ) + * ( K ( P ":" , 'String.Interpol' ) * C ( (1 - S "}:\"") ^ 0 ) ) ^ -1 + * K ( P "}" , 'String.Interpol' ) + +local SingleLongInterpol = + K ( P "{" , 'String.Interpol' ) + * K ( ( 1 - S "}:\r" - P "'''" ) ^ 0 , 'Interpol.Inside' ) + * C ( P ":" * (1 - S "}:\r" - P "'''" ) ^ 0 ) ^ -1 + * K ( P "}" , 'String.Interpol' ) + +local DoubleLongInterpol = + K ( P "{" , 'String.Interpol' ) + * K ( ( 1 - S "}:\r" - P "\"\"\"" ) ^ 0 , 'Interpol.Inside' ) + * C ( P ":" * (1 - S "}:\r" - P "\"\"\"" ) ^ 0 ) ^ -1 + * K ( P "}" , 'String.Interpol' ) + +local SingleShortPureString = C ( ( P "\\'" + P "{{" + P "}}" + 1 - S "{}'" ) ^ 1 ) + +local DoubleShortPureString = C ( ( P "\\\"" + P "{{" + P "}}" + 1 - S "{}\"" ) ^ 1 ) + +local SingleLongPureString = C ( ( 1 - P "'''" - S "{}'\r" ) ^ 1 ) + +local DoubleLongPureString = C ( ( 1 - P "\"\"\"" - S "{}\"\r" ) ^ 1 ) + +local SingleShortString = + L ( "{\\PitonStyle{String.Short}{" ) + * ( + C ( P "f'" + P "F'" ) + * ( SingleShortInterpol + SingleShortPureString ) ^ 0 + * C ( P "'" ) + + + C ( ( P "'" + P "r'" + P "R'" ) * ( P "\\'" + 1 - S "'\r" ) ^ 0 * P "'" ) + ) + * L ( "}}" ) + +local DoubleShortString = + L ( "{\\PitonStyle{String.Short}{" ) + * ( + C ( P "f\"" + P "F\"" ) + * ( DoubleShortInterpol + DoubleShortPureString ) ^ 0 + * C ( P "\"" ) + + + C ( ( P "\"" + P "r\"" + P "R\"" ) * ( P "\\\"" + 1 - S "\"\r" ) ^ 0 * P "\"" ) + ) + * L ( "}}" ) + + +local ShortString = SingleShortString + DoubleShortString + + +local SingleLongString = + L "{\\PitonStyle{String.Long}{" + * ( + C ( S "fF" * P "'''" ) + * ( SingleLongInterpol + SingleLongPureString ) ^ 0 + * L "}}" + * ( + EOL + + + L "{\\PitonStyle{String.Long}{" + * ( SingleLongInterpol + SingleLongPureString ) ^ 0 + * L "}}" + * EOL + ) ^ 0 + * L "{\\PitonStyle{String.Long}{" + * ( SingleLongInterpol + SingleLongPureString ) ^ 0 + + + C ( ( S "rR" ) ^ -1 * P "'''" * ( 1 - P "'''" - P "\r" ) ^ 0 ) + * L "}}" + * ( + L "{\\PitonStyle{String.Long}{" + * C ( ( 1 - P "'''" - P "\r" ) ^ 0 ) + * L "}}" + * EOL + ) ^ 0 + * L "{\\PitonStyle{String.Long}{" + * C ( ( 1 - P "'''" - P "\r" ) ^ 0 ) + ) + * C ( P "'''" ) + * L "}}" + + +local DoubleLongString = + L "{\\PitonStyle{String.Long}{" + * ( + C ( S "fF" * P "\"\"\"" ) + * ( DoubleLongInterpol + DoubleLongPureString ) ^ 0 + * L "}}" + * ( + EOL + + + L "{\\PitonStyle{String.Long}{" + * ( DoubleLongInterpol + DoubleLongPureString ) ^ 0 + * L "}}" + * EOL + ) ^ 0 + * L "{\\PitonStyle{String.Long}{" + * ( DoubleLongInterpol + DoubleLongPureString ) ^ 0 + + + C ( ( S "rR" ) ^ -1 * P "\"\"\"" * ( 1 - P "\"\"\"" - P "\r" ) ^ 0 ) + * L "}}" + * ( + L "{\\PitonStyle{String.Long}{" + * C ( ( 1 - P "\"\"\"" - P "\r" ) ^ 0 ) + * L "}}" + * EOL + ) ^ 0 + * L "{\\PitonStyle{String.Long}{" + * C ( ( 1 - P "\"\"\"" - P "\r" ) ^ 0 ) + ) + * C ( P "\"\"\"" ) + * L "}}" + + + +local LongString = SingleLongString + DoubleLongString + + +local Expression = + P { "E" , + E = ( 1 - S "{}()[]\r," ) ^ 0 + * ( + ( P "{" * V "F" * P "}" + + P "(" * V "F" * P ")" + + P "[" * V "F" * P "]" ) * ( 1 - S "{}()[]\r," ) ^ 0 + ) ^ 0 , + F = ( 1 - S "{}()[]\r\"'" ) ^ 0 + * ( ( + P "'" * (P "\\'" + 1 - S"'\r" )^0 * P "'" + + P "\"" * (P "\\\"" + 1 - S"\"\r" )^0 * P "\"" + + P "{" * V "F" * P "}" + + P "(" * V "F" * P ")" + + P "[" * V "F" * P "]" + ) * ( 1 - S "{}()[]\r\"'" ) ^ 0 ) ^ 0 , + } + +local Param = SkipSpace * K ( identifier , '' ) * SkipSpace + * ( K ( P "=" * Expression , 'InitialValues' ) + + K ( P ":" , '' ) * SkipSpace * K ( letter^1 , 'Name.Type' )) + + SkipSpace * K ( alphanum ^ 1 , '' ) * SkipSpace + +local Params = Param * ( K ( P "," , '' ) * Param ) ^ 0 + +local StringDoc = K ( P "\"\"\"" , 'String.Doc' ) + * ( K ( (1 - P "\"\"\"" - P "\r" ) ^ 0 , 'String.Doc' ) * EOL ) ^ 0 + * K ( ( 1 - P "\"\"\"" - P "\r" ) ^ 0 * P "\"\"\"" , 'String.Doc' ) + + K ( P "'''" , 'String.Doc' ) + * ( K ( (1 - P "'''" - P "\r")^0 , 'String.Doc' ) * EOL ) ^ 0 + * K ( ( 1 - P "'''" - P "\r")^0 * P "'''" , 'String.Doc' ) + +local CommentMath = P "$" * K ( ( 1 - S "$\r" ) ^ 1 , 'Comment.Math' ) * P "$" + + +local Comment = L ( "{\\pitonStyleComment {" ) + * C ( P "#" ) * ( CommentMath + C ( ( 1 - S "$\r" ) ^ 1 ) ) ^ 0 + * L ( "}}" ) + * ( EOL + -1 ) + +local CommentLaTeX = + P "##" + * L "{\\PitonStyle{Comment.LaTeX}{" + * Ct ( C ( ( 1 - P "\r" ) ^ 0 ) ) + * L "}}" + * ( EOL + -1 ) + +local DefFunction = + K ( P "def" , 'Keyword' ) + * Space + * K ( identifier , 'Name.Function' ) + * ( SkipSpace * K ( P "(" , '' ) * Params * K ( P ")" , '' ) ) ^ -1 + * ( SkipSpace + * K ( ( 1 - S ":\r" )^0 , 'Post.Function' ) + * K ( P ":" , 'Keyword' ) + * SkipSpace + * ( EOL + CommentLaTeX + Comment ) + * SkipSpace + * StringDoc ) ^ -1 + +local ItemDict = ShortString * SkipSpace * C ( P ":" ) * K ( Expression , 'Dict.Value' ) + +local ItemOfSet = SkipSpace * ( ItemDict + ShortString ) * SkipSpace + +local Set = C ( P "{" ) + * ItemOfSet * ( C ( P "," ) * ItemOfSet ) ^ 0 + * C ( P "}" ) + + +local Operator = K ( P "!=" + P "==" + P "<<" + P ">>" + S "-~+/*%=<>&.@|" , 'Operator') + +local OperatorWord = K ( P "in" + P "is" + P "and" + P "or" + P "not" , 'Operator.Word') + +local SyntaxPython = + ( ( space - P "\r" ) ^0 * P "\r" ) ^ -1 * space ^ -1 * + ( ( space^1 * -1 ) + + EOL + + Space + + Escape + + CommentLaTeX + + LongString + + Comment + + ExceptionInConsole + + Set + + Delim + + Class * ( Space + Punct + EOL ) + + Namespace * ( Space + Punct + EOL ) + + ImportAs + + RaiseException + + Keyword * ( Space + Punct + EOL ) + + DefFunction + + ShortString + + Decorator * ( Space + Punct + EOL ) + + Operator + + OperatorWord * ( Space + Punct + EOL ) + + Builtin * ( Space + Punct + EOL ) + + Identifier + + Number + + Word + ) ^0 * -1 + + +local MinimalSyntax = + P { "S" ; + S = K ( (1 - P "\r" ) ^ 0 , '') + EOL * S + } + + +--- with cctab, all characters including spaces have catcode 12 +local cctab = luatexbase.catcodetables.CatcodeTableOther + +function Parse(code) + local t = Ct(SyntaxPython) : match(code) + if t then else t = Ct(MinimalSyntax) : match(code) end + for i = 1 , #t do + if type(t[i]) == 'string' + then + tex.sprint(cctab, t[i]) + else + tex.sprint( t[i][1] ) + end + end +end + +function ParseFile(name) + s = '' + for line in io.lines(name) do s = s .. '\r' .. line end + Parse(s) +end + + +function define_gobble_syntax(n) + GobbleSyntax = ( 1 - P "\r" ) ^ (-n) * C ( ( 1 - P "\r" ) ^0 ) + * ( C ( P "\r" ) + * ( 1 - P "\r" ) ^ (-n) + * C ( ( 1 - P "\r" ) ^0 ) + ) ^ 0 +end + +function GobbleParse(code) + local t = Ct(GobbleSyntax):match(code) + local new_code = "" + for i = 1 , #t do + new_code = new_code .. t[i] + end + Parse(new_code) +end + + +function min(x,y) + if x <= y + then return x + else return y + end +end + +function add(acc,new_value) + return acc + new_value +end + + +--[[ The following LPEG returns as capture the minimal number of spaces at +the beginning of the lines of code]] +AutoGobbleSyntax = + ( space ^ 0 * P "\r" ) ^ -1 + * Cf ( + ( + ( P " " ) ^ 0 * P "\r" + + + Cf ( Cc(0) * ( P " " * Cc(1) ) ^ 0 , add ) + * ( 1 - P " " ) * ( 1 - P "\r" ) ^ 0 * P "\r" + ) ^ 0 + * + ( Cf ( Cc(0) * ( P " " * Cc(1) ) ^ 0 , add ) + * ( 1 - P " " ) * ( 1 - P "\r" ) ^ 0 ) ^ -1 , + min + ) + + +function AutoGobbleParse(code) + local n = AutoGobbleSyntax:match(code) + if n==0 + then Parse(code) + else define_gobble_syntax(n) + GobbleParse(code) + end +end + + + + + + + + + + + diff --git a/macros/luatex/latex/piton/piton.pdf b/macros/luatex/latex/piton/piton.pdf new file mode 100644 index 0000000000..34024c336e Binary files /dev/null and b/macros/luatex/latex/piton/piton.pdf differ -- cgit v1.2.3