From 679f10baab2346635f0953f5acf1b6d7067da22b Mon Sep 17 00:00:00 2001 From: PatrikBak Date: Thu, 7 May 2026 23:00:18 +0200 Subject: [PATCH] Add \Remark, \NamedProof, \SmileWithTear macros to handout template Extends \Theorem to peek at the proof body for a leading \NamedProof sentinel, allowing multi-proof theorems to supply their own labelled headers instead of the auto "\captionProof." prefix. Adds matching TeX cleaner rules so \Remark, \NamedProof, \SmileWithTear and the \em italic form render correctly on the web. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../TexCleaner/tex_cleaner_rules.txt | 7 +++++ data/handouts/_template.tex | 29 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/backend/src/Core/MathComps.TexParser/TexCleaner/tex_cleaner_rules.txt b/backend/src/Core/MathComps.TexParser/TexCleaner/tex_cleaner_rules.txt index bf7e9144..c2054913 100644 --- a/backend/src/Core/MathComps.TexParser/TexCleaner/tex_cleaner_rules.txt +++ b/backend/src/Core/MathComps.TexParser/TexCleaner/tex_cleaner_rules.txt @@ -47,7 +47,9 @@ \\itemvar\{(.*)\} => \item{$1} \{\s*\\it\s(.*?)(?:\\\/)?\} => \textit{$1} +\{\s*\\em\s(.*?)(?:\\\/)?\} => \textit{$1} \\emph\{(.*?)\} => \textit{$1} +\\NamedProof\{(.*?)\} => \textit{$1} \\geqq(?![A-Za-z]) => \ge \\leqq(?![A-Za-z]) => \le @@ -58,6 +60,8 @@ \\pozn[aá]mka(?![A-Za-z]) => \textit{Poznámka.} \\note(?![A-Za-z]) => \textit{Remark.} \\remark(?![A-Za-z]) => \textit{Remark.} +\\Remark\{([^}]*)\}(?![A-Za-z]) => \textit{Poznámka ($1).} +\\Remark(?![A-Za-z]) => \textit{Poznámka.} \\align(?![A-Za-z]) => \begin{align*} \\endalign(?![A-Za-z]) => \end{align*} @@ -92,6 +96,7 @@ \\SlightSmile(?![A-Za-z]) => 🙂 \\Laugh(?![A-Za-z]) => 😄 +\\SmileWithTear(?![A-Za-z]) => 🥲 [remove] @@ -147,6 +152,7 @@ choose circ clubsuit colon +cong cos cotg cr @@ -184,6 +190,7 @@ lceil ldots le left +Leftarrow leq leqslant lfloor diff --git a/data/handouts/_template.tex b/data/handouts/_template.tex index 6e211cc4..edbee1e2 100644 --- a/data/handouts/_template.tex +++ b/data/handouts/_template.tex @@ -32,6 +32,7 @@ % Emoji macros: render as ASCII in the PDF, replaced with UTF-8 emoji on the web \def\SlightSmile{:-)} \def\Laugh{:D} +\def\SmileWithTear{:'-)} % Prints a link to the MathComps website to the handout \def\MathcompsLink#1{% @@ -54,6 +55,7 @@ \def\captionExample{Příklad}% \def\captionSolution{Řešení}% \def\captionProblem{Úloha}% + \def\captionRemark{Poznámka}% \def\captionProblemSolutions{Řešení k úlohám} \def\captionExerciseSolutions{Řešení ke cvičením} \def\captionHints##1{% @@ -90,6 +92,7 @@ \def\captionExample{Príklad}% \def\captionSolution{Riešenie}% \def\captionProblem{Úloha}% + \def\captionRemark{Poznámka}% \def\captionProblemSolutions{Riešenia k úlohám} \def\captionExerciseSolutions{Riešenia k cvičeniam} \def\captionHints##1{% @@ -126,6 +129,7 @@ \def\captionExample{Example}% \def\captionSolution{Solution}% \def\captionProblem{Problem}% + \def\captionRemark{Remark}% \def\captionProblemSolutions{Solutions to problems} \def\captionExerciseSolutions{Solutions to exercises} \def\captionHints##1{% @@ -195,6 +199,11 @@ \long\def\saferead#1{\ignorespaces#1} \long\def\safepar{\par\removelastskip} +% Remark: \Remark text or \Remark{label} text +\def\Remark{\safepar\isnextchar\bgroup{\remarkwitharg}{\remarknoarg}} +\long\def\remarkwitharg#1{\textit{\captionRemark\ (#1).}\enskip} +\def\remarknoarg{\textit{\captionRemark.}\enskip} + % Prints the end of a block (exercise, theorem, example, definition) \def\endblock{% \safepar\medskip% @@ -256,10 +265,28 @@ \enskip\saferead{#2}\safepar% }% \def\temp{#3}\ifx\temp\empty\else% - \safepar{\em \captionProof.}\enskip\saferead{#3}\qedsquare\endblock% + \safepar% + \theoremDispatchProof#3\theoremDispatchEnd% + \qedsquare\endblock% + \fi% +} + +% Peeks at the first token of the proof body. If it is \NamedProof, the body +% supplies its own labelled proof headers, so emit the body verbatim. Otherwise +% prepend the standard "\captionProof." italic header. +\long\def\theoremDispatchProof#1#2\theoremDispatchEnd{% + \ifx#1\NamedProof% + #1#2% + \else% + {\em \captionProof.}\enskip\saferead{#1#2}% \fi% } +% Named proof header inside a multi-proof \Theorem body. The argument is +% rendered in italics, matching the standard \captionProof style. Acts as a +% sentinel for \theoremDispatchProof to suppress the auto "\captionProof." prefix. +\def\NamedProof#1{\textit{#1}} + % #1 - Source (might be empty) % #2 - Statement % #3 - Solution