summaryrefslogtreecommitdiff
path: root/macros/latex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-08-17 03:00:52 +0000
committerNorbert Preining <norbert@preining.info>2022-08-17 03:00:52 +0000
commitc384cf2662c6574dc248ae20a9276cacf20320f6 (patch)
tree2a719b425428d6e7de07bde420534be13ea788a2 /macros/latex
parentdeb51d400db4c69df1cef442643a6b94428a2211 (diff)
CTAN sync 202208170300
Diffstat (limited to 'macros/latex')
-rw-r--r--macros/latex/contrib/hereapplies/ChangeLog.md19
-rw-r--r--macros/latex/contrib/hereapplies/README.md82
-rw-r--r--macros/latex/contrib/hereapplies/hereapplies-example.pdfbin49807 -> 50857 bytes
-rw-r--r--macros/latex/contrib/hereapplies/hereapplies-example.tex25
-rw-r--r--macros/latex/contrib/hereapplies/hereapplies.sty269
-rw-r--r--macros/latex/contrib/hereapplies/lyx-module/hereapplies-example.lyx78
-rw-r--r--macros/latex/contrib/hereapplies/lyx-module/hereapplies.module10
-rw-r--r--macros/latex/contrib/hereapplies/package.json2
-rw-r--r--macros/latex/contrib/msu-thesis/README.md2
-rw-r--r--macros/latex/contrib/msu-thesis/msu-thesis.cls12
-rw-r--r--macros/latex/contrib/msu-thesis/msu-thesis.pdfbin250087 -> 253032 bytes
-rw-r--r--macros/latex/contrib/msu-thesis/msu-thesis.tex60
-rw-r--r--macros/latex/contrib/pygmentex/pygmentex.sty22
-rw-r--r--macros/latex/contrib/pygmentex/pygmentex_demo.pdfbin585220 -> 668777 bytes
-rw-r--r--macros/latex/contrib/pygmentex/pygmentex_demo.tex120
-rw-r--r--macros/latex/contrib/pygmentex/pygmentex_demo_2.pdfbin0 -> 37310 bytes
-rw-r--r--macros/latex/contrib/pygmentex/pygmentex_demo_2.tex23
17 files changed, 523 insertions, 201 deletions
diff --git a/macros/latex/contrib/hereapplies/ChangeLog.md b/macros/latex/contrib/hereapplies/ChangeLog.md
index 0835e321b9..7f1fda1e25 100644
--- a/macros/latex/contrib/hereapplies/ChangeLog.md
+++ b/macros/latex/contrib/hereapplies/ChangeLog.md
@@ -2,6 +2,25 @@ Change Log
==========
+## 0.4.0 (2022-08-16)
+
+Changes:
+
+* The `\whereapplies` macro and its starred counterpart now support page ranges
+ and a more robust indexing (a partial rewrite of the code and the addition of
+ the `refcount` dependency were necessary)
+* The LyX module has been updated
+* Documentation
+* Examples
+
+
+## 0.3.1 (2022-08-15)
+
+Changes:
+
+* Documentation
+
+
## 0.3.0 (2022-08-13)
Changes:
diff --git a/macros/latex/contrib/hereapplies/README.md b/macros/latex/contrib/hereapplies/README.md
index 8ffda3cd99..2ef03857e6 100644
--- a/macros/latex/contrib/hereapplies/README.md
+++ b/macros/latex/contrib/hereapplies/README.md
@@ -7,38 +7,43 @@ A LaTeX package for cross-linking concepts to their applications
Overview
--------
-**Here Applies** is a LaTeX package that implements an _informal glossary_. Its
-core mechanism is identical to that of a conventional glossary – i.e. some
-concepts are marked as “important” and indicized every time they appear in the
-document – but it does not produce any nomenclature section, nor relies on the
-conventions that normally take part in a glossary.
-
-In fact, normally, besides an indicization mechanism, a proper glossary should
-be able to produce a dedicated section (usually at the end of the document)
+**Here Applies** is a LaTeX package that implements an _informal glossary_ for
+cross-linking concepts to their applications. Its core mechanism is identical
+to that of a conventional glossary – i.e. some concepts are marked as
+“important” and indicized every time they appear in the document – but it does
+not produce any nomenclature section, nor relies on the conventions that
+normally take part in a glossary.
+
+Besides an indicization mechanism, in fact, a proper glossary should normally
+be able to produce a dedicated section – usually at the end of the document –
where the terms are collected in alphabetical order, their definitions are
-shown, and the lists of their occurrences are presented. By design, all these
-things but the last one are missing in **Here Applies**.
+shown, and the lists of their occurrences are presented. All these things but
+the last one, by design, are missing in **Here Applies**.
Instead, the package offers only two macros: `\hereapplies` and `\whereapplies`
(plus their “starred” versions `\hereapplies*` and `\whereapplies*`). In both
cases a “concept name” is passed as argument – and this can be any string
invented in the moment, as long as it contains only letters.
-Every time `\hereapplies` is invoked again on an identical string the document
-knows that the same concept from previous invocations is occurring at that
-point. And so every time the `\whereapplies` macro is invoked, all the
-occurrences of that concept within the entire document will be printed in the
-form of a linkable page number list (“pp. 1, 2, 3, 4, …”).
+Every time `\hereapplies` is invoked again on an identical string, the document
+is made aware that the same concept from previous invocations is occurring at
+that point. And so, every time the `\whereapplies` macro is invoked on that
+same string, all the occurrences of that concept within the entire document
+will be printed in the form of a linkable page number list (e.g. “pp. 1, 5,
+8–9, 14–20…”).
As `\hereapplies` is designed to be invoked in the middle of a chapter or a
-section and make it linkable, the `\phantomsection` macro is invoked by default
-before a label is added to that place. To avoid calling `\phantomsection`,
-the “starred” macro `\hereapplies*` is available.
+section, and that location must be made linkable, the `\phantomsection` macro
+is invoked by default before a label is added. To avoid calling
+`\phantomsection`, the “starred” macro `\hereapplies*` is available.
Finally, like `\whereapplies` resembles a pluralizable version of `\pageref`,
its “starred” version `\whereapplies*` resembles a pluralizable version of
`\pageref*`.
+If you use LyX, the package ships a LyX module as well (please check the
+`lyx-module` subdirectory).
+
Example usage
-------------
@@ -53,29 +58,34 @@ The following LaTeX manuscript
\begin{document}
\title{Some title}
+
\author{Some author}
\maketitle
-This is concept one. To find this concept applied, please
-see \whereapplies{conceptOne}.
-
-This is concept two. To find this concept applied, please
-see \whereapplies{conceptTwo}.
+This is concept one. To find this concept applied, please see
+\whereapplies{conceptOne}.
-\newpage
+This is concept two. To find this concept applied, please see
+\whereapplies{conceptTwo}.\newpage
\hereapplies{conceptOne}This is page \thepage. As you can see, ``concept
one'' applies here.\newpage
-\hereapplies{conceptTwo}This is page \thepage. As you can see,
-``concept two'' applies here.\newpage
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
\hereapplies{conceptOne}This is page \thepage. As you can see, ``concept
one'' applies here.\newpage
-\hereapplies{conceptTwo}This is page \thepage. As you can see,
-``concept two'' applies here.\newpage
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
+
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
+
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
\hereapplies[myref]{conceptOne}This is page \thepage. As you can
see, ``concept one'' applies here. This point in the document is
@@ -90,27 +100,31 @@ will generate [this document][1].
A minimal tutorial
------------------
-### Macro `\hereapplies[label]{concept_name}`
+### Macro `\hereapplies[Label]{ConceptName}`
The `\hereapplies` macro notifies the document that a particular concept
-applies to a particular point and creates a label for it.
+applies to a particular point and adds a label to it.
If the optional argument is passed the label created will be named accordingly,
otherwise an opaque name will be assigned to it. This argument may contain only
what is legal in both `\label` and `\pageref`.
-The `concept_name` argument may contain only letters and the “at” sign (`@`).
+The `ConceptName` argument may contain only Latin letters and the “at” sign
+(`@`). This string remains confined within the internal scope of the package
+and does not create conflicts with possible macros or labels of the same name.
The “starred” version of this macro (`\hereapplies*`) does not invoke the
`\phantomsection` directive.
-### Macro `\whereapplies{concept_name}`
+### Macro `\whereapplies{ConceptName}`
The `\whereapplies` macro prints all the occurrences of a concept, in the form
-“p. …” or “pp. …”
+“p. …” or “pp. …” (with page range support).
-The `concept_name` argument may contain only letters and the “at” sign (`@`).
+The `ConceptName` argument may contain only Latin letters and the “at” sign
+(`@`). This string remains confined within the internal scope of the package
+and does not create conflicts with possible macros or labels of the same name.
The “starred” version of this macro (`\whereapplies*`) will use `\pageref*`
instead of `\pageref` for generating the page list.
diff --git a/macros/latex/contrib/hereapplies/hereapplies-example.pdf b/macros/latex/contrib/hereapplies/hereapplies-example.pdf
index 7e58c9011e..a6406da256 100644
--- a/macros/latex/contrib/hereapplies/hereapplies-example.pdf
+++ b/macros/latex/contrib/hereapplies/hereapplies-example.pdf
Binary files differ
diff --git a/macros/latex/contrib/hereapplies/hereapplies-example.tex b/macros/latex/contrib/hereapplies/hereapplies-example.tex
index 18b2154e10..ef76ef5ce0 100644
--- a/macros/latex/contrib/hereapplies/hereapplies-example.tex
+++ b/macros/latex/contrib/hereapplies/hereapplies-example.tex
@@ -5,29 +5,34 @@
\begin{document}
\title{Some title}
+
\author{Some author}
\maketitle
-This is concept one. To find this concept applied, please
-see \whereapplies{conceptOne}.
-
-This is concept two. To find this concept applied, please
-see \whereapplies{conceptTwo}.
+This is concept one. To find this concept applied, please see
+\whereapplies{conceptOne}.
-\newpage
+This is concept two. To find this concept applied, please see
+\whereapplies{conceptTwo}.\newpage
\hereapplies{conceptOne}This is page \thepage. As you can see, ``concept
one'' applies here.\newpage
-\hereapplies{conceptTwo}This is page \thepage. As you can see,
-``concept two'' applies here.\newpage
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
\hereapplies{conceptOne}This is page \thepage. As you can see, ``concept
one'' applies here.\newpage
-\hereapplies{conceptTwo}This is page \thepage. As you can see,
-``concept two'' applies here.\newpage
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
+
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
+
+\hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+two'' applies here.\newpage
\hereapplies[myref]{conceptOne}This is page \thepage. As you can
see, ``concept one'' applies here. This point in the document is
diff --git a/macros/latex/contrib/hereapplies/hereapplies.sty b/macros/latex/contrib/hereapplies/hereapplies.sty
index 734881ca8f..c83693fb4a 100644
--- a/macros/latex/contrib/hereapplies/hereapplies.sty
+++ b/macros/latex/contrib/hereapplies/hereapplies.sty
@@ -1,5 +1,5 @@
% -*- Mode: latex; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-
-
+%
%
% hereapplies.sty
%
@@ -7,9 +7,9 @@
%
% https://github.com/madmurphy/hereapplies.sty
%
-% Version 0.3.0
+% Version 0.4.0
%
-% Copyright (c) 2022 madmurphy <madmurphy333@gmail.com>
+% Copyright (C) 2022 madmurphy <madmurphy333@gmail.com>
%
% **Here Applies** is free software: you can redistribute it and/or modify it
% under the terms of the GNU Affero General Public License as published by the
@@ -35,29 +35,34 @@
% \begin{document}
%
% \title{Some title}
+%
% \author{Some author}
%
% \maketitle
%
-% This is concept one. To find this concept applied, please
-% see \whereapplies{conceptOne}.
+% This is concept one. To find this concept applied, please see
+% \whereapplies{conceptOne}.
%
-% This is concept two. To find this concept applied, please
-% see \whereapplies{conceptTwo}.
-%
-% \newpage
+% This is concept two. To find this concept applied, please see
+% \whereapplies{conceptTwo}.\newpage
%
% \hereapplies{conceptOne}This is page \thepage. As you can see, ``concept
% one'' applies here.\newpage
%
-% \hereapplies{conceptTwo}This is page \thepage. As you can see,
-% ``concept two'' applies here.\newpage
+% \hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+% two'' applies here.\newpage
%
% \hereapplies{conceptOne}This is page \thepage. As you can see, ``concept
% one'' applies here.\newpage
%
-% \hereapplies{conceptTwo}This is page \thepage. As you can see,
-% ``concept two'' applies here.\newpage
+% \hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+% two'' applies here.\newpage
+%
+% \hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+% two'' applies here.\newpage
+%
+% \hereapplies{conceptTwo}This is page \thepage. As you can see, ``concept
+% two'' applies here.\newpage
%
% \hereapplies[myref]{conceptOne}This is page \thepage. As you can
% see, ``concept one'' applies here. This point in the document is
@@ -68,6 +73,7 @@
%
\ProvidesPackage{hereapplies}
\RequirePackage{hyperref}
+\RequirePackage{refcount}
%
%
%
@@ -75,65 +81,158 @@
% ===================
%
%
-% Assign a unique number to each applicable concept
+% Assign a unique number to each concept
\newcounter{@ha@concept@counter}
% Assign a unique number to each unnamed occurrence of a concept
\newcounter{@ha@unlabeled@counter}
%
%
-% Macro `\@ha@newapplicable{concept_name}`
+% Macro `\@ha@makeoccurrencelist{HyperrefMacro}{LabelList}`
% *****************************************************************************
%
-% Initialize a new applicable concept
+% Generate the list of page numbers with page range support
+%
+% This macro is for internal purposes only. When invoked, it scans the list of
+% labels provided (`LabelList`) and checks which labels refer to duplicate page
+% numbers and which page numbers can be grouped together.
+%
+% The `HyperrefMacro` argument is the macro from the `hyperref` package that
+% will process the label name. This should be either `T@pageref` -- equivalent
+% to `\pageref` -- or `@pagerefstar` -- equivalent to `\pageref*`.
+%
+% The `ConceptName` argument may contain only Latin letters and the "at" sign
+% (`@`). This string remains confined within the internal scope of the package
+% and does not create conflicts with possible macros or labels of the same
+% name.
+%
+% The `LabelList` must be a comma-separated list of labels.
+%
+\newcommand{\@ha@makeoccurrencelist}[2]{%
+ % Reset the current page number
+ \def\@ha@tmp@@currp{-1}%
+ % Reset the current range offset
+ \def\@ha@tmp@@prangeoffs{-1}%
+ % Iterate through the `LabelList` argument
+ \@for\@ha@tmp@@thislabel:=#2\do{%
+ % Store the page number associated with this label
+ \edef\@ha@tmp@@nextp{\getpagerefnumber{\@ha@tmp@@thislabel}}%
+ % Check that we are not on the same page as in the last iteration
+ \unless\ifnum\@ha@tmp@@currp=\@ha@tmp@@nextp%
+ % This is not the same page as in the last iteration
+ % Is this the first page in which this concept appears?
+ \unless\ifnum\@ha@tmp@@currp=-1%
+ % This is not the first page in which this concept appears
+ % Does this page follow immediately the previous label's page?
+ \ifnum\numexpr\@ha@tmp@@currp+1=\@ha@tmp@@nextp%
+ % This page follows immediately the previous label's page
+ % Are these the first contiguous pages that we encounter?
+ \ifnum\@ha@tmp@@prangeoffs=-1%
+ % These are the first contiguous pages we encounter
+ % Store the first page number of the pair
+ \edef\@ha@tmp@@prangeoffs{\@ha@tmp@@currp}%
+ % Store the first label of the pair
+ \edef\@ha@tmp@@currrangelbl{\@ha@tmp@@currlbl}%
+ \fi%
+ \else%
+ % This page is far from the previous label's page
+ % Was the previous page part of a contiguous range?
+ \ifnum\@ha@tmp@@prangeoffs=-1%
+ % The previous page was a standalone page
+ % Print "[p], "
+ {\csname #1\endcsname{\@ha@tmp@@currlbl}, }%
+ \else%
+ % The previous page was part of a contiguous range
+ % Print "[p--q], "
+ {\csname #1\endcsname{\@ha@tmp@@currrangelbl}--\csname
+ #1\endcsname{\@ha@tmp@@currlbl}, }%
+ % Reset the current range offset
+ \def\@ha@tmp@@prangeoffs{-1}%
+ \fi%
+ \fi%
+ \fi%
+ % Prepare the next page number
+ \edef\@ha@tmp@@currp{\@ha@tmp@@nextp}%
+ % Prepare the next label
+ \edef\@ha@tmp@@currlbl{\@ha@tmp@@thislabel}%
+ \fi%
+ }%
+ % Print the last page number
+ % Is there at least one page to print?
+ \unless\ifnum\@ha@tmp@@currp=-1%
+ % There is at least one page to print
+ % Was the previous page part of a contiguous range?
+ \ifnum\@ha@tmp@@prangeoffs=-1%
+ % The previous page was a standalone page
+ % Print "[p], "
+ {\csname #1\endcsname{\@ha@tmp@@currlbl}}%
+ \else%
+ % The previous page was part of a contiguous range
+ % Print "[p--q], "
+ {\csname #1\endcsname{\@ha@tmp@@currrangelbl}--\csname
+ #1\endcsname{\@ha@tmp@@currlbl}}%
+ \fi%
+ \fi%
+}
+%
+%
+% Macro `\@ha@newconcept{ConceptName}`
+% *****************************************************************************
+%
+% Initialize a new concept
%
-% Thie macro is for internal purposes only. When invoked, it sets up the helper
+% This macro is for internal purposes only. When invoked, it sets up the helper
% macros, counters and auxiliary files needed for keeping track of a concept.
-% If the concept was already initialized this macro will be no op.
+% If the concept was already initialized the macro will be no op.
%
-% The `concept_name` argument may contain only letters and the "at" sign (`@`).
+% The `ConceptName` argument may contain only Latin letters and the "at" sign
+% (`@`). This string remains confined within the internal scope of the package
+% and does not create conflicts with possible macros or labels of the same
+% name.
%
-\newcommand{\@ha@newapplicable}[1]{%
+\newcommand{\@ha@newconcept}[1]{%
% Was this concept already initialized?
- \expandafter\ifx\csname @ha@prop@@cursor@#1\endcsname\relax%
+ \expandafter\ifx\csname @ha@prop@@count@#1\endcsname\relax%
% The concept was never initialized
- % Move the counter to the current id
- \stepcounter{@ha@concept@counter}%
% Set the output to "??" - it will be updated by the .haN file
- \expandafter\def\csname @ha@prop@@uoutput@#1\endcsname{\textbf{??}}%
+ \expandafter\gdef\csname @ha@prop@@uoutput@#1\endcsname{\textbf{??}}%
% Set the starred output to "??" - it will be updated by the .haN file
- \expandafter\def\csname @ha@prop@@soutput@#1\endcsname{\textbf{??}}%
- % The last page that applies
- \expandafter\def\csname @ha@prop@@cursor@#1\endcsname{-1}%
- % Store the id of the current concept
- \expandafter\edef\csname @ha@prop@@id@#1\endcsname{\arabic{@ha@concept@counter}}%
+ \expandafter\gdef\csname @ha@prop@@soutput@#1\endcsname{\textbf{??}}%
+ % Use "p." for the preamble when there is only one occurrence
+ \expandafter\gdef\csname @ha@prop@@preamble@#1\endcsname{p.~}%
+ % Increase the counter of concepts
+ \stepcounter{@ha@concept@counter}%
+ % Store the current value of the counter of concepts
+ \expandafter\xdef\csname
+ @ha@prop@@count@#1\endcsname{\the@ha@concept@counter}%
% Initialize the .haN file
% Previous versions had this line, which created unwanted whitespaces:
- %\@starttoc{ha\csname @ha@prop@@id@#1\endcsname}%
+ %\@starttoc{ha\csname @ha@prop@@count@#1\endcsname}%
% I am thankful to David Carlisle for the following replacement:
- {\endlinechar=\m@ne\@starttoc{ha\csname @ha@prop@@id@#1\endcsname}}%
+ {\endlinechar=\m@ne\@starttoc{ha\csname @ha@prop@@count@#1\endcsname}}%
% Store all the occurrences when the document reaches the end
\AtEndDocument{%
% Make sure that there are occurrences
- \expandafter\ifcsname @ha@prop@@preamble@#1\endcsname%
+ \expandafter\ifcsname @ha@prop@@labels@#1\endcsname%
% There are occurrences
- % When `\hereapplies` is the last directive of the document and
- % is not followed by any text, due to an unknown bug
- % `\whereapplies` prints "??" even when there are occurrences
- % of a concept. Uncommenting the `\phantom` macro below fixes
- % the bug, yet it might be wiser to leave the choice to the
- % user and search for more final solutions in the meanwhile.
- % The `\phantom{}` directive can also be inserted
- % manually at the end of the document.
- %\phantom{}%
% Set the .haN file as output
- \addtocontents{ha\csname @ha@prop@@id@#1\endcsname}{%
+ \addtocontents{ha\csname @ha@prop@@count@#1\endcsname}{%
% Write "p./pp. \pageref..." to the output
\gdef\expandafter\protect\csname @ha@prop@@uoutput@#1\endcsname{%
- \csname @ha@prop@@preamble@#1\endcsname\csname @ha@prop@@ucache@#1\endcsname%
+ % Preamble (either "p." or "pp.")
+ \csname @ha@prop@@preamble@#1\endcsname%
+ % `\T@pageref` is a synonym of `\pageref`
+ \expandafter\protect\csname
+ @ha@makeoccurrencelist\endcsname{T@pageref}{\csname
+ @ha@prop@@labels@#1\endcsname}%
}%
% Write "p./pp. \pageref*..." to the starred output
\gdef\expandafter\protect\csname @ha@prop@@soutput@#1\endcsname{%
- \csname @ha@prop@@preamble@#1\endcsname\csname @ha@prop@@scache@#1\endcsname%
+ % Preamble (either "p." or "pp.")
+ \csname @ha@prop@@preamble@#1\endcsname%
+ % `\@pagerefstar` is a synonym of `\pageref*`
+ \expandafter\protect\csname
+ @ha@makeoccurrencelist\endcsname{@pagerefstar}{\csname
+ @ha@prop@@labels@#1\endcsname}%
}%
}%
\fi%
@@ -142,72 +241,61 @@
}
%
%
-% Macro: `\@ha@getpropat{property_name}{concept_name}`
+% Macro: `\@ha@getpropat{PropertyName}{ConceptName}`
% *****************************************************************************
%
-% Get the current value of a concept's property
+% Get the value of a concept's property
%
-% Thie macro is for internal purposes (but nothing forbids invoking it
-% directly).
+% This macro is for internal purposes (but nothing forbids invoking it
+% directly). If a concept was never initialized the macro will initialize it.
%
-% Possible values for the `property_name` argument are: `cursor`, `id`,
-% `preamble`, `scache`, `soutput`, `ucache`, `uoutput`.
+% Possible values for the `PropertyName` argument are: `count`, `labels`,
+% `preamble`, `soutput`, `uoutput`.
%
-% The `concept_name` argument may contain only letters and the "at" sign (`@`).
+% The `ConceptName` argument may contain only Latin letters and the "at" sign
+% (`@`). This string remains confined within the internal scope of the package
+% and does not create conflicts with possible macros or labels of the same
+% name.
%
\newcommand{\@ha@getpropat}[2]{%
- % Make sure that the applicable concept is initialized
- \@ha@newapplicable{#2}%
- % Print all the occurrences of the concept
+ % Make sure that the concept is initialized
+ \@ha@newconcept{#2}%
+ % Print the concept's property
\csname @ha@prop@@#1@#2\endcsname%
}
%
%
-% Macro: `\starred@labeled@hereapplies{label}{concept_name}`
+% Macro: `\starred@labeled@hereapplies{Label}{ConceptName}`
% *****************************************************************************
%
% Equivalent to `\hereapplies*`, but the two arguments are both mandatory
%
-% Thie macro is for internal purposes (but nothing forbids invoking it
+% This macro is for internal purposes (but nothing forbids invoking it
% directly). See the documentation of `\hereapplies` for more information.
%
\newcommand{\starred@labeled@hereapplies}[2]{%
% Make sure that the concept has been initialized
- \@ha@newapplicable{#2}%
+ \@ha@newconcept{#2}%
% Assign a label to this occurrence
\label{#1}%
- % If the cursor already points to the current page do nothing
- \unless\ifnum\csname @ha@prop@@cursor@#2\endcsname=\thepage%
- % Is this the first occurrence?
- \expandafter\ifcsname @ha@prop@@preamble@#2\endcsname%
- % This is *not* the first occurrence
- % Use "pp." for the preamble when there are multiple occurrences
- \expandafter\def\csname @ha@prop@@preamble@#2\endcsname{pp.~}%
- % Populate the cache
- \expandafter\g@addto@macro\csname @ha@prop@@ucache@#2\endcsname{, \pageref{#1}}%
- % Populate the starred cache
- \expandafter\g@addto@macro\csname @ha@prop@@scache@#2\endcsname{, \pageref*{#1}}%
- \else%
- % This is the first occurrence
- % Use "p." for the preamble when there is only one occurrence
- \expandafter\def\csname @ha@prop@@preamble@#2\endcsname{p.~}%
- % Initialize the cache
- \expandafter\def\csname @ha@prop@@ucache@#2\endcsname{\pageref{#1}}%
- % Initialize the starred cache
- \expandafter\def\csname @ha@prop@@scache@#2\endcsname{\pageref*{#1}}%
- \fi%
- % Make the cursor point to the current page
- \expandafter\edef\csname @ha@prop@@cursor@#2\endcsname{\thepage}%
+ \expandafter\ifcsname @ha@prop@@labels@#2\endcsname%
+ % This is *not* the first occurrence
+ \expandafter\g@addto@macro\csname @ha@prop@@labels@#2\endcsname{,#1}%
+ % Use "pp." for the preamble when there are multiple occurrences
+ \expandafter\gdef\csname @ha@prop@@preamble@#2\endcsname{pp.~}%
+ \else%
+ % This is the first occurrence
+ \expandafter\gdef\csname @ha@prop@@labels@#2\endcsname{#1}%
\fi%
}
%
%
-% Macro: `\starred@hereapplies[label]{concept_name}`
+% Macro: `\starred@hereapplies[Label]{ConceptName}`
% *****************************************************************************
%
% Equivalent to `\hereapplies*`
%
-% Thie macro is for internal purposes (but nothing forbids invoking it
+% This macro is for internal purposes (but nothing forbids invoking it
% directly). See the documentation of `\hereapplies` for more information.
%
\newcommand{\starred@hereapplies}[2][]{%
@@ -217,7 +305,9 @@
% Assign a unique number to the unnamed occurrence
\stepcounter{@ha@unlabeled@counter}%
% Call `\starred@hereapplies` with an opaque label
- \edef\tmp{\noexpand\starred@labeled@hereapplies{#2:__appl\arabic{@ha@unlabeled@counter}__}{#2}}\tmp%
+ {\edef\tmp{\noexpand\starred@labeled@hereapplies{%
+ ha:#2-unnamed\the@ha@unlabeled@counter}{#2}%
+ }\tmp}%
\else%
% The macro has been called with two arguments
\starred@labeled@hereapplies{#1}{#2}%
@@ -230,7 +320,7 @@
% ===================
%
%
-% Macro: `\hereapplies[label]{concept_name}`
+% Macro: `\hereapplies[Label]{ConceptName}`
% *****************************************************************************
%
% Notify the document that a particular concept applies and create a label for
@@ -240,7 +330,10 @@
% accordingly, otherwise an opaque name will be assigned to it. This argument
% may contain only what is legal in both `\label` and `\pageref`.
%
-% The `concept_name` argument may contain only letters and the "at" sign (`@`).
+% The `ConceptName` argument may contain only Latin letters and the "at" sign
+% (`@`). This string remains confined within the internal scope of the package
+% and does not create conflicts with possible macros or labels of the same
+% name.
%
% The starred version of this macro (`\hereapplies*`) does not invoke the
% `\phantomsection` directive.
@@ -251,12 +344,16 @@
}
%
%
-% Macro: `\whereapplies{concept_name}`
+% Macro: `\whereapplies{ConceptName}`
% *****************************************************************************
%
% Print all the occurrences of a concept in the form "p. ..." or "pp. ..."
+% with page range support
%
-% The `concept_name` argument may contain only letters and the "at" sign (`@`).
+% The `ConceptName` argument may contain only Latin letters and the "at" sign
+% (`@`). This string remains confined within the internal scope of the package
+% and does not create conflicts with possible macros or labels of the same
+% name.
%
% The starred version of this macro (`\whereapplies*`) will use `\pageref*`
% instead of `\pageref` for generating the page list.
diff --git a/macros/latex/contrib/hereapplies/lyx-module/hereapplies-example.lyx b/macros/latex/contrib/hereapplies/lyx-module/hereapplies-example.lyx
index 0b9e259dca..8f77964e19 100644
--- a/macros/latex/contrib/hereapplies/lyx-module/hereapplies-example.lyx
+++ b/macros/latex/contrib/hereapplies/lyx-module/hereapplies-example.lyx
@@ -297,6 +297,84 @@ concept two
status open
\begin_layout Plain Layout
+conceptTwo
+\end_layout
+
+\end_inset
+
+This is page
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+thepage
+\end_layout
+
+\end_inset
+
+.
+ As you can see,
+\begin_inset Quotes eld
+\end_inset
+
+concept two
+\begin_inset Quotes erd
+\end_inset
+
+ applies here.
+\begin_inset Newpage newpage
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex Here applies
+status open
+
+\begin_layout Plain Layout
+conceptTwo
+\end_layout
+
+\end_inset
+
+This is page
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+thepage
+\end_layout
+
+\end_inset
+
+.
+ As you can see,
+\begin_inset Quotes eld
+\end_inset
+
+concept two
+\begin_inset Quotes erd
+\end_inset
+
+ applies here.
+\begin_inset Newpage newpage
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex Here applies
+status open
+
+\begin_layout Plain Layout
\begin_inset Argument 1
status open
diff --git a/macros/latex/contrib/hereapplies/lyx-module/hereapplies.module b/macros/latex/contrib/hereapplies/lyx-module/hereapplies.module
index 6d927540ca..27438dde66 100644
--- a/macros/latex/contrib/hereapplies/lyx-module/hereapplies.module
+++ b/macros/latex/contrib/hereapplies/lyx-module/hereapplies.module
@@ -34,6 +34,9 @@ InsetLayout Flex:Here_applies
BgColor lightgray
Argument 1
Decoration Classic
+ Font
+ Color blue
+ EndFont
LabelString "Label"
MenuString "Instance label"
Tooltip "A string that will become the label of the instance (which can be referenced with \ref, \pageref, etc.)"
@@ -64,6 +67,9 @@ InsetLayout Flex:Here_applies*
BgColor lightgray
Argument 1
Decoration Classic
+ Font
+ Color blue
+ EndFont
LabelString "Label"
MenuString "Instance label"
Tooltip "A string that will become the label of the instance (which can be referenced with \ref, \pageref, etc.)"
@@ -81,7 +87,7 @@ InsetLayout Flex:Where_applies
EndFont
LabelFont
Family Serif
- Color green
+ Color purple
Size Small
EndFont
LabelString "Applications of"
@@ -104,7 +110,7 @@ InsetLayout Flex:Where_applies*
EndFont
LabelFont
Family Serif
- Color green
+ Color purple
Size Small
EndFont
LabelString "Applications of*"
diff --git a/macros/latex/contrib/hereapplies/package.json b/macros/latex/contrib/hereapplies/package.json
index b74ebec02c..74dd5ed4a9 100644
--- a/macros/latex/contrib/hereapplies/package.json
+++ b/macros/latex/contrib/hereapplies/package.json
@@ -1,6 +1,6 @@
{
"name": "hereapplies.sty",
- "version": "0.3.0",
+ "version": "0.4.0",
"description": "A LaTeX package for cross-linking concepts to their applications",
"homepage": "https://madmurphy.github.io/hereapplies.sty",
"author": "madmurphy",
diff --git a/macros/latex/contrib/msu-thesis/README.md b/macros/latex/contrib/msu-thesis/README.md
index ca01a2226f..c49830bee6 100644
--- a/macros/latex/contrib/msu-thesis/README.md
+++ b/macros/latex/contrib/msu-thesis/README.md
@@ -1,4 +1,4 @@
-# MSU Thesis Class Version 3.4 2022/06/30
+# MSU Thesis Class Version 3.5 2022/08/15
Copyright 2011-2022 by Alan Munn <amunn@msu.edu>
diff --git a/macros/latex/contrib/msu-thesis/msu-thesis.cls b/macros/latex/contrib/msu-thesis/msu-thesis.cls
index b7d90a5fc7..07e3fee9c3 100644
--- a/macros/latex/contrib/msu-thesis/msu-thesis.cls
+++ b/macros/latex/contrib/msu-thesis/msu-thesis.cls
@@ -168,11 +168,12 @@
% Version 3.4 2022/06/30 Added a starred version of \makecopyrightpage;
% removed colons from captions;
% updated documentation on algorithms and captions
+% Version 3.5 2022/08/15 Added \setabstractnamespace to allow user control over thesis office idiocy
%
% Report bugs/problems/questions to <amunn@msu.edu>
%
-\def\msu@version{3.4}
-\def\msu@date{2022/06/30}
+\def\msu@version{3.5}
+\def\msu@date{2022/08/15}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{msu-thesis}[\msu@date\space Michigan State University Thesis Class version \msu@version]
\newif\ifmsu@dissertation\msu@dissertationtrue % added v2.7 boolean for \msu@thesistype
@@ -506,6 +507,11 @@
\feetbelowfloat % footnotes will appear below bottom floats
% set up abstract and public abstract
+% The thesis office is inconsistent in how they measure what they call a "double space".
+% Adding a fudge factor that can be changed at the user level (v3.5 8/15/2022)
+% We'll set it to 1 for the moment; 0 is what should be 1 double space, but they seem to want more
+\newcommand\setabstractnamespace[1]{\gdef\msu@abstractnamespacefactor{#1}}
+\setabstractnamespace{1}
\renewenvironment{abstract}{%
\setlength{\afterchapskip}{\onelineskip} % changed 2020/12/14 again removed manual spacing from 2016
\chapter*{\abstractname}
@@ -514,7 +520,7 @@
\begin{center}
\MakeUppercase{\thetitle}\plainbreak{1}By\plainbreak{1}\theauthor
\end{center}
-% \plainbreak{-.5} % changed 2016/06/08 after complaints
+ \plainbreak{\msu@abstractnamespacefactor} % changed 2016/06/08 after complaints
\DoubleSpacing
}{\par}
%
diff --git a/macros/latex/contrib/msu-thesis/msu-thesis.pdf b/macros/latex/contrib/msu-thesis/msu-thesis.pdf
index c9487ce6ca..37f508b169 100644
--- a/macros/latex/contrib/msu-thesis/msu-thesis.pdf
+++ b/macros/latex/contrib/msu-thesis/msu-thesis.pdf
Binary files differ
diff --git a/macros/latex/contrib/msu-thesis/msu-thesis.tex b/macros/latex/contrib/msu-thesis/msu-thesis.tex
index 6ee63661cd..ae36197dbe 100644
--- a/macros/latex/contrib/msu-thesis/msu-thesis.tex
+++ b/macros/latex/contrib/msu-thesis/msu-thesis.tex
@@ -2,8 +2,8 @@
\documentclass[11pt]{article}
-\def\msuversion{3.4}
-\def\msudate{2022/06/30}
+\def\msuversion{3.5}
+\def\msudate{2022/08/15}
\title{\textbf{Using the MSU Thesis Class}}
\author{\textbf{Alan Munn}\\Department of Linguistics, Languages, and Cultures\\Michigan State University\\\texttt{\href{mailto:amunn@msu.edu}{amunn@msu.edu}}}
\date{Version \msuversion\\\msudate}
@@ -14,6 +14,7 @@
\usepackage{enumitem}
\usepackage{fancyvrb,listings,url}
\usepackage[sf]{titlesec}
+\usepackage[section]{placeins}
\usepackage[colorlinks=true]{hyperref}
@@ -75,7 +76,7 @@ Formatting a dissertation according to a University's thesis requirements is not
The MSU Thesis Class is based on the \pkg{memoir} document class. The \pkg{memoir} class is an extensive class that incorporates the functionality of many other packages into it. The class is extensively documented, and the documentation (\pkg{memman.pdf}) should be available with any \TeX\ distribution. I strongly recommend that you familiarize yourself with \pkg{memoir} as you use the present class.
\section{Class Options}
In addition to any options passed to the \pkg{memoir} class (e.g. |oldfontcommands|; see Section \ref{sec:fonts}, font size), the \pkg{msu-thesis} takes six options: one to specify the type of degree, (see Table~\ref{degrees}), one to enable landscape page numbering, two to enable per-chapter bibliographies and appendices, two to make small adjustments to Table of Contents. If no degree option is specified, a Ph.D. dissertation is assumed.
-\begin{table}
+\begin{table}[htpb]
\centering
\begin{tabularx}{.8\textwidth}{>{\ttfamily}lX}
\toprule
@@ -118,18 +119,34 @@ I also have received inconsistent formatting requirements for per-chapter biblio
As of v2.9, the class now supports |10pt|, |11pt| and |12pt| font sizes. The default is |12pt|. If you are using a small font like Times New Roman or equivalent, you should stick to the default. If you are using a larger font like Computer Modern, |11pt| is probably fine. Use |10pt| at your own peril, as I suspect the Thesis Office will not accept it!
\section{User commands}
-In addition to all the user functionality defined by \pkg{memoir}, the \pkg{msu-thesis} class defines seven new titling commands.
-\begin{quote}
-\begin{description}
-\item[\texttt{\bs maketitlepage}] Makes the main title page for the thesis.
-\item[\texttt{\bs fieldofstudy\{\}}] Takes one argument corresponding to your field of study.
-\item[\texttt{\bs dedication\{\}}] Takes one argument (should be short), your dedication.
-\item[\texttt{\{publicabstract\}}] Environment for the public abstract (unnumbered, uncounted).
-\item[\texttt{\bs makecopyrightpage}] Creates the copyright page (use |\makecopyrightpage*| to align the text on the left.)
-\item[\texttt{\bs makededicationpage}] Creates the dedication page.
-\item[\texttt{\bs makebibliographypage}] Creates the bibliography cover page.
-\end{description}
-\end{quote}
+In addition to all the user functionality defined by \pkg{memoir}, the \pkg{msu-thesis} class defines seven new titling commands, and two “appeasement” commands, i.e., commands to tweak the formatting to appease the the thesis office’s inconsistency.
+\begin{table}[htpb]
+\centering
+\begin{tabularx}{.8\textwidth}{>{\ttfamily}lX}
+\toprule
+{\bs maketitlepage} & Makes the main title page for the thesis.\\
+{\bs fieldofstudy\{\}} & Takes one argument corresponding to your field of study.\\
+{\bs dedication\{\}} & Takes one argument (should be short), your dedication.\\
+{\{publicabstract\}} & Environment for the public abstract (unnumbered, uncounted).\\
+{\bs makecopyrightpage} & Creates the copyright page (use \texttt{\bs makecopyrightpage*} to align the text on the left.)\\
+{\bs makededicationpage} & Creates the dedication page.\\
+{\bs makebibliographypage} & Creates the bibliography cover page.\\
+\bottomrule
+\end{tabularx}
+\caption{Class titling commands}
+\end{table}
+
+\begin{table}[htpb]
+\centering
+\begin{tabularx}{.8\textwidth}{>{\ttfamily}lX}
+\toprule
+{\bs msucaptiondelim} & Delimiter for floating elements (see section \ref{captiondelim}).\\
+{\bs setabstractnamespace} & Changes spacing after the name in the abstract (see section \ref{abstractspacing}).\\
+\bottomrule
+\end{tabularx}
+\caption{Appeasement commands}
+\end{table}
+
\section{Using the class}
\subsection{Logical parts of the document}
@@ -277,8 +294,15 @@ before the contents lists and |\microtypesetup{protrusion=true}| afterwards. Sc
\microtypesetup{protrusion=true}
\end{lstlisting}
\end{quote}
+\subsection{Abstracts}
+MSU requires you to have an abstract, but you may also have a public abstract, which is weirdly unnumbered and uncounted.
+
+\subsubsection{Spacing after the author name in the abstract}\label{abstractspacing}
+The thesis office is very inconsistent in how it determines what it thinks is a “double space”, and this especially seems to be true after the author name in the the abstract. Because of this, I’ve created a way to change the spacing within the user document so that you can appease the thesis office bureaucrats without reporting an issue to me.
+
+Use the command |\setabstractnamespace| to change the spacing after the author name in the abstract. This command takes a value typically between 0 and 1 where 0 reduces the space to a single baselineskip, while 1 adds an extra baselineskip. The default is set to 1, but if that’s too large, try 0.5 or 0 as needed.
-\subsection{Public abstract}
+\subsubsection{Public abstract}
If your thesis requires a public abstract, it should go immediately before the regular abstract. Use the |{publicabstract}| environment for this. Please note that you \emph{must} have an abstract even if you also have a public abstract.
\subsection{Landscape figures and tables}
If you have large figures and tables that must be rotated, you should use the |[lscape]| class option. This enables a pagestyle |lscape| and places the page numbers correctly on the long edge of the page. The option loads the \pkg{pdflscape} package which provides a |landscape| environment to place the landscape figure in. Before the landscape environment, you need to issue a |\clearpage| command and change the pagestyle to |lscape|, and afterwards, change it back to |plain|. Schematically, then, any landscape pages should be created in the following way.
@@ -371,10 +395,10 @@ I'm happy to answer emails about formatting issues with the class, especially wh
\subsection{Archiving your thesis for the future}
Since the current version of the \pkg{msu-thesis} class satisfies the Graduate School requirements at any one time, as these requirements change, you may find that if you need to recompile your thesis after you have graduated that the formatting changes. To avoid this, I would recommend saving an archived version of the \pkg{msu-thesis.cls} file in the same folder as your thesis file. You only need to do this once you have completely finished your thesis however; there's no need to do it during the writing process.
\subsection{Major Version history}
-Previous versions of \pkg{msu-thesis} (versions 1.0--1.4b) were created for non-electronic submission and should not be used. Versions 1.5--1.6 (the first electronic submission versions) contained a |\makeabstract| command and a separate |msuabstract| environment. These have been removed as of version 1.7. Users who are upgrading from earlier versions to version 1.7 do not need to change these commands however but their use will trigger a warning.) Version 2.0 implemented landscape pages; version 2.1 added support for \pkg{hyperref}. Versions 2.2--2.5 mainly accommodated to the ever changing whims of the MSU Graduate School. Version 2.6 fixed some appendix bugs introduced by the previous whim accommodation. Version 2.7 fixed various small spacing issues, fixed a bug which prevented a new chapter page to be a landscape page, added support for the \pkg{apacite} package, and updated degree options. Version 2.8 fixed some spacing and capitalization issues and added support for the public abstract. Version 2.9 removed subscript/superscript size restrictions, added font size options and made small spacing changes to appease the thesis office. Version 3.0 added full support for per-chapter bibliographies and appendices, and automated bibliography spacing for |natbib| and |biblatex| produced bibliographies. Version 3.1 added support for an |{algorithm}| environment and a list of algorithms to combat incompatibilities with the \pkg{algorithm} and \pkg{algorithm2e} packages. Version 3.2 fixed some lingering problems with per-chapter appendices. Version 3.3 added code to accommodate the insane inconsistencies in formatting requirements that the thesis office requires, including a new contents option which hopefully should never be used, and fixed some numbering problems with per-chapter appendices. Version 3.4 added a starred option to the |\makecopyrightpage| command after complaints about placement. The documentation has also been updated to include more information about caption formatting and removed colons from the default caption format.
+Previous versions of \pkg{msu-thesis} (versions 1.0--1.4b) were created for non-electronic submission and should not be used. Versions 1.5--1.6 (the first electronic submission versions) contained a |\makeabstract| command and a separate |msuabstract| environment. These have been removed as of version 1.7. Users who are upgrading from earlier versions to version 1.7 do not need to change these commands however but their use will trigger a warning.) Version 2.0 implemented landscape pages; version 2.1 added support for \pkg{hyperref}. Versions 2.2--2.5 mainly accommodated to the ever changing whims of the MSU Graduate School. Version 2.6 fixed some appendix bugs introduced by the previous whim accommodation. Version 2.7 fixed various small spacing issues, fixed a bug which prevented a new chapter page to be a landscape page, added support for the \pkg{apacite} package, and updated degree options. Version 2.8 fixed some spacing and capitalization issues and added support for the public abstract. Version 2.9 removed subscript/superscript size restrictions, added font size options and made small spacing changes to appease the thesis office. Version 3.0 added full support for per-chapter bibliographies and appendices, and automated bibliography spacing for |natbib| and |biblatex| produced bibliographies. Version 3.1 added support for an |{algorithm}| environment and a list of algorithms to combat incompatibilities with the \pkg{algorithm} and \pkg{algorithm2e} packages. Version 3.2 fixed some lingering problems with per-chapter appendices. Version 3.3 added code to accommodate the insane inconsistencies in formatting requirements that the thesis office requires, including a new contents option which hopefully should never be used, and fixed some numbering problems with per-chapter appendices. Version 3.4 added a starred option to the |\makecopyrightpage| command after complaints about placement. The documentation has also been updated to include more information about caption formatting and removed colons from the default caption format. Version 3.5 added user level way to change the spacing after the author’s name in the abstract, to deal with thesis office inconsistency.
\section{Acknowledgements}
-Thanks to Lars Madsen, Ulrike Fischer and Peter Wilson for help with setting up parts of the memoir code for versions 1.0--1.4 (now eliminated due to changed requirements). Thanks to Wolfgang Sternefeld for supplying the \pkg{linguex} spacing fix code, Leo Liu for the landscape page numbering code, which greatly simplified my original version, and Florent Chervet for the \pkg{hyperref} code. Thanks also to the following students who have reported problems over the years: Irina Agafonova, Ali Al-jiboory, Julian Blank, Dmitriy Bryndin, Greg Christian, Kyle Crayne, Ciaron Hamilton, Matt Husband, Changkuk Jung, Adam Liter, Vanessa Maldonado, William Muir, Alicia Parrish, Neil ver Planck, Giacomo Romanini, William Sands, Adam Soliman, Erik Stitt, Eremey Valetov, Matthew Vincent, Michael Wojcik, Stephen Yowono, Ali Zare, and Yisu Zhou. A special thank you to Non Thongprong who graciously provided a copy of his entire thesis which allowed me to debug some especially subtle spacing inconsistencies.
+Thanks to Lars Madsen, Ulrike Fischer and Peter Wilson for help with setting up parts of the memoir code for versions 1.0--1.4 (now eliminated due to changed requirements). Thanks to Wolfgang Sternefeld for supplying the \pkg{linguex} spacing fix code, Leo Liu for the landscape page numbering code, which greatly simplified my original version, and Florent Chervet for the \pkg{hyperref} code. Thanks also to the following students who have reported problems over the years: Irina Agafonova, Ali Al-jiboory, Abubakr Ayesh, Julian Blank, Dmitriy Bryndin, Greg Christian, Kyle Crayne, Ciaron Hamilton, Matt Husband, Changkuk Jung, Adam Liter, Vanessa Maldonado, William Muir, Alicia Parrish, Neil ver Planck, Giacomo Romanini, William Sands, Adam Soliman, Erik Stitt, Eremey Valetov, Matthew Vincent, Michael Wojcik, Stephen Yowono, Ali Zare, and Yisu Zhou. A special thank you to Non Thongprong who graciously provided a copy of his entire thesis which allowed me to debug some especially subtle spacing inconsistencies.
\appendix
\renewcommand{\thesection}{Appendix \Alph{section}}
diff --git a/macros/latex/contrib/pygmentex/pygmentex.sty b/macros/latex/contrib/pygmentex/pygmentex.sty
index 60e7bcda30..4e07211490 100644
--- a/macros/latex/contrib/pygmentex/pygmentex.sty
+++ b/macros/latex/contrib/pygmentex/pygmentex.sty
@@ -2,13 +2,19 @@
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{pygmentex}[2020/12/21 v0.10 A Pygmentex layer for LaTeX]
+\ProvidesPackage{pygmentex}[2022/08/15 v0.11 A Pygmentex layer for LaTeX]
+
+\newif\ifpygmented@opt@force\pygmented@opt@forcefalse
+\DeclareOption{force}{\pygmented@opt@forcetrue}
+
+\ProcessOptions\relax
\RequirePackage{fancyvrb}
\RequirePackage{color}
\RequirePackage{ifthen}
%\RequirePackage[font=small,format=plain,labelfont=bf,up,textfont=it,up]{caption}
\RequirePackage{caption}
+\RequirePackage{shellesc}
\RequirePackage{pgfkeys}
\RequirePackage{efbox}
\RequirePackage[framemethod=tikz]{mdframed}
@@ -117,6 +123,7 @@
colback/.store in = \pygmented@opt@colback,
font/.store in = \pygmented@opt@font,
%
+ force/.default = false,
texcomments/.default = true,
mathescape/.default = true,
linenos/.default = true,
@@ -383,7 +390,18 @@
}
\AtEndDocument{%
- \closeout\pygmented@outfile%
+ \immediate\closeout\pygmented@outfile%
+ \ifpygmented@opt@force
+ \typeout{>>>> running pygmentex (option force=true) ...}%
+ \ShellEscape{pygmentex \jobname.snippets}%
+ \typeout{>>>> ... done.}%
+ \else
+ \IfFileExists{\jobname.pygmented}%
+ {\typeout{>>>> file \jobname.pygmented exists, not running pygmentex}}%
+ {\typeout{>>>> no file \jobname.pygmented, running pygmentex ...}%
+ \ShellEscape{pygmentex \jobname.snippets}%
+ \typeout{>>>> ... done.}}%
+ \fi
}
\endinput
diff --git a/macros/latex/contrib/pygmentex/pygmentex_demo.pdf b/macros/latex/contrib/pygmentex/pygmentex_demo.pdf
index a444bffd44..73b3171514 100644
--- a/macros/latex/contrib/pygmentex/pygmentex_demo.pdf
+++ b/macros/latex/contrib/pygmentex/pygmentex_demo.pdf
Binary files differ
diff --git a/macros/latex/contrib/pygmentex/pygmentex_demo.tex b/macros/latex/contrib/pygmentex/pygmentex_demo.tex
index 5a07f49bed..1b6888022c 100644
--- a/macros/latex/contrib/pygmentex/pygmentex_demo.tex
+++ b/macros/latex/contrib/pygmentex/pygmentex_demo.tex
@@ -1,5 +1,4 @@
\documentclass[10pt,a4paper]{article}
-
%\usepackage[margin=13mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
@@ -24,7 +23,10 @@
\begin{document}
\title{Testing the Pygmen\TeX{} package}
-\author{José Romildo Malaquias}
+\author{José Romildo Malaquias\\
+\href{mailto:malaquias@ufop.edu.br}{malaquias@ufop.edu.br}\\
+\href{https://bitbucket.org/romildo/pygmentex/src/master/}{bitbucket.org/romildo/pygmentex}
+}
\maketitle
\section{The Pygmen\TeX{} package}
@@ -42,7 +44,7 @@ listings in a \LaTeX{} document:
\begin{itemize}
\item the \verb|pygmented| environment typesets its contents as a
source code listing,
- \item the \verb|includepygmented| command typesets the contents of a
+ \item the \verb|\inputpygmented| command typesets the contents of a
file, including the result in the \LaTeX{} document, and
\item the \verb|\pyginline| command typesets its contents, keeping the
result in the same line.
@@ -53,35 +55,49 @@ many ways.
Read the remaining of this document to have an idea of what the package
is capable of.
+\section{Requirements}
+
+Current versions of Pygmen\TeX require Python version 3. Earlier versions
+required Python version 2. All versions require the Python Pygments library.
+
\section{How to use the package}
-In order to use the package, start by putting
+\paragraph{1.} Add the package to the document preamble.
\begin{verbatim}
\usepackage{pygmentex}
\end{verbatim}
-in the preamble of the document.
-Use the environment or commands mentioned previously to include source
+\paragraph{2.} Use the environment or commands mentioned previously to include source
code listings on your document.
-When compiling the document (with \texttt{pdflatex}, for instance), all
-the source code listings in the document wil be collected and saved in a
-temporary file with the extension \texttt{.snippets} in its name. Then
-the auxiliary program \texttt{pygmentex} (a Python application
-distributed with the Pygmen\TeX{} package) should be run taking this
-file as input. It will produce another temporary file with the extension
+\paragraph{3.} Compile using \texttt{pdflatex}.\footnote{Other \LaTeX compilers
+may also work but have not been tested by the author.}
+All the source code listings in the document wil be collected and saved in a
+temporary file with the extension \texttt{.snippets} in its name.
+
+\paragraph{4.} Run \texttt{pygmentex documentname.snippets}.
+The python application \texttt{pygmentex} is
+distributed with the Pygmen\TeX{} package).
+It will produce another temporary file with the extension
\texttt{.pygmented}, containing \LaTeX{} code for the code listings
previously collected. The next time the document is compiled, they are
included to produce the final typeset document.
-The programming language of the listing code can be specified using the
-\verb|lang| option.
+\paragraph{5.} Rerun \texttt{pdflatex} as usual.
-To get a list of all available languages, execute the following command
-on the command line:
+\paragraph{Note.} Running the external python application
+\texttt{pygmentex} can be done automatically from withing \LaTeX{} if
+the optional argument \texttt{--shell-escape} is used.
+
+With
\begin{verbatim}
-$ pygmentize -L lexers
+pdflatex --shell-escape <file>
\end{verbatim}
+the external run of \texttt{pygmentex} is not needed. It will be run
+automatically at the end of the document compilation.
+
+There is a package option \texttt{force} that will force running
+\texttt{pygmentex} every time the document is compiled.
\section{First examples}
@@ -122,7 +138,18 @@ Next you can see a Java program to calculate the factorial of a number.
\inputpygmented[lang=java]{Factorial.java}
\end{Example}
-\section{Choosing different Pygments styles}
+\section{Options}
+\subsection{\texttt{lang}}
+The programming language of the listing code can be specified using the
+\verb|lang| option.
+
+To get a list of all available languages, execute the following command
+on the command line:
+\begin{verbatim}
+$ pygmentize -L lexers
+\end{verbatim}
+
+\subsection{\texttt{sty}}
Instead of using the default style you may choose another stylesheet
provided by Pygments by its name using the \verb|sty| option.
@@ -142,7 +169,7 @@ As examples you can see a C program typeset with different styles.
\noindent
\begin{minipage}[t]{0.49\linewidth}
\begin{pygmented}[lang=c,gobble=4,sty=murphy]
- #include<stdio.h>
+ #include<stdio.h>
main()
{ int n;
printf("Enter a number: ");
@@ -158,7 +185,7 @@ As examples you can see a C program typeset with different styles.
\hfil
\begin{minipage}[t]{0.49\linewidth}
\begin{pygmented}[lang=c,gobble=4,sty=trac]
- #include<stdio.h>
+ #include<stdio.h>
main()
{ int n;
printf("Enter a number: ");
@@ -173,7 +200,7 @@ As examples you can see a C program typeset with different styles.
\end{minipage}
\end{Example}
-\section{Choosing a font}
+\subsection{\texttt{font}}
The value of the option \verb|font| is typeset before the content of the
listing. Usualy it is used to specify a font to be used. See the
@@ -193,23 +220,23 @@ object bigint extends Application {
\end{pygmented}
\end{Example}
-\section{Changing the background color}
+\subsection{\texttt{colback}}
The option \verb|colback| can be used to choose a background color, as
is shown in the folowing example.
\begin{Example}
\begin{pygmented}[lang=fsharp,colback=green!25]
-let rec factorial n =
- if n = 0
- then 1
+let rec factorial n =
+ if n = 0
+ then 1
else n * factorial (n - 1)
System.Console.WriteLine(factorial anInt)
\end{pygmented}
\end{Example}
-\section{Supressing initial characters}
+\subsection{\texttt{gobble}}
The option \verb|gobble| specifies the number of characters to suppress
at the beginning of each line (up to a maximum of 9). This is mainly
@@ -232,7 +259,7 @@ A code snippet inside a minipage:
\end{Example}
-\section{Size of tabulator}
+\subsection{\texttt{tabsize}}
The option \verb|tabsize| specifies the number of of spaces given by a
tab character (Default: 8).
@@ -254,7 +281,7 @@ tab character (Default: 8).
\end{pygmented}
-\section{Numbering lines}
+\subsection{\texttt{linenos}, \texttt{linenostart}, \texttt{linenostep}, \texttt{linenosep}}
The lines of a listing can be numbered. The followig options control
numbering of lines.
@@ -277,7 +304,7 @@ factorial of a number.
;; Building a list of squares from 0 to 9.
;; Note: loop is simply an arbitrary symbol used as
;; a label. Any symbol will do.
-
+
(define (list-of-squares n)
(let loop ((i n) (res '()))
(if (< i 0)
@@ -286,7 +313,7 @@ factorial of a number.
\end{pygmented}
\end{Example}
-\section{Captioning}
+\subsection{\texttt{caption} and \texttt{label}}
The option \verb|caption| can be used to set a caption for the listing.
The option \verb|label| allows the assignment of a label to the listing.
@@ -314,7 +341,7 @@ int main()
Listing \ref{lst:test} is a C++ program.
\end{Example}
-\section{Escaping to \LaTeX{} inside a code snippet}
+\subsection{\texttt{texcomments}, \texttt{mathescape} and \texttt{escapeinside}}
The option \verb|texcomments|, if set to \texttt{true}, enables \LaTeX{}
comment lines. That is, LaTex markup in comment tokens is not escaped
@@ -364,13 +391,13 @@ else
\end{Example}
-\section{Enclosing command and environment}
+\subsection{\texttt{inline method} and \texttt{boxing method}}
After being prettified by Pygments, the listings are enclosed in a
command (for \verb|\pyginline|) or in an environment (for
-\verb|pygmented| and \verb|includepygmented|). By default
+\verb|pygmented| and \verb|inputpygmented|). By default
\verb|\pyginline| uses the command \verb|\efbox| from the \texttt{efbox}
-package, and \verb|pygmented| and \verb|includepygmented| use the
+package, and \verb|pygmented| and \verb|inputpygmented| use the
environment \verb|mdframed| from the \texttt{mdframed} package.
The enclosing command or environment should be configurable using a list
@@ -388,7 +415,7 @@ The enclosing command for
\end{Example}
The enclosing environment for \verb|pygmented| and
-\verb|includepygmented| can be changed with the option
+\verb|inputpygmented| can be changed with the option
\verb|boxing method|. For instance, here is a hello world program in
C\#, enclosed in a \verb|tcolorbox| environment:
@@ -461,7 +488,7 @@ END
\begin{pygmented}[test, lang=vbnet]
Module Module1
- Sub Main()
+ Sub Main()
Console.WriteLine("Hello, world!")
End Sub
End Module
@@ -595,7 +622,7 @@ def qsort(xs: List[Int]): List[Int] =
}
\end{pygmented}
\lipsum[32]
-
+
\item[Another item] \lipsum[33]
\begin{pygmented}[lang=lua,colback=yellow]
function entry0 (o)
@@ -704,9 +731,9 @@ int main(int argc, char** argv) {
/* This program prints a
hello world message
to the console. */
-
+
import std.stdio;
-
+
void main()
{
writeln("Hello, World!");
@@ -725,7 +752,7 @@ The followig example uses \texttt{mdframed} to typeset the code listing.
\begin{pygmented}[boxing method=mdframed,lang=ada,style=exampledefault]
with Ada.Text_IO;
-
+
procedure Hello_World is
use Ada.Text_IO;
begin
@@ -739,7 +766,7 @@ end;
\begin{pygmented}[boxing method=mdframed,lang=pascal,style=exampledefault,frametitle={Saying \emph{hello} from Pascal}]
program HelloWorld;
-
+
begin
WriteLn('Hello, world!');
end.
@@ -814,9 +841,9 @@ END Hello.
\begin{pygmented}[boxing method=mdframed,lang=go,style=exercisestyle]
// hello world in 'go'
package main
-
+
import "fmt"
-
+
func main() {
fmt.Println("Hello, world!")
}
@@ -827,7 +854,7 @@ func main() {
#import <stdio.h>
#import <Foundation/Foundation.h>
-
+
int main(void)
{
NSLog(@"Hello, world!\n");
@@ -853,6 +880,11 @@ int main(int argc, char **argv) {
}
\end{pygmented}
+\section{Debugging}
+Paths given to \verb|\inputpygmented| should be relative to the top level project
+directory, not to the file that contains the command (if that file is in a
+subdirectory). Pygmen\TeX generates only a single top-level \texttt{.snippets} file,
+and paths are not munged to account for code in subdirectories.
\section{Conclusion}
diff --git a/macros/latex/contrib/pygmentex/pygmentex_demo_2.pdf b/macros/latex/contrib/pygmentex/pygmentex_demo_2.pdf
new file mode 100644
index 0000000000..b824f9695f
--- /dev/null
+++ b/macros/latex/contrib/pygmentex/pygmentex_demo_2.pdf
Binary files differ
diff --git a/macros/latex/contrib/pygmentex/pygmentex_demo_2.tex b/macros/latex/contrib/pygmentex/pygmentex_demo_2.tex
new file mode 100644
index 0000000000..fc684fa615
--- /dev/null
+++ b/macros/latex/contrib/pygmentex/pygmentex_demo_2.tex
@@ -0,0 +1,23 @@
+\documentclass{article}
+\usepackage[T1]{fontenc}
+\usepackage[scaled=0.85]{beramono}
+\usepackage[force]{pygmentex}
+
+\begin{document}
+
+This is my C program:
+
+\begin{pygmented}[lang=c]
+#include <stdio.h>
+int main(void)
+{
+ int a, b, c;
+ printf("Enter two numbers to add: ");
+ scanf("%d%d", &a, &b);
+ c = a + b;
+ printf("Sum of entered numbers = %d\n", c);
+ return 0;
+}
+\end{pygmented}
+
+\end{document}