diff options
author | Norbert Preining <norbert@preining.info> | 2024-03-28 03:01:34 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2024-03-28 03:01:34 +0000 |
commit | 79e9e48f9496fe82b7e76b2b318d24e9aab1ca8a (patch) | |
tree | 5c7e66ed056f7855cb4caee718c5406c947e3af8 /macros/latex/contrib | |
parent | 31fa8cd73bab8480d38dae3a89ca578f337d6bbd (diff) |
CTAN sync 202403280301
Diffstat (limited to 'macros/latex/contrib')
19 files changed, 1121 insertions, 187 deletions
diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/README.md b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/README.md index 5634883569..c167a21ea5 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/README.md +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/README.md @@ -1,4 +1,5 @@ -<b>Date of last change: 2024-02-10 to version v1.1p</b> +<b>Date of last change: 2024-03-27 to version v1.1q</b> + # biblatex-gb7714-2015: a biblatex style package @@ -74,6 +75,8 @@ biblatex-gb7714-2015 宏包是中文参考文献著录/标注标准 `GB/T 7714-2 * [SJTUThesis(上海交通大学学位论文模板)](https://github.com/sjtug/SJTUThesis) (母校的论文模板,不得不说缘分真的很神奇,16年一出来就用上) * [sustechthesis(Southern University of Science and Technology Thesis Template LaTeX Template)](https://github.com/Iydon/sustechthesis) * [SwufeTeX(西南财经大学学位论文LaTeX模板)](https://github.com/OopsYao/swufethesis) +* [SYSUThesis(中山大学研究生学位论文LaTeX模板(试用))](https://github.com/1FCENdoge/SYSUThesis) +* [sysu-thesis(中山大学 LaTeX 论文项目模板(本科))](https://github.com/SYSU-SCC/sysu-thesis) * [Thesis-Template-for-XJTU (西安交大毕业设计模板)](https://github.com/DXie123/Thesis-Template-for-XJTU) * [ThuThesis(LaTeX Thesis Template for Tsinghua University )](https://github.com/tuna/thuthesis) * [TongjiThesis(同济大学硕博士论文LaTeX模板)](https://github.com/marquistj13/TongjiThesis) @@ -703,14 +706,15 @@ GB/T 7714-2015标准实现的bst版本,已经由[zeping lee](https://github.co #### 4.2 Bibliography format/文献表著录格式 -* <b>请问可以在参考文献表中实现类似于word那样的与文献内容等间距标签对齐格式么?</b> +* <b>请问可以在参考文献表中实现类似于word那样的与文献内容等间距的标签对齐格式么?</b> 可以,latex的列表通常用list来实现,因此一般列表的内容都是对齐的, -此时如果标签右对齐的,那么标签和内容等间距,但标签左侧是不对齐的。 -如果标签是左对齐的,那么标签和内容的间距不相等。 -如果要求标签左侧对齐,且标签与内容等间距必须放弃使用list。 -biblatex-7714-2015的顺序编码制样式特别设计了这样的环境,以保持和word一致。通过设置选项gbalign来实现: +此时如果标签右对齐的,那么标签和内容等间距,但标签左侧是不对齐的,此时对应的选项为:gbalign=right。 +如果标签是左对齐的,那么标签和内容的间距不相等,此时对应的选项为:gbalign=left。 +如果标签是中间对齐的,那么标签的两侧的[]是对齐的,数字标签处于其中间,此时对应的选项为:gbalign=center。 +如果要求标签左侧对齐,且标签与内容等间距,则必须放弃使用list,这种方式在本宏包中称为项对齐,对应选项为gbalign=gb7714-2015, +这是biblatex-7714-2015的顺序编码制样式为项对齐设计了专门环境达成的,其使用方式很简单,加上响应的选项即可: ```\usepackage[backend=biber,bibstyle=gb7714-2015,gbalign=gb7714-2015]{biblatex}``` @@ -1609,6 +1613,8 @@ please see the file 'biblatex-gb7714-2015.pdf' for further information! * 2023/05/24 v1.1n,ctan,github * 2023/09/10 v1.1o,ctan,github * 2024/02/10 v1.1p,ctan,github +* 2024/03/27 v1.1q,ctan,github + diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.pdf b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.pdf Binary files differindex e0b7222d5e..042dce20cb 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.pdf +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.pdf diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.tex b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.tex index 2dce4783ce..e87235d9e4 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.tex +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.tex @@ -538,6 +538,20 @@ leftrule=0pt,rightrule=0pt,toprule=0.4pt,bottomrule=0.4pt] \caption{文献表作者缺失处理选项gbnoauthor效果}\label{fig:eg:optgbnoauthor} \end{figure} + + + \pdfbookmark[4]{gbnoothers}{gbnoothers} + \item[gbnoothers]=true,\textbf{false}. \hfill default is false + + 为控制是否输出作者列表截断后的等/et al. 信息增加的选项。 + \begin{itemize} + \item gbnoothers=false,默认输出等、et al.信息; + \item gbnoothers=true,不输出。 + \end{itemize} + 该选项是全局选项,设置为true后,全文的作者列表都将不输出。若需要再局部调整,则利用编组局部设置\verb|\settoggle{bbx:gbnoothers}{true}|即可。 + + + \pdfbookmark[4]{gbbiblabel}{gbbiblabel} \item[gbbiblabel]=\textbf{bracket},parens,plain,dot,box,circle. \hfill default is bracket @@ -1098,6 +1112,16 @@ leftrule=0pt,rightrule=0pt,toprule=0.4pt,bottomrule=0.4pt] 将会为author2007en,author2014en两个条目添加nameformat域信息。 该命令也只能出现在导言区中。 + + \pdfbookmark[4]{delEntryField}{delEntryField} + \item[delEntryField] \{entrykey or entrykey comma list\}\{field\} + + 用于给指定的文献条目(集)删除域。即将指定的entrykey 条目或者entrykey comma list 中的各个条目中的 field 域删除。 + + \verb|\delEntryField{author2007en,author2014en}{usera}| + + 将会把author2007en,author2014en两个条目中usera域信息删除。 + \pdfbookmark[4]{setlocalbibstring}{setlocalbibstring} @@ -1650,7 +1674,7 @@ leftrule=0pt,rightrule=0pt,toprule=0.4pt,bottomrule=0.4pt] \end{figure} \paragraph{\heiti 文献表竖直间距控制} -文献表各条目之间的竖直间距控制如例\ref{eg:biblist:vspace}所示,此外,还可以调整方括号和圆括号的竖直位置,使其与使用无基线以下部分字体的文本相配合。 +文献表各条目之间的竖直间距控制如例\ref{eg:biblist:vspace}所示。注意,这些竖直间距设置不是行距设置,而是行距基础上附加设置,行距默认采用正文的设置,若要局部调整参考文献的行距,则在局部编组中采用linespread命令或者调整 baselinestretch 实现。此外,还可以调整方括号和圆括号的竖直位置,使其与使用无基线以下部分字体的文本相配合。 \begin{example}{文献表竖直间距控制}{eg:biblist:vspace} \begin{texlist} @@ -1779,7 +1803,7 @@ bibitemindent表示 其它一些修改示例可以参考: \href{run:./chinese-erj.bbx}{chinese-erj.bbx}, \href{run:./gb7714-CCNU.bbx}{gb7714-CCNU.bbx}, -\href{run:./egthesis/thesis-uibe-numeric.tex}{thesis-uibe-numeric.tex}。各标点命令的意义详见biblatex手册。 +\href{run:./egthesis/thesis-uibe-numeric.tex}{thesis-uibe-numeric.tex}。各标点命令的意义详见biblatex手册。一些示例见:\url{https://github.com/TheNetAdmin/zjuthesis/issues/374}。 \begin{example}{文献表常见标点(间隔符)控制}{eg:biblist:separator} \begin{texlist} @@ -1806,12 +1830,16 @@ bibitemindent表示 %姓名内部的相关标点,包括如下等设置 %注意这类设置与gbnamefmt选项相关,不同的选项值对应不同的gb...localset +%包括:gbcaselocalset,gbpinyinlocalset,gbquanpinlocalset,gbfullnamelocalset +%如果是familyahead,givenahead选项,则直接使用内部的重设命令即可。 %除了如下命令外还有其它设置,有需要可以查biblatex文档 \def\gbcaselocalset{% \renewcommand*{\revsdnamepunct}{,}%% \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 \renewrobustcmd*{\bibinithyphendelim}{}%.\mbox{-} -\renewrobustcmd*{\bibnamedelima}{} %%\mbox{-} +\renewrobustcmd*{\bibnamedelima}{} %%全拼名后的标点\mbox{-} +\renewrobustcmd*{\bibnamedelimi}{} %名缩写点后的标点,Initials in the bib file +\renewrobustcmd*{\bibinitdelim}{} %名缩写点后的标点 } \end{texlist} \end{example} @@ -2007,6 +2035,20 @@ annotation = {美国发明专利申请号.}, } \end{filecontents} +%导言区 +%去掉文献Zhang2007-500-503的usera域 +\delEntryField{Zhang2007-500-503}{usera} +%在第1个refsection中去掉article类的文献标识符 +%利用AtEveryBibitem在对refsection和entrytype判断后局部做设置 +\AtEveryBibitem{% +\ifnumequal{\value{refsection}}{1} + {% + \ifentrytype{article}{\settoggle{bbx:gbtype}{false}}{\settoggle{bbx:gbtype}{true}}% + }% + {}% +} + +%正文区 \begin{refsection}[resume.bib] \nocite{ref-8-1-任天令,ref-9-1-Ren}% \printbibliography[heading=subbibliography,title={研究成果}] @@ -2170,7 +2212,7 @@ annotation = {美国发明专利申请号.}, \href{https://github.com/hushidong/biblatex-solution-to-latex-bibliography/blob/master/biblatex-solution-to-latex-bibliography.pdf}% {biblatex-solution-to-latex-bibliography}中的第2.10节。 -具体例子则可以参考\href{run:./stdgbT7714-2015.pdf}{stdgbT7714-2015.pdf}。其中第8节中大量使用这种方式。 +具体例子则可以参考\href{run:./stdgbT7714-2015.pdf}{stdgbT7714-2015.pdf},其中第8节中大量使用这种方式。 @@ -2540,7 +2582,7 @@ biber -l zh__stroke jobname 其中,排序模板优先使用persort域进行排序,接着是与文种相关的lansortorder域,接着是sortkey域(该域在biblatex中就是key域的别名),接着是sortname等作者姓名相关的域,要让文献根据多音字习惯音进行排序,那么就在key域中设置文献作者姓名的习惯音。比如三篇文献作者分别是[李四]、[J. B. Conway]、[曾三]。在设置sorting=multipinyin, gblanorder=chineseahead, sortlocale=zh\_\_pinyin的情况下,根据上述的multipinyin排序模板,首先根据文种和作者信息将中文文献[曾三][李四]排在前面,接着是[J. B. Conway],因为默认情况下,曾字考虑的读音是ceng2,但这不是我们希望得到的。 -所以需要手动将key域设置为中文的拼音,比如[李四]文献设置key=\{li3si4\},而[曾三]文献设置key=\{zeng1san1\},那么中文文献仍然排在前面,但根据key域的设置会将[李四]文献排列在[曾三]前面。因此手动设置作者姓名的习惯拼音后,文献排列正确,顺序为:[李四][曾三][J. B. Conway]。 需要注意的是:若要手动设置拼音则需要对文献表中的全部中文文献设置否则利用key域排序就会失效,而这并是一个轻松的活,此时我们可以使用自动设置拼音的工具,详见 +所以需要手动将key域设置为中文的拼音,比如[李四]文献设置key=\{li3si4\},而[曾三]文献设置key=\{zeng1san1\},那么中文文献仍然排在前面,但根据key域的设置会将[李四]文献排列在[曾三]前面。因此手动设置作者姓名的习惯拼音后,文献排列正确,顺序为:[李四][曾三][J. B. Conway]。 需要注意的是:若要手动设置拼音则需要对文献表中的全部中文文献设置否则利用key域排序就会失效,而这并不是一个轻松的活,此时我们可以使用自动设置拼音的工具,详见 \href{https://www.latexstudio.net/index/details/index/ids/1546}{为中文参考文献自动添加排序用的拼音信息域},\href{https://github.com/hushidong/biblatex-map}{bibmap宏包}。 diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015.bbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015.bbx index bc09f63c6e..6042720bc3 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015.bbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015.bbx @@ -11,7 +11,7 @@ % % 版本和时间信息 % -\def\versionofgbtstyle{2024/02/10 v1.1p} +\def\versionofgbtstyle{2024/03/27 v1.1q} \def\versionofbiblatex{\abx@version} \ProvidesFile{gb7714-2015.bbx}[\versionofgbtstyle biblatex bibliography style] %\RequireBiber[3]%显式指定用biber后端,当用bibtex时会报错,但其实不会影响编译,只是采用bibtex后无法达成格式需求 @@ -236,6 +236,14 @@ % 设置宏包选项 %===================================================================== % + % 增加一个控制是否输出and others信息的选项 + % 20240315,v1.1p,hzz + \newtoggle{bbx:gbnoothers} + \DeclareBibliographyOption{gbnoothers}[false]{%biblatex低版本 + \settoggle{bbx:gbnoothers}{#1}} + \ExecuteBibliographyOptions{gbnoothers} + + % % 增加一个控制是否调整日期输出位置的选项mergedate % 为兼容性考虑,但实际不产生作用了,因为如果要使用ay样式可以直接从bibstyle进入 % 因为使用string所以只适用于biblatex3.3以上版本 @@ -960,6 +968,7 @@ bibliography = {\str@bibliography}, references = {\str@references}, bytranslatorcn = {\str@bytranslator},%\addperiod,%将trans. by 改成 译\addcomma\ + byeditor={\iffieldequalstr{userd}{chinese}{\str@editorcn}{ed\adddotspace by}}, and = {\addcomma},%将第2和3人名间的and符号改成逗号,用\finalnamedelim命令也可以定义,参见3.9.1节 andcn = {\addcomma},%and本地化字符串的中文对应词 andincitecn = {\str@andcn},%将标注中的分开,便于与文献表中的区分 @@ -1848,37 +1857,31 @@ } %用于人工的为条目或条目集添加域 \newcommand{\addEntryField}[3]{% - \edef\entrykeya{#1} - \edef\entrykeyb{#2} - \edef\entrykeyc{#3} + \edef\entrykeya{#1}% + \edef\entrykeyb{#2}% + \edef\entrykeyc{#3}% \DeclareStyleSourcemap{ \maps[datatype=bibtex]{ \map[foreach={#1}]{ \step[fieldsource=entrykey, match=\regexp{$MAPLOOP}, final] \step[fieldset=\entrykeyb, fieldvalue=\entrykeyc] } - \map{%处理在bib文件中直接给出文献的姓名格式为lowercase的情况 - \step[fieldsource=nameformat,match=lowercase,final] - \step[fieldset=namefmtid,fieldvalue={1}] - } - \map{%处理在bib文件中直接给出文献的姓名格式为givenahead的情况 - \step[fieldsource=nameformat,match=givenahead,final] - \step[fieldset=namefmtid,fieldvalue={2}] - } - \map{%处理在bib文件中直接给出文献的姓名格式为familyahead的情况 - \step[fieldsource=nameformat,match=familyahead,final] - \step[fieldset=namefmtid,fieldvalue={3}] - } - \map{%处理在bib文件中直接给出文献的姓名格式为pinyin的情况 - \step[fieldsource=nameformat,match=pinyin,final] - \step[fieldset=namefmtid,fieldvalue={4}] - } - \map{%处理在bib文件中直接给出文献的姓名格式为全拼的情况 - \step[fieldsource=nameformat,match=quanpin,final] - \step[fieldset=namefmtid,fieldvalue={6}] - } } - } + }% + } + +%用于人工的为条目或条目集删除域 +\newcommand{\delEntryField}[2]{% + \edef\entrykeya{#1}% + \edef\entrykeyb{#2}% + \DeclareStyleSourcemap{ + \maps[datatype=bibtex,overwrite]{ + \map[foreach={#1}]{ + \step[fieldsource=entrykey, match=\regexp{$MAPLOOP}, final] + \step[fieldset=\entrykeyb, fieldvalue={}] + } + } + }% } % @@ -2355,7 +2358,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 \DeclareFieldFormat{gbtypeflag}{% \iftoggle{bbx:gbmedium}% {\iftoggle{bbx:url}% - {\iffieldundef{url}%当存在url时,增加一个OL标识符 + {\ifboolexpr{ test {\iffieldundef{url}} and test {\iffieldundef{doi}} and test {\iffieldundef{eprint}} }%\iffieldundef{url}%当存在url时,增加一个OL标识符->改为当存在doi或eprint或url时增加OL标识符 {\printdelim{titletypedelim}\printtext{\gbleftbracket}\nobreak#1\nobreak\printtext{\iffieldundef{medium}{}{{\SlashFont/}\thefield{medium}}\gbrightbracket}}% {\printdelim{titletypedelim}\printtext{\gbleftbracket}\nobreak#1\nobreak\printtext{{\SlashFont/}OL\gbrightbracket}}% }% @@ -2476,6 +2479,18 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 \patchcmd{\abx@macro@title}{\newunitpunct}{}{}{}}}{} } +% +\newbibmacro*{byeditor+others}{% + \ifnameundef{editor} + {} + {\iffieldequalstr{userd}{chinese}{}{\usebibmacro{byeditor+othersstrg}% + \setunit{\addspace}}% + \printnames[byeditor]{editor}% + \iffieldequalstr{userd}{chinese}{\usebibmacro{byeditor+othersstrg}}{}% + \clearname{editor}% + \newunit}% + \usebibmacro{byeditorx}% + \usebibmacro{bytranslator+others}} % % 修改译者位置格式 @@ -2485,8 +2500,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 \renewbibmacro*{bytranslator+others}{\bibauthorfont% \ifnameundef{translator} {} - {\iffieldequalstr{usere}{chinese}{}{\usebibmacro{bytranslator+othersstrg}}% - %\setunit{\addspace}% + {\iffieldequalstr{usere}{chinese}{}{\usebibmacro{bytranslator+othersstrg}\setunit{\addspace}}% \printnames[bytranslator]{translator}% \clearname{translator}% %从macro*{bytranslator+othersstrg}%中可以看到当地化字符串格式的引用前的代码处理 @@ -2792,7 +2806,9 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 {\namepartprefix} {\namepartsuffix}% \fi - \usebibmacro{name:andothers}} +\iftoggle{bbx:gbnoothers}{}% + {\usebibmacro{name:andothers}}% +} \DeclareNameAlias{default}{namefmtselected}%姓名的默认格式采用可选的模式 \DeclareNameAlias{sortname}{default}% Used in the bibliography %family-given/given-family @@ -3092,8 +3108,10 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 {\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}}% \or \usebibmacro{name:gbquanpin}{#1}{#3}{#5}{#7}% - \fi - \usebibmacro{name:andothers}} + \fi% +\iftoggle{bbx:gbnoothers}{}% + {\usebibmacro{name:andothers}}% + }% } % @@ -4218,7 +4236,7 @@ test{\iffieldundef{day}} and test{\iffieldundef{endday}} and test{\iffieldundef{ \usebibmacro{institution+location+date}% %\newunit\newblock \usebibmacro{chapter+pages}% - \iffieldundef{url}{}{a%当没有网址时也不输出修改或更新日期 + \iffieldundef{url}{}{%当没有网址时也不输出修改或更新日期 \usebibmacro{modifydate}}%修改或更新日期为带括号的时间 \usebibmacro{doi+eprint+url}% \newunit diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.bbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.bbx index 73316ea3cb..01a0f05a6b 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.bbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.bbx @@ -10,7 +10,7 @@ % % 版本和时间信息 % -\def\versionofgbtstyle{2024/02/10 v1.1p} +\def\versionofgbtstyle{2024/03/27 v1.1q} \def\versionofbiblatex{\abx@version} \ProvidesFile{gb7714-2015ay.bbx}[\versionofgbtstyle biblatex bibliography style] %\RequireBiber[3]%显式指定用biber后端,当用bibtex时会报错,但其实不会影响编译,只是采用bibtex后无法达成格式需求 @@ -233,6 +233,14 @@ % 设置宏包选项 %===================================================================== % + % 增加一个控制是否输出and others信息的选项 + % 20240315,v1.1p,hzz + \newtoggle{bbx:gbnoothers} + \DeclareBibliographyOption{gbnoothers}[false]{%biblatex低版本 + \settoggle{bbx:gbnoothers}{#1}} + \ExecuteBibliographyOptions{gbnoothers} + + % % 增加一个控制是否输出文献载体的选项 % 20191125,v1,0s,hzz \newtoggle{bbx:gbmedium} @@ -913,6 +921,7 @@ bibliography = {\str@bibliography}, references = {\str@references}, bytranslatorcn= {\str@bytranslator\adddot}, %将trans. by 改成 译 + byeditor={\iffieldequalstr{userd}{chinese}{\str@editorcn}{ed\adddotspace by}}, and = {\addcomma},%将第2和3人名见的and符号改成 逗号,用\finalnamedelim命令也可以定义,参见3.9.1节 andcn = {\addcomma},%\str@andcn\ and本地化字符串的中文对应词 andincitecn = {\str@andcn},%将标注中的分开,便于与文献表中的区分 @@ -1675,37 +1684,31 @@ } %用于人工的为条目或条目集添加域 \newcommand{\addEntryField}[3]{% - \edef\entrykeya{#1} - \edef\entrykeyb{#2} - \edef\entrykeyc{#3} + \edef\entrykeya{#1}% + \edef\entrykeyb{#2}% + \edef\entrykeyc{#3}% \DeclareStyleSourcemap{ \maps[datatype=bibtex]{ \map[foreach={#1}]{ \step[fieldsource=entrykey, match=\regexp{$MAPLOOP}, final] \step[fieldset=\entrykeyb, fieldvalue=\entrykeyc] } - \map{%处理在bib文件中直接给出文献的姓名格式为lowercase的情况 - \step[fieldsource=nameformat,match=lowercase,final] - \step[fieldset=namefmtid,fieldvalue={1}] - } - \map{%处理在bib文件中直接给出文献的姓名格式为givenahead的情况 - \step[fieldsource=nameformat,match=givenahead,final] - \step[fieldset=namefmtid,fieldvalue={2}] - } - \map{%处理在bib文件中直接给出文献的姓名格式为familyahead的情况 - \step[fieldsource=nameformat,match=familyahead,final] - \step[fieldset=namefmtid,fieldvalue={3}] - } - \map{%处理在bib文件中直接给出文献的姓名格式为pinyin的情况 - \step[fieldsource=nameformat,match=pinyin,final] - \step[fieldset=namefmtid,fieldvalue={4}] - } - \map{%处理在bib文件中直接给出文献的姓名格式为全拼的情况 - \step[fieldsource=nameformat,match=quanpin,final] - \step[fieldset=namefmtid,fieldvalue={6}] - } } - } + }% + } + +%用于人工的为条目或条目集删除域 +\newcommand{\delEntryField}[2]{% + \edef\entrykeya{#1}% + \edef\entrykeyb{#2}% + \DeclareStyleSourcemap{ + \maps[datatype=bibtex,overwrite]{ + \map[foreach={#1}]{ + \step[fieldsource=entrykey, match=\regexp{$MAPLOOP}, final] + \step[fieldset=\entrykeyb, fieldvalue={}] + } + } + }% } % @@ -2213,7 +2216,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 \DeclareFieldFormat{gbtypeflag}{% \iftoggle{bbx:gbmedium}% {\iftoggle{bbx:url}% - {\iffieldundef{url}%当存在url时,增加一个OL标识符 + {\ifboolexpr{ test {\iffieldundef{url}} and test {\iffieldundef{doi}} and test {\iffieldundef{eprint}} }%\iffieldundef{url}%当存在url时,增加一个OL标识符->改为当存在doi或eprint或url时增加OL标识符 {\printdelim{titletypedelim}\printtext{\gbleftbracket}\nobreak#1\nobreak\printtext{\iffieldundef{medium}{}{{\SlashFont/}\thefield{medium}}\gbrightbracket}}% {\printdelim{titletypedelim}\printtext{\gbleftbracket}\nobreak#1\nobreak\printtext{{\SlashFont/}OL\gbrightbracket}}% }% @@ -2334,6 +2337,19 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 } +\renewbibmacro*{byeditor+others}{% + \ifnameundef{editor} + {} + {\iffieldequalstr{userd}{chinese}{}{\usebibmacro{byeditor+othersstrg}% + \setunit{\addspace}}% + \printnames[byeditor]{editor}% + \iffieldequalstr{userd}{chinese}{\usebibmacro{byeditor+othersstrg}}{}% + \clearname{editor}% + \newunit}% + \usebibmacro{byeditorx}% + \usebibmacro{bytranslator+others}} + + % % 修改译者位置格式 % v1.0w,20210401,hzz,增加对英文等其它语言译者的处理 @@ -2342,8 +2358,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 \renewbibmacro*{bytranslator+others}{\bibauthorfont% \ifnameundef{translator} {} - {\iffieldequalstr{usere}{chinese}{}{\usebibmacro{bytranslator+othersstrg}}% - %\setunit{\addspace}% + {\iffieldequalstr{usere}{chinese}{}{\usebibmacro{bytranslator+othersstrg}\setunit{\addspace}}% \printnames[bytranslator]{translator}% \clearname{translator}% %从macro*{bytranslator+othersstrg}%中可以看到当地化字符串格式的引用前的代码处理 @@ -2648,7 +2663,9 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 {\namepartprefix} {\namepartsuffix}% \fi - \usebibmacro{name:andothers}} +\iftoggle{bbx:gbnoothers}{}% + {\usebibmacro{name:andothers}}% +} \DeclareNameAlias{default}{namefmtselected}%姓名的默认格式采用可选的模式 \DeclareNameAlias{sortname}{default}% Used in the bibliography %family-given/given-family @@ -2948,8 +2965,10 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 {\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}}% \or \usebibmacro{name:gbquanpin}{#1}{#3}{#5}{#7}% - \fi - \usebibmacro{name:andothers}} + \fi% +\iftoggle{bbx:gbnoothers}{}% + {\usebibmacro{name:andothers}}% + }% } % diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.cbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.cbx index 739528dc1b..8a1a03d1d2 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.cbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.cbx @@ -7,7 +7,7 @@ %% Released under the LaTeX Project Public License v1.3c or later %% --------------------------------------------------------------- %% -\ProvidesFile{gb7714-2015.cbx}[a biblatex citation style for GB/T 7714-2015] +\ProvidesFile{gb7714-2015ay.cbx}[a biblatex citation style for GB/T 7714-2015] % % 加载标准样式 @@ -322,16 +322,20 @@ test {\iftoggle{iftlseven}}%3.7=biblatex \newrobustcmd*{\upcite}{% \cite} +\newrobustcmd{\mkbiboutparens}[1]{% + \unspace\allowhyphens% +\begingroup\mkbibleftborder#1\mkbibrightborder\endgroup}% + % % 重定义parencite命令 % -\DeclareCiteCommand{\parencite}%[\mkbibparens] +\DeclareCiteCommand{\parencite}[\mkbiboutparens]% {\usebibmacro{cite:init}% - \mkbibleftborder\usebibmacro{prenote}}% + \usebibmacro{prenote}}% {\usebibmacro{citeindex}% \usebibmacro{cite}} {} - {\usebibmacro{postnote}\mkbibrightborder} + {\usebibmacro{postnote}} % % 重定义footcite需要使用的命令 diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.bbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.bbx index a4668eb0ff..3ff6cc21b6 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.bbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.bbx @@ -11,7 +11,7 @@ % % 版本和时间信息 % -\def\versionofgbtstyle{2024/02/10 v1.1p} +\def\versionofgbtstyle{2024/03/27 v1.1q} \def\versionofbiblatex{\abx@version} \ProvidesFile{gb7714-2015ms.bbx}[\versionofgbtstyle biblatex bibliography style] %\RequireBiber[3]%显式指定用biber后端,当用bibtex时会报错,但其实不会影响编译,只是采用bibtex后无法达成格式需求 @@ -120,6 +120,14 @@ % 设置宏包选项 %===================================================================== % + % 增加一个控制是否输出and others信息的选项 + % 20240315,v1.1p,hzz + \newtoggle{bbx:gbnoothers} + \DeclareBibliographyOption{gbnoothers}[false]{%biblatex低版本 + \settoggle{bbx:gbnoothers}{#1}} + \ExecuteBibliographyOptions{gbnoothers} + + % % 增加一个控制是否输出文献载体的选项 % 20191125,v1,0s,hzz \newtoggle{bbx:gbmedium} @@ -384,6 +392,13 @@ \def\str@mathesiscn{硕士学位论文} \def\str@phdthesiscn{博士学位论文} \def\str@editorcn{主编} + \def\str@editorscn{主编} + \def\str@compilerscn{整理} + \def\str@compilercn{整理} + \def\str@revisercn{编} + \def\str@reviserscn{编} + \def\str@foundercn{编著} + \def\str@founderscn{编著} \AtEndOfPackage{% \iftoggle{bbx:codegbk}{% @@ -636,6 +651,12 @@ \NewBibliographyString{editorcn} \NewBibliographyString{editorscn} \NewBibliographyString{bytranslatorcn} + \NewBibliographyString{compilercn} + \NewBibliographyString{compilerscn} + \NewBibliographyString{revisercn} + \NewBibliographyString{reviserscn} + \NewBibliographyString{foundercn} + \NewBibliographyString{founderscn} % @@ -648,6 +669,7 @@ bibliography = {\str@bibliography}, references = {\str@references}, bytranslatorcn = {\str@bytranslator},%\addperiod,%将trans. by 改成 译 + byeditor={\iffieldequalstr{userd}{chinese}{\str@editorcn}{ed\adddotspace by}}, and = {\addcomma},%将第2和3人名间的and符号改成逗号,用\finalnamedelim命令也可以定义,参见3.9.1节 andcn = {\addcomma},%and本地化字符串的中文对应词 andincitecn = {\addcomma},%将标注中的分开,便于与文献表中的区分 @@ -671,6 +693,12 @@ phdthesiscn={\str@phdthesiscn}, editorscn={\str@editorcn}, editorcn={\str@editorcn}, + compilerscn={\str@compilerscn}, + compilercn={\str@compilercn}, + reviserscn={\str@reviserscn}, + revisercn={\str@revisercn}, + founderscn={\str@founderscn}, + foundercn={\str@foundercn}, } % @@ -1263,6 +1291,35 @@ } } +%用于人工的为条目或条目集添加域 +\newcommand{\addEntryField}[3]{% + \edef\entrykeya{#1}% + \edef\entrykeyb{#2}% + \edef\entrykeyc{#3}% + \DeclareStyleSourcemap{ + \maps[datatype=bibtex]{ + \map[foreach={#1}]{ + \step[fieldsource=entrykey, match=\regexp{$MAPLOOP}, final] + \step[fieldset=\entrykeyb, fieldvalue=\entrykeyc] + } + } + }% + } + +%用于人工的为条目或条目集删除域 +\newcommand{\delEntryField}[2]{% + \edef\entrykeya{#1}% + \edef\entrykeyb{#2}% + \DeclareStyleSourcemap{ + \maps[datatype=bibtex,overwrite]{ + \map[foreach={#1}]{ + \step[fieldsource=entrykey, match=\regexp{$MAPLOOP}, final] + \step[fieldset=\entrykeyb, fieldvalue={}] + } + } + }% + } + % %驱动别名等价于驱动层映射 % @@ -1445,7 +1502,7 @@ \DeclareFieldFormat{gbtypeflag}{% \iftoggle{bbx:gbmedium}% {\iftoggle{bbx:url}% - {\iffieldundef{url}%当存在url时,增加一个OL标识符 + {\ifboolexpr{test {\iffieldundef{url}} and test {\iffieldundef{doi}} and test {\iffieldundef{eprint}}}%\iffieldundef{url}%当存在url时,增加一个OL标识符->改为当存在doi或eprint或url时增加OL标识符 {\allowbreak\printtext{\gbleftbracket}\nobreak#1\nobreak\printtext{\iffieldundef{medium}{}{{\SlashFont/}\thefield{medium}}\gbrightbracket}}% {\allowbreak\printtext{\gbleftbracket}\nobreak#1\nobreak\printtext{{\SlashFont/}OL\gbrightbracket}}% }% @@ -1590,8 +1647,10 @@ {\namepartgiven} {\namepartprefix} {\namepartsuffix}% -\fi - \usebibmacro{name:andothers}} +\fi% +\iftoggle{bbx:gbnoothers}{}% + {\usebibmacro{name:andothers}}% +} \DeclareNameAlias{default}{namefmtselected}%姓名的默认格式采用可选的模式 \DeclareNameAlias{sortname}{default}% Used in the bibliography %family-given/given-family @@ -1935,6 +1994,17 @@ togl{bbx:gbstyle} or test {\iffieldequalstr{userd}{chinese}}% \href{\thefield{url}}{##1}}}{##1}}%重设标题格式,将其修改为首字母大写 \DeclareFieldFormat{pages}{##1}%去掉前面引导页码的pp.等字符,\mkpageprefix[bookpagination]{##1} }% +\renewbibmacro*{byeditor+others}{% + \ifnameundef{editor}% + {}% + {\iffieldequalstr{userd}{chinese}{}{\usebibmacro{byeditor+othersstrg}% + \setunit{\addspace}}% + \printnames[byeditor]{editor}% + \iffieldequalstr{userd}{chinese}{\usebibmacro{byeditor+othersstrg}}{}% + \clearname{editor}% + \newunit}% + \usebibmacro{byeditorx}% + \usebibmacro{bytranslator+others}}% % % 修改译者位置格式 % v1.0w,20210401,hzz,增加对英文等其它语言译者的处理 @@ -1943,8 +2013,7 @@ togl{bbx:gbstyle} or test {\iffieldequalstr{userd}{chinese}}% \renewbibmacro*{bytranslator+others}{\bibauthorfont% \ifnameundef{translator} {} - {\iffieldequalstr{usere}{chinese}{}{\usebibmacro{bytranslator+othersstrg}}% - %\setunit{\addspace}% + {\iffieldequalstr{usere}{chinese}{}{\usebibmacro{bytranslator+othersstrg}\setunit{\addspace}}% \printnames[bytranslator]{translator}% \clearname{translator}% %从macro*{bytranslator+othersstrg}%中可以看到当地化字符串格式的引用前的代码处理 @@ -2092,7 +2161,7 @@ togl{bbx:gbstyle} or test {\iffieldequalstr{userd}{chinese}}% \iffieldundef{titleaddon}{}{\setunit{\subtitlepunct}\printfield{titleaddon}}%判断一下titleaddon \ifboolexpr{test{\ifentrytype{book}} and (not test{\iffieldundef{volume}})}%判断一下book类有没有volume {\setunit{\subtitlepunct}\printfield{volume}}{}% - \ifboolexpr{(test{\ifentrytype{archive}} or test{\ifentrytype{online}}) and (not test{\iffieldundef{number}})}%判断一下archive类有没有number + \ifboolexpr{(test{\ifentrytype{archive}} or test{\ifentrytype{online}}) and (not test{\iffieldundef{number}})}%判断一下archive类有没有number {\setunit{\subtitlepunct}\printfield{number}}{}% \iftoggle{bbx:gbtype}% {\iffieldundef{entrysubtype}{\printfield[gbtypeflag]{usera}}%在标题后直接给出文献标识字母,判断一下,是否是报纸和标准 diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.cbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.cbx index fce42d508b..333b873eec 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.cbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.cbx @@ -7,7 +7,7 @@ %% Released under the LaTeX Project Public License v1.3c or later %% --------------------------------------------------------------- %% -\ProvidesFile{gb7714-2015.cbx}[a biblatex citation style for GB/T 7714-2015] +\ProvidesFile{gb7714-2015ms.cbx}[a biblatex citation style for GB/T 7714-2015] % % 加载样式 diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.bbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.bbx index 8351664a2a..27b316d648 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.bbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.bbx @@ -11,7 +11,7 @@ % % 版本和时间信息 % -\def\versionofgbtstyle{2024/02/10 v1.1p} +\def\versionofgbtstyle{2024/03/27 v1.1q} \def\versionofbiblatex{\abx@version} \ProvidesFile{gb7714-2015mx.bbx}[\versionofgbtstyle biblatex bibliography style] %\RequireBiber[3]%显式指定用biber后端,当用bibtex时会报错,但其实不会影响编译,只是采用bibtex后无法达成格式需求 @@ -147,6 +147,15 @@ % 设置宏包选项 %===================================================================== % + % 增加一个控制是否输出and others信息的选项 + % 20240315,v1.1p,hzz + \newtoggle{bbx:gbnoothers} + \DeclareBibliographyOption{gbnoothers}[false]{%biblatex低版本 + \settoggle{bbx:gbnoothers}{#1}} + \ExecuteBibliographyOptions{gbnoothers} + + + % % 增加一个控制是否输出type域的选项 % 20190212,v1,0q,hzz \newtoggle{bbx:gbfieldtype} @@ -383,6 +392,13 @@ \def\str@mathesiscn{硕士学位论文} \def\str@phdthesiscn{博士学位论文} \def\str@editorcn{主编} + \def\str@editorscn{主编} + \def\str@compilerscn{整理} + \def\str@compilercn{整理} + \def\str@revisercn{编} + \def\str@reviserscn{编} + \def\str@foundercn{编著} + \def\str@founderscn{编著} \AtEndOfPackage{% \iftoggle{bbx:codegbk}{% @@ -680,6 +696,12 @@ \NewBibliographyString{editorcn} \NewBibliographyString{editorscn} \NewBibliographyString{bytranslatorcn} + \NewBibliographyString{compilercn} + \NewBibliographyString{compilerscn} + \NewBibliographyString{revisercn} + \NewBibliographyString{reviserscn} + \NewBibliographyString{foundercn} + \NewBibliographyString{founderscn} @@ -694,6 +716,7 @@ bibliography = {\str@bibliography}, references = {\str@references}, bytranslatorcn = {\str@bytranslator},%\addperiod,%将trans. by 改成 译\addcomma\ + byeditor={\iffieldequalstr{userd}{chinese}{\str@editorcn}{ed\adddotspace by}}, and = {\addcomma},%将第2和3人名间的and符号改成逗号,用\finalnamedelim命令也可以定义,参见3.9.1节 andcn = {\addcomma},%and本地化字符串的中文对应词 andincitecn = {\addcomma},%将标注中的分开,便于与文献表中的区分 @@ -717,6 +740,12 @@ phdthesiscn={\str@phdthesiscn}, editorscn={\str@editorcn}, editorcn={\str@editorcn}, + compilerscn={\str@compilerscn}, + compilercn={\str@compilercn}, + reviserscn={\str@reviserscn}, + revisercn={\str@revisercn}, + founderscn={\str@founderscn}, + foundercn={\str@foundercn}, } % @@ -1407,7 +1436,34 @@ } } +%用于人工的为条目或条目集添加域 +\newcommand{\addEntryField}[3]{% + \edef\entrykeya{#1}% + \edef\entrykeyb{#2}% + \edef\entrykeyc{#3}% + \DeclareStyleSourcemap{ + \maps[datatype=bibtex]{ + \map[foreach={#1}]{ + \step[fieldsource=entrykey, match=\regexp{$MAPLOOP}, final] + \step[fieldset=\entrykeyb, fieldvalue=\entrykeyc] + } + } + }% + } +%用于人工的为条目或条目集删除域 +\newcommand{\delEntryField}[2]{% + \edef\entrykeya{#1}% + \edef\entrykeyb{#2}% + \DeclareStyleSourcemap{ + \maps[datatype=bibtex,overwrite]{ + \map[foreach={#1}]{ + \step[fieldsource=entrykey, match=\regexp{$MAPLOOP}, final] + \step[fieldset=\entrykeyb, fieldvalue={}] + } + } + }% + } % @@ -1751,7 +1807,7 @@ \DeclareFieldFormat{gbtypeflag}{% \iftoggle{bbx:gbmedium}% {\iftoggle{bbx:url}% - {\iffieldundef{url}%当存在url时,增加一个OL标识符 + {\ifboolexpr{ test {\iffieldundef{url}} and test {\iffieldundef{doi}} and test {\iffieldundef{eprint}} }%\iffieldundef{url}%当存在url时,增加一个OL标识符->改为当存在doi或eprint或url时增加OL标识符 {\allowbreak\printtext{\gbleftbracket}\nobreak#1\nobreak\printtext{\iffieldundef{medium}{}{{\SlashFont/}\thefield{medium}}\gbrightbracket}}% {\allowbreak\printtext{\gbleftbracket}\nobreak#1\nobreak\printtext{{\SlashFont/}OL\gbrightbracket}}% }% @@ -1867,7 +1923,17 @@ \patchcmd{\abx@macro@title}{\newunitpunct}{}{}{}}}{} } - +\newbibmacro*{byeditor+others}{% + \ifnameundef{editor} + {} + {\iffieldequalstr{userd}{chinese}{}{\usebibmacro{byeditor+othersstrg}% + \setunit{\addspace}}% + \printnames[byeditor]{editor}% + \iffieldequalstr{userd}{chinese}{\usebibmacro{byeditor+othersstrg}}{}% + \clearname{editor}% + \newunit}% + \usebibmacro{byeditorx}% + \usebibmacro{bytranslator+others}} % % 修改译者位置格式 % v1.0w,20210401,hzz,增加对英文等其它语言译者的处理 @@ -1876,8 +1942,7 @@ \renewbibmacro*{bytranslator+others}{\bibauthorfont% \ifnameundef{translator} {} - {\iffieldequalstr{usere}{chinese}{}{\usebibmacro{bytranslator+othersstrg}}% - %\setunit{\addspace}% + {\iffieldequalstr{usere}{chinese}{}{\usebibmacro{bytranslator+othersstrg}\setunit{\addspace}}% \printnames[bytranslator]{translator}% \clearname{translator}% %从macro*{bytranslator+othersstrg}%中可以看到当地化字符串格式的引用前的代码处理 @@ -2172,8 +2237,10 @@ {\namepartgiven} {\namepartprefix} {\namepartsuffix}% -\fi - \usebibmacro{name:andothers}} +\fi% +\iftoggle{bbx:gbnoothers}{}% + {\usebibmacro{name:andothers}}% +} \DeclareNameAlias{default}{namefmtselected}%姓名的默认格式采用可选的模式 \DeclareNameAlias{sortname}{default}% Used in the bibliography %family-given/given-family diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.cbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.cbx index 1beb8d05ca..e7d16c09b4 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.cbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.cbx @@ -7,7 +7,7 @@ %% Released under the LaTeX Project Public License v1.3c or later %% --------------------------------------------------------------- %% -\ProvidesFile{gb7714-2015.cbx}[a biblatex citation style for GB/T 7714-2015] +\ProvidesFile{gb7714-2015mx.cbx}[a biblatex citation style for GB/T 7714-2015] % % 加载标准样式 diff --git a/macros/latex/contrib/fontscale/fontscale-manual.pdf b/macros/latex/contrib/fontscale/fontscale-manual.pdf Binary files differindex 99984191ff..e90ca7b92d 100644 --- a/macros/latex/contrib/fontscale/fontscale-manual.pdf +++ b/macros/latex/contrib/fontscale/fontscale-manual.pdf diff --git a/macros/latex/contrib/fontscale/fontscale-manual.tex b/macros/latex/contrib/fontscale/fontscale-manual.tex index 26833d220e..f7d475cd7b 100644 --- a/macros/latex/contrib/fontscale/fontscale-manual.tex +++ b/macros/latex/contrib/fontscale/fontscale-manual.tex @@ -13,7 +13,7 @@ A user interface for setting document font sizes Oliver Beery -Version 1.0.2\quad{}22 March 2024 +Version 1.0.3\quad{}26 March 2024 \section{Introduction} diff --git a/macros/latex/contrib/fontscale/fontscale.sty b/macros/latex/contrib/fontscale/fontscale.sty index ba1ba40b87..3a6d63676a 100644 --- a/macros/latex/contrib/fontscale/fontscale.sty +++ b/macros/latex/contrib/fontscale/fontscale.sty @@ -8,8 +8,8 @@ \NeedsTeXFormat{LaTeX2e}[2022-06-01] \ProvidesExplPackage {fontscale} - {2024-03-22} - {1.0.2} + {2024-03-26} + {1.0.3} {A user interface for setting document font sizes} % The 2023-10-10 l3kernel update added many 'e'-variants. @@ -127,12 +127,11 @@ \tl_new:N \l__fontscale_keys_precompile_preamble_tl % Temporary variables -\seq_new:N \l__fontscale_tmp_seq - -\tl_new:N \l__fontscale_step_tl -\fp_new:N \l__fontscale_step_fp -\tl_new:N \l__fontscale_scale_tl -\dim_new:N \l__fontscale_size_dim +\fp_new:N \l__fontscale_step_fp +\tl_new:N \l__fontscale_step_tl +\tl_new:N \l__fontscale_scale_tl +\dim_new:N \l__fontscale_size_dim +\skip_new:N \l__fontscale_baselineskip_skip % INITIAL FONT PARAMETERS @@ -415,43 +414,43 @@ } \keys_define:nn { fontscale } { - tiny .code:n = \__fontscale_keys_name_fn:n {#1} + tiny .code:n = \__fontscale_keys_name_code:n {#1} , tiny .value_required:n = true - , scriptsize .code:n = \__fontscale_keys_name_fn:n {#1} + , scriptsize .code:n = \__fontscale_keys_name_code:n {#1} , scriptsize .value_required:n = true - , footnotesize .code:n = \__fontscale_keys_name_fn:n {#1} + , footnotesize .code:n = \__fontscale_keys_name_code:n {#1} , footnotesize .value_required:n = true - , small .code:n = \__fontscale_keys_name_fn:n {#1} + , small .code:n = \__fontscale_keys_name_code:n {#1} , small .value_required:n = true - , normalsize .code:n = \__fontscale_keys_name_fn:n {#1} + , normalsize .code:n = \__fontscale_keys_name_code:n {#1} , normalsize .value_required:n = true - , large .code:n = \__fontscale_keys_name_fn:n {#1} + , large .code:n = \__fontscale_keys_name_code:n {#1} , large .value_required:n = true - , Large .code:n = \__fontscale_keys_name_fn:n {#1} + , Large .code:n = \__fontscale_keys_name_code:n {#1} , Large .value_required:n = true - , LARGE .code:n = \__fontscale_keys_name_fn:n {#1} + , LARGE .code:n = \__fontscale_keys_name_code:n {#1} , LARGE .value_required:n = true - , huge .code:n = \__fontscale_keys_name_fn:n {#1} + , huge .code:n = \__fontscale_keys_name_code:n {#1} , huge .value_required:n = true - , Huge .code:n = \__fontscale_keys_name_fn:n {#1} + , Huge .code:n = \__fontscale_keys_name_code:n {#1} , Huge .value_required:n = true } -\cs_new_protected:Npn \__fontscale_keys_name_fn:n #1 +\cs_new_protected:Npn \__fontscale_keys_name_code:n #1 { \str_if_in:nnTF {#1} { / } - { \__fontscale_keys_name_fn_split:ww #1 \q_stop } + { \__fontscale_keys_name_code_split:ww #1 \q_stop } { \tl_set:cn { l__fontscale_ \l_keys_key_str _size_tl } {#1} } } -\cs_new_protected:Npn \__fontscale_keys_name_fn_split:ww #1 / #2 \q_stop +\cs_new_protected:Npn \__fontscale_keys_name_code_split:ww #1 / #2 \q_stop { \tl_set:cn { l__fontscale_ \l_keys_key_str _size _tl } {#1} \tl_set:cn { l__fontscale_ \l_keys_key_str _baselineskip_tl } {#2} @@ -601,6 +600,7 @@ { \__fontscale_keys_process_normalsize: \__fontscale_keys_process_other: + \__fontscale_keys_process_other_props: \__fontscale_keys_process_check_order: } % Sets the size and baselineskip of \normalsize, stores them in a property @@ -791,14 +791,67 @@ { l_fontscale_##1_baselineskip_skip } { \use:c { l__fontscale_##1_baselineskip_tl } } } - \prop_put:cne { l_fontscale_##1_prop } { scale } - { \fp_use:c { l_fontscale_##1_scale_fp } } - \prop_put:cne { l_fontscale_##1_prop } { size } - { \dim_use:c { l_fontscale_##1_size_dim } } - \prop_put:cne { l_fontscale_##1_prop } { baselineskip } - { \skip_use:c { l_fontscale_##1_baselineskip_skip } } } } +\cs_new_protected:Npn \__fontscale_keys_process_other_props: + { + \prop_put:Nne \l_fontscale_tiny_prop { scale } + { \fp_use:N \l_fontscale_tiny_scale_fp } + \prop_put:Nne \l_fontscale_scriptsize_prop { scale } + { \fp_use:N \l_fontscale_scriptsize_scale_fp } + \prop_put:Nne \l_fontscale_footnotesize_prop { scale } + { \fp_use:N \l_fontscale_footnotesize_scale_fp } + \prop_put:Nne \l_fontscale_small_prop { scale } + { \fp_use:N \l_fontscale_small_scale_fp } + \prop_put:Nne \l_fontscale_large_prop { scale } + { \fp_use:N \l_fontscale_large_scale_fp } + \prop_put:Nne \l_fontscale_Large_prop { scale } + { \fp_use:N \l_fontscale_Large_scale_fp } + \prop_put:Nne \l_fontscale_LARGE_prop { scale } + { \fp_use:N \l_fontscale_LARGE_scale_fp } + \prop_put:Nne \l_fontscale_huge_prop { scale } + { \fp_use:N \l_fontscale_huge_scale_fp } + \prop_put:Nne \l_fontscale_Huge_prop { scale } + { \fp_use:N \l_fontscale_Huge_scale_fp } + + \prop_put:Nno \l_fontscale_tiny_prop { size } + { \dim_use:N \l_fontscale_tiny_size_dim } + \prop_put:Nno \l_fontscale_scriptsize_prop { size } + { \dim_use:N \l_fontscale_scriptsize_size_dim } + \prop_put:Nno \l_fontscale_footnotesize_prop { size } + { \dim_use:N \l_fontscale_footnotesize_size_dim } + \prop_put:Nno \l_fontscale_small_prop { size } + { \dim_use:N \l_fontscale_small_size_dim } + \prop_put:Nno \l_fontscale_large_prop { size } + { \dim_use:N \l_fontscale_large_size_dim } + \prop_put:Nno \l_fontscale_Large_prop { size } + { \dim_use:N \l_fontscale_Large_size_dim } + \prop_put:Nno \l_fontscale_LARGE_prop { size } + { \dim_use:N \l_fontscale_LARGE_size_dim } + \prop_put:Nno \l_fontscale_huge_prop { size } + { \dim_use:N \l_fontscale_huge_size_dim } + \prop_put:Nno \l_fontscale_Huge_prop { size } + { \dim_use:N \l_fontscale_Huge_size_dim } + + \prop_put:Nno \l_fontscale_tiny_prop { baselineskip } + { \skip_use:N \l_fontscale_tiny_baselineskip_skip } + \prop_put:Nno \l_fontscale_scriptsize_prop { baselineskip } + { \skip_use:N \l_fontscale_scriptsize_baselineskip_skip } + \prop_put:Nno \l_fontscale_footnotesize_prop { baselineskip } + { \skip_use:N \l_fontscale_footnotesize_baselineskip_skip } + \prop_put:Nno \l_fontscale_small_prop { baselineskip } + { \skip_use:N \l_fontscale_small_baselineskip_skip } + \prop_put:Nno \l_fontscale_large_prop { baselineskip } + { \skip_use:N \l_fontscale_large_baselineskip_skip } + \prop_put:Nno \l_fontscale_Large_prop { baselineskip } + { \skip_use:N \l_fontscale_Large_baselineskip_skip } + \prop_put:Nno \l_fontscale_LARGE_prop { baselineskip } + { \skip_use:N \l_fontscale_LARGE_baselineskip_skip } + \prop_put:Nno \l_fontscale_huge_prop { baselineskip } + { \skip_use:N \l_fontscale_huge_baselineskip_skip } + \prop_put:Nno \l_fontscale_Huge_prop { baselineskip } + { \skip_use:N \l_fontscale_Huge_baselineskip_skip } + } % Issues a warning if the font sizes or font baselineskips are not in the % correct order. \cs_new_protected:Npn \__fontscale_keys_process_check_order: @@ -961,23 +1014,15 @@ \cs_new:Npn \__fontscale_current_font_baselineskip: { \f@baselineskip } \NewDocumentCommand \SetFontStep { s m } - { \__fontscale_set_font_step:Nn #1 {#2} } -\cs_new_protected:Npn \__fontscale_set_font_step:Nn #1#2 { - \bool_if:NTF #1 - { - \tl_set:Ne \l__fontscale_step_tl { \__fontscale_current_font_step: } - \tl_if_empty:NTF \l__fontscale_step_tl - { \msg_error:nn { fontscale } { font-step-out-of-bounds } } - { - \fp_set:Nn \l__fontscale_step_fp { (#2) + \l__fontscale_step_tl } - \__fontscale_set_font_step_aux:N \l__fontscale_step_fp - } - } - { - \fp_set:Nn \l__fontscale_step_fp {#2} - \__fontscale_set_font_step_aux:N \l__fontscale_step_fp - } + \IfBooleanTF #1 + { \__fontscale_add_font_step:n {#2} } + { \__fontscale_set_font_step:n {#2} } + } +\cs_new_protected:Npn \__fontscale_set_font_step:n #1 + { + \fp_set:Nn \l__fontscale_step_fp {#1} + \__fontscale_set_font_step_aux:N \l__fontscale_step_fp } \cs_new_protected:Npn \__fontscale_set_font_step_aux:N #1 { @@ -1001,7 +1046,7 @@ { \fontsize { - \fp_eval:n + \fp_to_dim:n { \l__fontscale_normalsize_size_fp * \l__fontscale_modular_ratio_fp ^ #1 @@ -1012,7 +1057,7 @@ { \fontsize { - \fp_eval:n + \fp_to_dim:n { \l__fontscale_normalsize_size_fp * \l__fontscale_musical_ratio_fp @@ -1023,36 +1068,66 @@ } { { - \fp_eval:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } + \fp_to_dim:n + { \f@size * \l__fontscale_baselineskip_size_ratio_fp } } \selectfont } { \msg_error:nn { fontscale } { font-step-out-of-bounds } } } } +\cs_new_protected:Npn \__fontscale_add_font_step:n #1 + { + \tl_set:Ne \l__fontscale_step_tl { \__fontscale_current_font_step: } + \tl_if_empty:NTF \l__fontscale_step_tl + { \msg_error:nn { fontscale } { font-step-out-of-bounds } } + { + \fp_set:Nn \l__fontscale_step_fp { (#1) + \l__fontscale_step_tl } + \__fontscale_add_font_step_aux:N \l__fontscale_step_fp + } + } +\cs_new_eq:NN \__fontscale_add_font_step_aux:N \__fontscale_set_font_step_aux:N \NewDocumentCommand \SetFontScale { s m } - { \__fontscale_set_font_scale:Nn #1 {#2} } -\cs_new_protected:Npn \__fontscale_set_font_scale:Nn #1#2 { - \dim_set:Nn \l__fontscale_size_dim - { \fp_to_dim:n { \l__fontscale_normalsize_size_fp * (#2) } } - \bool_if:NT #1 - { \dim_add:Nn \l__fontscale_size_dim { \f@size pt } } - \fontsize \l__fontscale_size_dim - { \fp_eval:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } } + \IfBooleanTF #1 + { \__fontscale_add_font_scale:n {#2} } + { \__fontscale_set_font_scale:n {#2} } + } +\cs_new_protected:Npn \__fontscale_set_font_scale:n #1 + { + \fontsize + { \fp_to_dim:n { \l__fontscale_normalsize_size_fp * (#1) } } + { \fp_to_dim:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } } + \selectfont + } +\cs_new_protected:Npn \__fontscale_add_font_scale:n #1 + { + \fontsize + { \fp_to_dim:n { \l__fontscale_normalsize_size_fp * (#1) + \f@size } } + { \fp_to_dim:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } } \selectfont } \NewDocumentCommand \SetFontSize { s m } - { \__fontscale_set_font_size:Nn #1 {#2} } -\cs_new_protected:Npn \__fontscale_set_font_size:Nn #1#2 { - \__fontscale_dim_set_with_default_unit:Nn \l__fontscale_size_dim {#2} - \bool_if:NT #1 - { \dim_add:Nn \l__fontscale_size_dim { \f@size pt } } + \IfBooleanTF #1 + { \__fontscale_add_font_size:n {#2} } + { \__fontscale_set_font_size:n {#2} } + } +\cs_new_protected:Npn \__fontscale_set_font_size:n #1 + { + \__fontscale_dim_set_with_default_unit:Nn \l__fontscale_size_dim {#1} + \fontsize \l__fontscale_size_dim + { \fp_to_dim:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } } + \selectfont + } +\cs_new_protected:Npn \__fontscale_add_font_size:n #1 + { + \__fontscale_dim_set_with_default_unit:Nn \l__fontscale_size_dim {#1} + \dim_add:Nn \l__fontscale_size_dim { \f@size pt } \fontsize \l__fontscale_size_dim - { \fp_eval:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } } + { \fp_to_dim:n { \f@size * \l__fontscale_baselineskip_size_ratio_fp } } \selectfont } @@ -1060,15 +1135,21 @@ \cs_new_protected:Npn \__fontscale_scalefont:n #1 { \fontsize - { \fp_eval:n { \f@size * (#1) } } - { \fp_eval:n { \dim_to_fp:n { \f@baselineskip } * (#1) } } + { \fp_to_dim:n { \f@size * (#1) } } + { \fp_to_dim:n { \dim_to_fp:n { \f@baselineskip } * (#1) } } \selectfont } \NewDocumentCommand \SetFontSizeBaselineskip { m m } { \__fontscale_set_font_size_baselineskip:nn {#1} {#2} } \cs_new_protected:Npn \__fontscale_set_font_size_baselineskip:nn #1#2 - { \exp_args:Nee \fontsize {#1} {#2} \selectfont } + { + \__fontscale_dim_set_with_default_unit:Nn \l__fontscale_size_dim {#1} + \__fontscale_skip_set_with_default_unit:Nn \l__fontscale_baselineskip_skip + {#2} + \fontsize \l__fontscale_size_dim \l__fontscale_baselineskip_skip + \selectfont + } \NewDocumentCommand \PrintFontParameters { } { \__fontscale_print_font_parameters: } @@ -1104,19 +1185,36 @@ A~ user~ interface~ for~ setting~ document~ font~ sizes } } - { \__fontscale_print_sample_text:Nn #1 {#2} } -\cs_new_protected:Npn \__fontscale_print_sample_text:Nn #1#2 { - \seq_set_eq:NN \l__fontscale_tmp_seq \c__fontscale_names_seq - \bool_if:NT #1 { \seq_reverse:N \l__fontscale_tmp_seq } - \seq_map_inline:Nn \l__fontscale_tmp_seq - { - \group_begin: - \use:c {##1} - #2 - \par - \group_end: - } + \IfBooleanTF #1 + { \__fontscale_print_sample_text_descending_order:n {#2} } + { \__fontscale_print_sample_text_ascending_order:n {#2} } + } +\cs_new_protected:Npn \__fontscale_print_sample_text_ascending_order:n #1 + { + { \tiny #1 \par } + { \scriptsize #1 \par } + { \footnotesize #1 \par } + { \small #1 \par } + { \normalsize #1 \par } + { \large #1 \par } + { \Large #1 \par } + { \LARGE #1 \par } + { \huge #1 \par } + { \Huge #1 \par } + } +\cs_new_protected:Npn \__fontscale_print_sample_text_descending_order:n #1 + { + { \Huge #1 \par } + { \huge #1 \par } + { \LARGE #1 \par } + { \Large #1 \par } + { \large #1 \par } + { \normalsize #1 \par } + { \small #1 \par } + { \footnotesize #1 \par } + { \scriptsize #1 \par } + { \tiny #1 \par } } \NewDocumentCommand \PrintFontSizeCommand { } { \__fontscale_print_name: } diff --git a/macros/latex/contrib/profmaquette/doc/ProfMaquette-doc.pdf b/macros/latex/contrib/profmaquette/doc/ProfMaquette-doc.pdf Binary files differindex a4382edbdf..d78fcc96d2 100644 --- a/macros/latex/contrib/profmaquette/doc/ProfMaquette-doc.pdf +++ b/macros/latex/contrib/profmaquette/doc/ProfMaquette-doc.pdf diff --git a/macros/latex/contrib/profmaquette/latex/ProfMaquette.sty b/macros/latex/contrib/profmaquette/latex/ProfMaquette.sty index a9131f1115..da9aafbfe0 100644 --- a/macros/latex/contrib/profmaquette/latex/ProfMaquette.sty +++ b/macros/latex/contrib/profmaquette/latex/ProfMaquette.sty @@ -2,9 +2,9 @@ % licence : Released under the LaTeX Project Public License v1.3c % or later, see http://www.latex-project.org/lppl.txtf \NeedsTeXFormat{LaTeX2e}% -\def\filedate{2024/03/24}% +\def\filedate{2024/03/26}% \let\PfMfiledate\filedate% -\def\fileversion{0.89}% +\def\fileversion{0.90}% \let\PfMfileversion\fileversion% \ProvidesPackage{ProfMaquette}[\filedate\space v\fileversion\space Maquettage de documents]% @@ -196,13 +196,14 @@ } } -\NewDocumentEnvironment{Consignes}{+b}{% +\NewDocumentEnvironment{Consignes}{}{% \ifboolKV[Boulot]{CAN}{}{% \begin{tcolorbox}[consignes]% - \small\sffamily #1 - \end{tcolorbox}% + \small\sffamily }% -}{}% +}{% +\end{tcolorbox}% +}% %% Option french pour les mathématiques % By CT @@ -2248,7 +2249,7 @@ \fi% }% -\NewDocumentEnvironment{exerciceFiche}{so+b}{% +\NewDocumentEnvironment{exerciceFiche}{so}{% \setcounter{PfMAlea}{0}% \setcounter{PfMNbLogo}{1}% \useKVdefault[ClesExercices]% @@ -2277,13 +2278,15 @@ label=page-\thePfMMaquette-\thePfMExo ] \ifboolKV[Boulot]{Dys}{\raggedright}{}% - #3 - \end{tcolorbox}% - \ifboolKV[ClesExercices]{Profile}{\PfMshowitems}{}% - \PfMApresLesExercices% - }% + }% + }% + }{% + \ifboolKV[ClesExercices]{NonUtilise}{}{% + \end{tcolorbox}% + \ifboolKV[ClesExercices]{Profile}{\PfMshowitems}{}% + \PfMApresLesExercices% } -}{} +}% \NewDocumentEnvironment{exerciceDS}{so}{% \setcounter{PfMAlea}{0}% @@ -2321,7 +2324,7 @@ \PfMApresLesExercices% }% -\NewDocumentEnvironment{ExerciceRecapBrevet}{so+b}{% +\NewDocumentEnvironment{ExerciceRecapBrevet}{so}{% \setcounter{PfMAlea}{0}% \useKVdefault[ClesExercices]% \setKV[ClesExercices]{#2}% @@ -2345,10 +2348,10 @@ label=page-\thePfMMaquette-\thePfMExo ] \ifboolKV[Boulot]{Dys}{\raggedright}{}% - #3 + }{% \end{tcolorbox} \PfMApresLesExercices% -}{}% +}% \makeatother %%% Recap Brevet @@ -4138,7 +4141,7 @@ \dispo{1}{#2}{#3} }% \fi% -}% +}{}% \NewDocumentEnvironment{CALign}{O{&=\dots&}O{&=\dots}mb}{% % #1 séparateur généraliste diff --git a/macros/latex/contrib/reptheorem/README.md b/macros/latex/contrib/reptheorem/README.md new file mode 100644 index 0000000000..f084c0692a --- /dev/null +++ b/macros/latex/contrib/reptheorem/README.md @@ -0,0 +1,40 @@ +# `reptheorem` + +When writing a large manuscript, it is sometimes +beneficial to repeat a theorem (or lemma or…) at +an earlier or later point for didactical purposes. +However, `thmtools`'s built-in `restatable` +only allows replicating theorems *after* they +have been stated, and only in the same document. +`reptheorem` solves the issue by making use +of the `.aux` file, and also introduces its own file +extension, `.thm`, to replicate theorems in other files. + +# Installation +Run the following in the command line: +1. If reptheorem.ins is present: +`latex reptheorem.ins` +2. If reptheorem.ins is absent: +`latex reptheorem.dtx` + +Move `reptheorem.sty` to a folder that TeX can find. + +# Documentation +Run the following in the command line: +``` +pdflatex reptheorem.dtx +makeindex -s gind.ist -o reptheorem.ind reptheorem.idx +makeindex -s gglo.ist -o reptheorem.gls reptheorem.glo +pdflatex reptheorem.dtx +``` +This automatically unpacks the package, as well. + +--- + +© 2024- Jesse Straat + +License: [LPPL1.3c](https://www.latex-project.org/lppl.txt) + +[GitHub Repository](https://github.com/JesseStraat/reptheorem) + + diff --git a/macros/latex/contrib/reptheorem/reptheorem.dtx b/macros/latex/contrib/reptheorem/reptheorem.dtx new file mode 100644 index 0000000000..d96f740fec --- /dev/null +++ b/macros/latex/contrib/reptheorem/reptheorem.dtx @@ -0,0 +1,486 @@ +% \iffalse meta-comment +% +% Copyright (c) 2024- Jesse Straat +% +% This work 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 +% https://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2008 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Jesse Sraat. +% +% This work consists of the main file reptheorem.dtx +% and the derived files +% reptheorem.sty, reptheorem.pdf, reptheorem.ins +% +% Unpacking: +% (a) If reptheorem.ins is present: +% latex reptheorem.ins +% (b) If reptheorem.ins is absent: +% latex reptheorem.dtx +% +% Documentation: +% pdflatex reptheorem.dtx +% makeindex -s gind.ist -o reptheorem.ind reptheorem.idx +% makeindex -s gglo.ist -o reptheorem.gls reptheorem.glo +% pdflatex reptheorem.dtx +% dtx file based on https://www.texdev.net/2009/10/06/a-model-dtx-file/ +% +%<*ignore> +\iffalse +%</ignore> +% +%<*readme> +# `reptheorem` + +When writing a large manuscript, it is sometimes +beneficial to repeat a theorem (or lemma or…) at +an earlier or later point for didactical purposes. +However, `thmtools`'s built-in `restatable` +only allows replicating theorems *after* they +have been stated, and only in the same document. +`reptheorem` solves the issue by making use +of the `.aux` file, and also introduces its own file +extension, `.thm`, to replicate theorems in other files. + +# Installation +Run the following in the command line: +1. If reptheorem.ins is present: + `latex reptheorem.ins` +2. If reptheorem.ins is absent: + `latex reptheorem.dtx` + +Move `reptheorem.sty` to a folder that TeX can find. + +# Documentation +Run the following in the command line: +``` +pdflatex reptheorem.dtx +makeindex -s gind.ist -o reptheorem.ind reptheorem.idx +makeindex -s gglo.ist -o reptheorem.gls reptheorem.glo +pdflatex reptheorem.dtx +``` +This automatically unpacks the package, as well. + +--- + +© 2024- Jesse Straat + +License: [LPPL1.3c](https://www.latex-project.org/lppl.txt) + +[GitHub Repository](https://github.com/JesseStraat/reptheorem) + +%</readme> +% +%<*ignore> +\fi +\def\plainTeXstring{plain} +\ifx\fmtname\plainTeXstring\else + \expandafter\begingroup +\fi +%</ignore> +% +%<*install> +\input docstrip.tex +\Msg{************************************************************************} +\Msg{* Installation} +\Msg{* Package: reptheorem 2024-03-27 v1.0} +\Msg{************************************************************************} + +\keepsilent +\askforoverwritefalse + +\preamble + +Copyright (c) 2024- Jesse Straat + +This work 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 + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2008 or later. + +This work has the LPPL maintenance status `maintained'. + +The Current Maintainer of this work is Jesse Sraat. + +This work consists of the main file reptheorem.dtx +and the derived files + reptheorem.sty, reptheorem.pdf, reptheorem.ins + +\endpreamble + +\usedir{tex/latex/reptheorem} +\generate{ + \file{\jobname.sty}{\from{\jobname.dtx}{package}} +} + +\obeyspaces +\Msg{************************************************************************} +\Msg{*} +\Msg{* To finish the installation you have to move the following} +\Msg{* file into a directory searched by TeX:} +\Msg{*} +\Msg{* repthm.sty} +\Msg{*} +\Msg{* To produce the documentation run the file `reptheorem.dtx'} +\Msg{* through LaTeX.} +\Msg{*} +\Msg{* Happy TeXing!} +\Msg{*} +\Msg{************************************************************************} + +%</install> +%<install>\endbatchfile +% +%<*ignore> +\usedir{source/latex/reptheorem} +\generate{ + \file{\jobname.ins}{\from{\jobname.dtx}{install}} +} + +\nopreamble\nopostamble +\usedir{doc/latex/reptheorem} +\generate{ + \file{README.md}{\from{\jobname.dtx}{readme}} +} + +\ifx\fmtname\plainTeXstring + \expandafter\endbatchfile +\else + \expandafter\endgroup +\fi +%</ignore> + +%<*driver> +\NeedsTeXFormat{LaTeX2e} +\documentclass{ltxdoc} +\usepackage{\jobname} +\usepackage{amsthm} +\newtheorem{theorem}{Theorem} +\usepackage[final, +hyperindex=false, +colorlinks, +]{hyperref} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +% \GetFileInfo{\jobname.sty} +% +% \DoNotIndex{\begin,\end,\begingroup,\endgroup,\csname,\endcsname,\ifcsname,\if,\else,\IfFileExists,\IfValueTF,\fi} +% \DoNotIndex{\def,\edef,\expandafter,\gdef} +% \DoNotIndex{\immediate,\input} +% \DoNotIndex{\jobname,\label,\let,\long,\newcounter,\NewDocumentCommand} +% \DoNotIndex{\NewDocumentEnvironment,\noexpand} +% \DoNotIndex{\ProvidesPackage,\ref,\relax,\setcounter} +% \DoNotIndex{\string,\value,\write} +% +% \title{^^A +% \textsf{reptheorem}\thanks{^^A +% Version \fileversion, last revised \filedate.^^A +% }^^A +% }^^A +% \author{^^A +% Jesse Straat^^A +% } +% \date{\filedate} +% +% \maketitle +% +% \begin{abstract} +% \noindent When writing a large manuscript, it is sometimes +% beneficial to repeat a theorem (or lemma or \dots) at +% an earlier or later point for didactical purposes. +% However, \textsf{thmtools}'s built-in |restatable| +% only allows replicating theorems \textit{after} they +% have been stated, and only in the same document. +% \textsf{reptheorem} solves the issue by making use +% of the |.aux| file, and also introduces its own file +% extension, |.thm|, to replicate theorems in other files. +% \end{abstract} +% +% \tableofcontents +% +%\changes{v1.0}{2024-03-27}{First public release} +% +% +% +%\StopEventually{^^A +% \PrintChanges +% \PrintIndex +%} +% +% +% +% +% \section{Repeating theorems} +% Let's say we define a theorem as follows: +% \begin{verbatim} +% \begin{theorem}[Yoneda Lemma] +% For \(F\colon \mathcal{C}\to \mathbf{Set}\) a functor, +% \([\mathcal{C}^\mathrm{op},\mathbf{Set}](YA, F) \cong F(A)\)% +% for all objects \(A\) in \(\mathcal{C}\). +% \end{theorem} +% \end{verbatim} +% Its output is of course +% \begin{makethm}{theorem}{thm:Yoneda}[Yoneda Lemma] +% For \(F\colon \mathcal{C}\to \mathbf{Set}\) a functor, +% \([\mathcal{C}^\mathrm{op},\mathbf{Set}](YA, F) \cong F(A)\) +% for all objects \(A\) in \(\mathcal{C}\). +% \end{makethm} +% Now let's say we want to replicate the theorem +% within the same document. That is what the new +% environment \DescribeEnv{makethm} |makethm| is +% used for. +% \begin{verbatim} +% \begin{makethm}{theorem}{thm:Yoneda}[Yoneda Lemma]{ +% For \(F\colon \mathcal{C}\to \mathbf{Set}\) a functor, +% \([\mathcal{C}^\mathrm{op},\mathbf{Set}](YA, F) \cong F(A)\)% +% for all objects \(A\) in \(\mathcal{C}\). +% \end{makethm} +% \end{verbatim} +% Its output is the same (in fact, we've secretly used +% |makethm| in the previous example), but the important +% difference is that we have saved the theorem for later use.\par +% The |makethm| environment takes two mandatory arguments +% and one optional one. The first mandatory argument is the +% type of theorem environment, like |theorem|, |lemma|, +% |definition|, etc. The second is the theorem's label. +% The label is mandatory because to replicate the theorem, +% we need to have a ``name'' attached to it. |makethm| +% automatically attaches a |\label|, as well, so |\ref{thm:Yoneda}| +% becomes \ref{thm:Yoneda}. The optional argument is passed +% right to the optional argument of the theorem environment, +% giving the name of a theorem\par +% +% Now let's say we want to replicate the theorem later +% or earlier in the text. This may be done if, for example, +% the theorem is proven at a later point, or we want to +% ``tease'' the reader with a powerful theorem that will be +% proven later in the chapter. To do this, we use the +% \DescribeMacro{repthm} command, as follows. +% \begin{verbatim} +% \repthm{theorem}{thm:Yoneda} +% \end{verbatim} +% This outputs the theorem again. +% \repthm{theorem}{thm:Yoneda} +% The label of this theorem is a |\ref|, and automatically +% links to the original theorem statement.\par +% If the original theorem statement exists in a different +% file, or has not been created yet, we can add a placeholder +% alt text to the |\repthm| as an optional argument, which +% only displays if the theorem is undefined. For example, +% |\repthm{theorem}{thm:foo}[bar]| returns +% \repthm{theorem}{thm:foo}[bar] +% If we do the same without providing an alt text, we get +% \repthm{theorem}{thm:foo} +% together with a warning.\par +% Since we're using the |.aux| file, it is possible +% to replicate a theorem before it is stated. For example, +% \begin{verbatim} +% \repthm{theorem}{thm:later} +% \begin{makethm}{theorem}{thm:later}[Later] +% Alligator! +% \end{makethm} +% \end{verbatim} +% returns +% \repthm{theorem}{thm:later} +% \begin{makethm}{theorem}{thm:later}[Later] +% Alligator +% \end{makethm} +% Note that it is necessary to run a |.tex| file twice +% to replicate theorems ahead of time, similarly to +% how one has to run a file twice to make sure the +% references are correct.\par +% +% \section{Replicating theorems between files} +% Let's say we have the following files for our project: +% \begin{verbatim} +% foo.tex +% bar.tex +% \end{verbatim} +% Let's say that we have defined a theorem |thm:baz| +% in |bar.tex|, and we want to replicate it in |foo.tex|. +% To achieve this, we first use the \DescribeMacro{\theoremfile} +% |\theoremfile| command in the preamble of |bar.tex|. This +% compiles all theorems defined in |bar.tex| and outputs them +% into a file |bar.thm|. To then import these into |foo.tex|, we +% use \DescribeMacro{\loadtheorems} |\loadtheorems{bar.thm}| in +% the preamble, which loads all theorems saved in |bar.thm|. +% One can then use |\repthm| as usual.\par +% Since the |.aux| file is loaded at |\begin{document}|, putting +% |\loadtheorems| in the preamble of a file will guarantee that +% the loaded theorem file will be overwritten by the theorems in +% the |.aux| file, i.e., theorems defined in the same document. +% In our example, if we also defined a |thm:baz| in |foo.tex|, +% loading |bar.thm| into |foo.tex| will not overwrite the local +% |thm:baz|. +% +% \subsection{Replicating theorems to subfiles} +% Replicating theorems to different files is particularly +% useful when working in big documents with multiple subfiles. +% For example, let's say we have the files +% \begin{verbatim} +% main.tex +% foo.tex +% bar.tex +% \end{verbatim} +% Here, |main.tex| is generated by including |foo.tex| +% and |bar.tex| as chapters, creating a single large document. +% It is now possible to replicate theorems within the +% subfiles by running |\theoremfile| in |main.tex|, +% and then using |\loadtheorems{main.thm}| in +% |foo.tex| and |bar.tex|. This will allow us to +% use all theorems in the final |main.tex| in each of +% the subfiles. +% +% +% +% \section{Source code} +% \begin{macrocode} +%<*package> +\ProvidesPackage{reptheorem}[2024-03-27 v1.0 Reptheorem package] +% \end{macrocode} +% +% \begin{macro}{\theoremfile} +% Using |\theoremfile| will output all saved theorems into an output file. +% By default, if your \LaTeX file is |foo.tex|, the output file is |foo.thm|. +% \begin{macrocode} +\def\reptheorem@theoremfile{\relax} +\NewDocumentCommand{\theoremfile}{ O{\jobname.thm} }{ + % O: the path of the file to which we should save theorems + % + \def\reptheorem@theoremfile{#1} + \newwrite\@thmlist + \immediate\openout\@thmlist=#1 +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\loadtheorems} +% If you have exported saved theorems to a file, you can load them +% into another file using the macro |\loadtheorems|. +% \begin{macrocode} +\NewDocumentCommand{\loadtheorems}{ m }{ + \IfFileExists{#1}{ + \input{#1} + }{ + \PackageWarning{reptheorem}{% + File #1 not found. I will not import any theorems.% + } + } +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{makethm} +% On to defining the actual theorems to be saved. +% \begin{macrocode} +\NewDocumentEnvironment{makethm}{ m m o +b } + % m: the type of theorem environment + % m: the name of the theorem + % o: optional parameter for environment + % b: the content of the theorem + % + {% + \IfValueTF{#3}{% Check if theorem has optional arguments + \begin{#1}[#3]\label{#2} + }{ + \begin{#1}\label{#2} + } + #4 + \end{#1} + \expandafter\long\expandafter\gdef\csname thm@#2\endcsname{#4}% + \expandafter\gdef\csname thmdesc@#2\endcsname{#3}% + % Saving parameters to aux file + \long\gdef\@thmoutput{% + \string\expandafter\string\long\string\expandafter% + \string\gdef\noexpand\csname thm@#2\string\endcsname{#4}% + ^^J% + \string\expandafter\string\expandafter% + \string\gdef\noexpand\csname thmdesc@#2\string\endcsname{#3}% + } + \write\@auxout{\@thmoutput} + \if\reptheorem@theoremfile\relax + % No file has been set + \else + % We have a theorem file + % Saving parameters to theorem file + \write\@thmlist{\@thmoutput} + \fi + }{} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\repthm} +% To repeat a theorem, use the |\repthm| command. +% The type of theorem is not saved, so it is necessary to +% respecify it each time a theorem is repeated. +% \begin{macrocode} +\newcounter{old@counter} +\NewDocumentCommand{\repthm}{ m m +o }{ + % m: the type of theorem environment + % m: the name of the theorem + % o: alt text + \begingroup + \setcounter{old@counter}{\value{#1}} + % Save theorem counter so we don't increase it + \def\thetheorem{\ref{#2}} + \let\@@theoremnotdefined\relax + % + \ifcsname thm@#2\endcsname% Check if theorem is even defined + % Theorem is defined + \expandafter\edef\expandafter\@@thmdesc{\csname thmdesc@#2\endcsname}% + \expandafter\let\expandafter\@@thm\csname thm@#2\endcsname + % Output theorem + \IfValueTF{\@@thmdesc}{% Check if theorem has name + \begin{#1}[\@@thmdesc] + \@@thm + \end{#1} + }{% No optionals + \begin{#1} + \@@thm + \end{#1} + } + \else + % Theorem undefined + \IfValueTF{#3}{ + \begin{#1} + #3 + \end{#1} + }{% No theorem or alt text provided: throw warning + \begin{#1} + \end{#1} + \PackageWarning{reptheorem}{% + Theorem #2 not defined; rebuild your project. + If the issue persists, create the theorem using + \begin{makethm} or consider adding alt text to \repthm + using the optional parameter% + } + } + \fi + \setcounter{#1}{\value{old@counter}} + % Reset theorem counter back to original + \endgroup +} +% \end{macrocode} +% \end{macro} + + +% \begin{macrocode} +%</package> +% \end{macrocode} +%\Finale diff --git a/macros/latex/contrib/reptheorem/reptheorem.ins b/macros/latex/contrib/reptheorem/reptheorem.ins new file mode 100644 index 0000000000..c85a0d2ff3 --- /dev/null +++ b/macros/latex/contrib/reptheorem/reptheorem.ins @@ -0,0 +1,82 @@ +%% +%% This is file `reptheorem.ins', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% reptheorem.dtx (with options: `install') +%% +%% Copyright (c) 2024- Jesse Straat +%% +%% This work 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 +%% https://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2008 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Jesse Sraat. +%% +%% This work consists of the main file reptheorem.dtx +%% and the derived files +%% reptheorem.sty, reptheorem.pdf, reptheorem.ins +%% +\input docstrip.tex +\Msg{************************************************************************} +\Msg{* Installation} +\Msg{* Package: reptheorem 2024-03-27 v1.0} +\Msg{************************************************************************} + +\keepsilent +\askforoverwritefalse + +\preamble + +Copyright (c) 2024- Jesse Straat + +This work 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 + https://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2008 or later. + +This work has the LPPL maintenance status `maintained'. + +The Current Maintainer of this work is Jesse Sraat. + +This work consists of the main file reptheorem.dtx +and the derived files +reptheorem.sty, reptheorem.pdf, reptheorem.ins + +\endpreamble + +\usedir{tex/latex/reptheorem} +\generate{ +\file{\jobname.sty}{\from{\jobname.dtx}{package}} +} + +\obeyspaces +\Msg{************************************************************************} +\Msg{*} +\Msg{* To finish the installation you have to move the following} +\Msg{* file into a directory searched by TeX:} +\Msg{*} +\Msg{* repthm.sty} +\Msg{*} +\Msg{* To produce the documentation run the file `reptheorem.dtx'} +\Msg{* through LaTeX.} +\Msg{*} +\Msg{* Happy TeXing!} +\Msg{*} +\Msg{************************************************************************} + +\endbatchfile + +\endinput +%% +%% End of file `reptheorem.ins'. diff --git a/macros/latex/contrib/reptheorem/reptheorem.pdf b/macros/latex/contrib/reptheorem/reptheorem.pdf Binary files differnew file mode 100644 index 0000000000..31caef6e5d --- /dev/null +++ b/macros/latex/contrib/reptheorem/reptheorem.pdf |