diff options
author | Norbert Preining <norbert@preining.info> | 2021-12-24 03:01:03 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-12-24 03:01:03 +0000 |
commit | 71bfbdc975332e32bf47112ec2d32f8491b1df40 (patch) | |
tree | 9fd890769d91f55bee8be839f70c2e41450adbac /macros | |
parent | efa3a013f699c533896b44e4fcb74c730e94ad34 (diff) |
CTAN sync 202112240301
Diffstat (limited to 'macros')
17 files changed, 2326 insertions, 431 deletions
diff --git a/macros/latex/contrib/asmejour/README.md b/macros/latex/contrib/asmejour/README.md index 18a7f825f0..067d79afe3 100644 --- a/macros/latex/contrib/asmejour/README.md +++ b/macros/latex/contrib/asmejour/README.md @@ -1,11 +1,11 @@ #asmejour: A template for ASME journal papers# - Version 1.15 dated 2021/02/01. + Version 1.16 dated 2021/12/23. ####Overview#### This class provides a template to format preprints in the style of journal papers published by the American Society of Mechanical Engineers. - The layout and reference formats follow the style of published papers in 2020. + The layout and reference formats follow the style of published papers in 2021. This work is not a publication of ASME. @@ -29,7 +29,7 @@ - closely approximate ASME's fonts and layout, including author/title/abstract design - - match ASME's current reference formats, including hyperlinked DOI and URL fields + - match ASME's current reference formats, including hyperlinked DOI and URL (replaces asmems4.bst) - support hyperlinks to figures, tables, equations, references, and external URLs @@ -64,6 +64,15 @@ --- ####Change log#### +v1.16 (2021/12/23): + - suppress warnings about unused options when calling mathalfa and/or barcolor + - eliminate use of \\entry{} with a single argument to produce subheadings in nomenclature; use \\EntryHeading{} instead. (**not backward compatible**) + - incorporate pending changes to LaTeX pdf management in relation to pdf-a color profile loading and recently deprecated \\pdfcatalog command + - load xparse only for older kernels + - edit documentation; mention \\mathversion sans and sansbold + - add upright, sans serif Greek letters for math + - minor edits to class file code; correct calls for pdfminorversion; edit warnings + - minor edits to asmejour.bst in relation to hyperlinks, \\href, \\hrefurl; update jht macro to latest style v1.15 (2021/02/01): - fix issue with math accents in mathversion sansbold (for captions) diff --git a/macros/latex/contrib/asmejour/asmejour-sample.bib b/macros/latex/contrib/asmejour/asmejour-sample.bib index 864e8f51fb..7f6e8d353d 100644 --- a/macros/latex/contrib/asmejour/asmejour-sample.bib +++ b/macros/latex/contrib/asmejour/asmejour-sample.bib @@ -1,6 +1,6 @@ %% Sample bibliography file for asmejour.bst and asmejour.cls %% -%% Revised: 30 January 2021 +%% Revised: 22 December 2022 %% Copyright John H. Lienhard, MIT %% Offered under the MIT license: https://ctan.org/license/mit @@ -12,7 +12,7 @@ author = {D. K. Edwards}, year = {1969}, title = {Radiative Transfer Characteristics of Materials}, - journal = {{ASME} J. Heat Transfer}, + journal = {{ASME} J. Heat Transfer-Trans. {ASME}}, volume = 91, number = 1, pages = {1--15}, @@ -128,14 +128,24 @@ %% note, url, urldate, urltype %% These additional fields are also supported, but are intended as alternatives to url: doi, eprint with archive +@online{kern, + author = {Uwe Kern}, + year = {2021}, + title = {Extending \LaTeX's color facilities: the \textsf{xcolor} package}, + version = {2.13}, + organization = {Comprehensive \TeX\ Archive Network}, + url = {https://ctan.org/pkg/xcolor}, + urldate = {Dec. 22, 2021}, +} + @online{sharpe1, author = {Michael Sharpe}, - year = {2018}, + year = {2021}, title = {New {TX} Font Package}, - version = {1.554}, + version = {1.659}, organization = {Comprehensive \TeX\ Archive Network}, url = {https://ctan.org/pkg/newtx}, - urldate = {Apr. 27, 2019}, + urldate = {Dec. 22, 2021}, } @article{Lienhard2019b, @@ -212,7 +222,7 @@ R. F. Boisvert and C. W. Clark and B. R. Miller and B. V. Saunders}, organization = {National Institute of Standards and Technology}, address = {Gaithersburg, MD}, - url = {http://dlmf.nist.gov/}, + url = {https://dlmf.nist.gov/}, urldate = {Dec. 22, 2018}, } @@ -220,7 +230,7 @@ author = {Richard Koch}, title = {{\TeX}{S}hop, Version 4.01}, year = {2018}, - url = {http://pages.uoregon.edu/koch/texshop/obtaining.html}, + url = {https://pages.uoregon.edu/koch/texshop/obtaining.html}, urldate = {Apr. 16, 2018}, organization = {University of Oregon}, address = {Eugene, OR}, @@ -341,7 +351,7 @@ eprint = {2060/19980228020}, } %% Equivalent links for this case: url = {https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19980228020.pdf}, -%% url = {http://hdl.handle.net/2060/19980228020} +%% url = {https://hdl.handle.net/2060/19980228020} @incollection{clauser56, author = {Francis H. Clauser}, @@ -433,7 +443,7 @@ @online{mpl, title = {mpl Colormaps}, author = {St{\'e}fan {van der Walt} and Nathaniel Smith}, - url = {http://bids.github.io/colormap/}, + url = {https://bids.github.io/colormap/}, urldate = {Aug. 26, 2018}, year = 2015, organization = {GitHub}, @@ -452,7 +462,7 @@ edition = {5}, month = aug, version = {5.00}, - url = {http://ahtt.mit.edu}, + url = {https://ahtt.mit.edu}, } @@ -497,14 +507,14 @@ } @proceedings{johnson2015, - editor = {Howard Johnson}, + editor = {Howard W. Johnson}, title = {The Title of the Proceedings}, year = 2015, volume = 2, organization = {Organization}, venue = {City, State}, eventdate = {April 27--28}, - url = {http://web.mit.edu}, + url = {https://news.mit.edu/2009/obit-johnson}, note = {Optional note}, } %% proceedings supports these fields: author OR editor, year, title, edition, editor, @@ -524,6 +534,7 @@ number = {23}, publisher = {Vulcan Free Press}, address = {T'Paal}, + note = {To appear.}, } %% One book in a series of books @@ -536,7 +547,7 @@ volume = {1}, chapter = {5}, pages = {66--89}, - url = {http://web.mit.edu}, + url = {https://www.worldcat.org/oclc/3025315}, publisher = {Houghton Mifflin Co.}, address = {Boston}, note = {{``The Locust Years''}}, diff --git a/macros/latex/contrib/asmejour/asmejour-template.pdf b/macros/latex/contrib/asmejour/asmejour-template.pdf Binary files differindex 2951bf48e7..8d6ee337d4 100644 --- a/macros/latex/contrib/asmejour/asmejour-template.pdf +++ b/macros/latex/contrib/asmejour/asmejour-template.pdf diff --git a/macros/latex/contrib/asmejour/asmejour-template.tex b/macros/latex/contrib/asmejour/asmejour-template.tex index b822063f69..9aba31970c 100644 --- a/macros/latex/contrib/asmejour/asmejour-template.tex +++ b/macros/latex/contrib/asmejour/asmejour-template.tex @@ -3,7 +3,7 @@ %% %% This file is asmejour-template.tex, a template to format papers in the style of ASME journal papers. %% -%% This file is version 1.15 dated 2021/02/01 +%% This file is version 1.16 dated 2021/12/23 %% %% Author: John H. Lienhard V %% Department of Mechanical Engineering @@ -18,7 +18,7 @@ %% * Option to omit the list of figures and list of tables at the end [nolists] %% %% * Math options from M. Sharpe's newtxmath package: upright integrals [upint]; -%% * [varvw] for a v and w that are better distinguished from greek nu; [subscriptcorrection] +%% * [varvw] for a v and w that are better distinguished from Greek nu; [subscriptcorrection] %% * to fine-tune the placement of math subscripts; and also additional options such as %% * [smallerops, varg, slantedGreek, frenchmath, varbb, cmbraces]. Version 1.6 or higher %% * is recommended. @@ -31,17 +31,21 @@ %% * misbehaves, so use it with an awareness that it can create unexpected problems. %% * This option is not compatible with line numbering. %% -%% * Options for PDF/A compliance. [pdf-a] will produce PDF/A-3u compliance with sRGB OutputIntent. -%% * [pdfapart= 1 or 2 or 3] and [pdfaconformance= b or u] allow other levels: 1b, 2b, 2u, and 3b. -%% -%% * An option to omit all the ASME text fields from the footer [nofoot]. -%% %% * Options for copyright notices: %% * Omit the ASME copyright from the footer [nocopyright] %% * Copyright footnote if all authors are government employees [govt] %% * Copyright footnote if some authors are government employees [govtsome] %% * Copyright footnote for government contractors [contractor] %% +%% * Option to omit all ASME text fields from the footer [nofoot]. +%% +%% * Options for PDF/A compliance. [pdf-a] will produce PDF/A-3u compliance with sRGB OutputIntent. +%% * [pdfapart= 1 or 2 or 3] and [pdfaconformance= b or u] can enable levels 1b, 2b, 2u, and 3b. +%% * +%% * The most recent versions of LaTeX (2021 and later) are moving toward integrated support for pdf-a, +%% * through \DeclareDocumentMetadata{..}. The asmeconf class supports these new features, which can +%% * replace the aforementioned class options. (An up-to-date LaTeX installation is required.) +%% %% * Many options for calligraphic, script, and fraktur fonts from the mathalfa package; the %% * example value used is: mathalfa=cal=euler (use Euler font for \mathcal) %% * some other options for cal are: dutchcal, zapfc, cm (default), boondox,... @@ -59,7 +63,7 @@ %% * abstract in an appendix), e.g. [french]. The main language will default to English %% * unless a different main language is selected, e.g. [main=spanish]. See Appendix C for details. %% -%% For details of the newtxmath and mathalfa packages, refer to their documentation (available at CTAN: http://ctan.org). +%% For details of the newtx and mathalfa packages, refer to their documentation (available at CTAN: http://ctan.org). %% %% The use of commands defined or modified by the asmejour class is illustrated below. In particular, some care %% is needed when using complicated math and macros in section headings, to avoid problems with pdf bookmarks, @@ -75,28 +79,30 @@ %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - %% Class options are described above. -\documentclass[subscriptcorrection,upint,varvw,mathalfa=cal=euler,barcolor=Goldenrod3,balance,hyphenate,french,pdf-a]{asmejour} +\documentclass[subscriptcorrection,upint,varvw,barcolor=Goldenrod3,mathalfa=cal=euler,balance,hyphenate,french,pdf-a]{asmejour} % + -%%%%% FIELDS TO BE COMPLETED FOLLOW %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% pdf metadata %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%% pdf metadata, the user should edit %%%%%%%%%%%%%%%%%% \hypersetup{% - pdftitle={ASME Journal Paper Template}, % <=== change to YOUR pdf file title - pdfkeywords={ASME, Paper, Template, LaTeX, BibTeX, asmejour class}, % <=== change to YOUR pdf keywords - pdfauthor={John H. Lienhard}, % <=== change to YOUR name[s]!!! + pdfauthor={John H. Lienhard}, % <=== change to YOUR name[s]! + pdftitle={ASME Journal Paper LaTeX Template}, % <=== change to YOUR pdf file title + pdfkeywords={ASME journal paper, LaTeX template, BibTeX style, asmejour class},% <=== change to YOUR pdf keywords + pdfsubject = {Describes the asmejour LaTeX template}, % <=== change to YOUR subject + pdfurl={https://ctan.org/pkg/asmejour},% may delete + pdflicenseurl={https://ctan.org/pkg/asmejour},% may delete } -%%%% Journal name and optional copyright year %%%%%%%%%%%%%% +%%%% Journal name and optional copyright year %%%%%%%%%%%%%% %% Omit "Journal of". If Journal Name is quite long, use \\ to insert a line break \JourName{Heat Transfer}%<=== change to the name of your journal %% The default copyright year is the current year -%% \PaperYear{2020} sets 2020; and \PaperYear{} omits the year entirely. +%% \PaperYear{2022} sets 2022; and \PaperYear{} omits the year entirely. -%%%%%%%%% End of Preamble %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% end of preamble %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} @@ -152,12 +158,11 @@ This paper is an example and {\upshape\LaTeX} template for the {\upshape\texttt{ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%% End of fields to be completed. Now write! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \section{Introduction} The \texttt{asmejour} class typesets papers with margins, fonts, headings, captions, and reference formats that follow those used in journals published by the American Society of Mechanical Engineers (ASME). Internal and external hyperlinks will be set automatically, and the pdf file will contain bookmarks and metadata. Many other useful features are supported. -This class is not a publication of ASME, although the author has published in ASME journals since 1984. The intended use of this package is to allow authors to format their papers in ASME style prior to submission to an ASME journal for peer review. +This class is not a publication of ASME, although the author has published in ASME journals since 1984. The intended use of this package is to enable authors to format their papers in ASME style prior to submission to an ASME journal for peer review. The \texttt{.tex} file may be written using standard \LaTeX\ commands, although some specific initial commands are needed to format the block containing the author[s], title, and abstract. The class calls a number of packages, all of which are contained in up-to-date versions of \TeX~Live, Mac\TeX, and similar platforms. If you find that you are missing a package, you may obtain it at no cost from CTAN (\href{http://ctan.org}{ctan.org}). @@ -168,12 +173,12 @@ For each author, put author names and affiliation (with line breaks) into a sepa The title should be placed into \verb|\title{..}|, and line breaks may be specified if desired. Keywords may optionally be including using the \verb|\keywords{..}| command; this command \textit{must} be issued before the abstract. To omit keywords, just omit this command. Next, the abstract text must be placed into \verb|\begin{abstract}|\ldots\verb|\end{abstract}|. The abstract will automatically be italicized. -The date is automatically given as an unnumbered footnote, which deafults to \verb|\today|. Different text may be given using \verb|\date{..}|. Putting \verb|\date{}| will suppress the date footnote. +The date is automatically given as an unnumbered footnote, which defaults to \verb|\today|. Different text may be given using \verb|\date{..}|. Putting \verb|\date{}| will suppress the date footnote. After setting up the authors, title, and abstract, issue the \verb|\maketitle| command. The introduction section comes next. -\subsection{Optional to the Color Title Bar} -The vertical bar in the title block is black in all ASME journals. Since the \texttt{asmejour} class is only for preprints, we include the [fun] option to have the bar in color. Any color \texttt{name} recognized by the \texttt{xcolor} package may be invoked by including the option \texttt{[barcolor=name]} in the \verb|\documentclass[..]{asmejour}| command. The color for this example is \texttt{Goldenrod3}. To have a black bar, either omit \texttt{barcolor} entirely or use the name \texttt{black}. +\subsection{Option to Color the Title Bar} +The vertical bar in the title block is black in all ASME journals. Since the \texttt{asmejour} class is only for preprints, we include the [fun] option to have the bar in color. Any color \texttt{name} recognized by the \texttt{xcolor} package~\cite{kern} may be invoked by including the option \texttt{[barcolor=name]} in the \verb|\documentclass[..]{asmejour}| command. The color for this example is \texttt{Goldenrod3}. To have a black bar, either omit \texttt{barcolor} entirely or use the name \texttt{black}. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -261,7 +266,7 @@ Landscape figures and tables may be produced at full-page size by putting \verb| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Reference Formatting with \texttt{asmejour.bst}} -The {\upshape\texttt{asmejour.bst}} \hologo{BibTeX} style follows the reference styles observed in ASME journals in 2020.\footnote{\texttt{asmejour.bst} is intended as a replacement for the older style \texttt{asmems4.bst}, which does not follow ASME's current reference formats or support DOI and URL.} The vast majority of published references are to journal papers and books. Examples for these and many other entry types are given in the \texttt{asmejour-sample.bib} file, which is part of this distribution. Citations and references are managed by the standard \texttt{natbib} package. +The {\upshape\texttt{asmejour.bst}} \hologo{BibTeX} style follows the reference styles observed in ASME journals in 2021.\footnote{\texttt{asmejour.bst} is intended as a replacement for the older style \texttt{asmems4.bst}, which does not follow ASME's current reference formats or support DOI and URL.} The vast majority of published references are to journal papers and books. Examples for these and many other entry types are given in the \texttt{asmejour-sample.bib} file, which is part of this distribution. Citations and references are managed by the standard \texttt{natbib} package. Nevertheless, a few comments are necessary. \subsection{Capitalization of Titles} ASME's bibliography style requires that titles be in title case. The first letters of principal words are capitalized. This must be done when writing the \texttt{.bib} file. @@ -291,6 +296,9 @@ Run 12 & 24 & 68.3 \\ }% \end{table} +%% Note: location of tables and figures can be adjusted with the options [!tbhp] +%% see: https://latexref.xyz/dev/latex2e.html#Floats + %%%%%%%%%%%%%%%%% end table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%% begin more complicated table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -327,10 +335,23 @@ The \verb|version={..}| field may be used with \verb|@book|, \verb|@online|, and %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{More on Math} -Math italics are used for roman and lower-case greek letters by default. If you want an upright letter in math, you can use the relevant math alphabet, e.g., \verb|\mathrm, \mathbf, \mathsf|: + +In most cases, long equations can be kept below the column width by using one of the multiline equation environments defined by \texttt{amsmath}, +such as \texttt{align}, \texttt{split}, or \texttt{multline}~\cite{amsmath}. The following equation is set with the \texttt{multline} environment: +\begin{multline} +\frac{\partial}{\partial t}\left[\rho\Bigl(e + \lVert\mathbf{u}\rVert^2\mspace{-3mu}\big/2\Bigr)\right] + \nabla\cdot\left[\rho\Bigl(h + \lVert\mathbf{u}\rVert^2\mspace{-3mu}\big/2 \Bigr)\mathbf{u}\right]\\ + ={}-\nabla \cdot \mathbf{q} + \rho \mathbf{u}\cdot\mathbf{g}+ \frac{\partial}{\partial x_j}\bigl(d_{ji}u_i\bigr) + \dot{Q}_v\label{eqn:energy} +\end{multline} +An example using \texttt{align} appears in Appendix~\ref{app:zetafunction}. + +An alternative solution may be to set large equations into two-column-wide tables or figures. While a package exists for setting equations that span two columns (\texttt{widetext.sty}), that code is erratic in relation to floats and page breaks. + +Math italics are used for Roman and lower-case Greek letters by default. If you want an upright letter in math, you can use the relevant math alphabet, e.g., \verb|\mathrm, \mathbf, \mathsf|: \begin{equation}\label{eqn:newton2} \vec{F} = m \vec{a} \quad\textrm{or}\quad \vec{\mathrm{F}} = m \vec{\mathrm{a}} \quad\textrm{or}\quad \mathbf{F} = m \mathbf{a} \quad\textrm{or}\quad \vec{\mathsf{F}} = m \vec{\mathsf{a}} \end{equation} +The class file also provides upright sans-serif Greek letters with \verb|\sfalpha| and similar expressions (e.g., $\sfalpha, \sfbeta, \sfgamma, \sfdelta$ \ldots $\bm{\sfalpha, \sfbeta, \sfgamma, \sfdelta \ldots}$). +% (Note that the \verb|newtxmath| options \verb|frenchmath| and \verb|slantedGreek| also affect how Greek letters are presented.) ASME typesets vectors in upright bold, like the third instance in Eq.\ \eqref{eqn:newton2}, and sets matrices in bold italic. In the next equation, $\mathbf{w}$ is a vector and $\bm{J}_1$ is a matrix: \begin{equation}\label{eqn:dw} @@ -350,21 +371,12 @@ To get additional symbols in bold math, you can use the \verb|\bm{..}| macro fro \begin{equation} \mathbf{u}_r = u_r\bm{\hat{\textbf{\i}}}+v_r\bm{\hat{\textbf{\j}}}+w_r\bm{\hat{\textbf{k}}} \end{equation} -or, \textit{very} rarely, \verb|\mathversion{bold}| for an entire equation: +or, \textit{very} rarely, \verb|\mathversion{bold}| for an entire equation\footnote{For sans-serif math expressions, \texttt{asmejour.cls} provides \texttt{\string\mathversion \{sans\}} and \texttt{\string\mathversion \{sansbold\}}. These fonts can act as engineering gothic for figures.}: \mathversion{bold}\begin{equation} S = k \ln w = k \ln \biggl(\frac{N!}{\prod_i N_i!}\biggr) \end{equation} \mathversion{normal}% avoid extra line break with % -In most cases, long equations can be kept below the column width by using one of the multiline equation environments defined by \texttt{amsmath}, -such as \texttt{align}, \texttt{split}, or \texttt{multline}~\cite{amsmath}. The following equation is set with the \texttt{multline} environment: -\begin{multline} -\frac{\partial}{\partial t}\left[\rho\Bigl(e + \lVert\mathbf{u}\rVert^2\mspace{-3mu}\big/2\Bigr)\right] + \nabla\cdot\left[\rho\Bigl(h + \lVert\mathbf{u}\rVert^2\mspace{-3mu}\big/2 \Bigr)\mathbf{u}\right]\\ - ={}-\nabla \cdot \mathbf{q} + \rho \mathbf{u}\cdot\mathbf{g}+ \frac{\partial}{\partial x_j}\bigl(d_{ji}u_i\bigr) + \dot{Q}_v\label{eqn:energy} -\end{multline} -An example using \texttt{align} appears in Appendix~\ref{app:zetafunction}. - -An alternative solution may be to set large equations into two-column-wide tables or figures. While a package exists for setting equations that span two columns (\texttt{widetext.sty}), that code is erratic in relation to floats and page breaks. \subsection{\texttt{newtxmath} and \texttt{mathalpha}} The \texttt{newtxmath} package~\cite{sharpe1}, loaded by default, includes a large number of options for mathematics, most of which can be called as options to \verb|\documentclass|. For example, the \texttt{upint} option of \texttt{newtxmath} selects upright integral signs (rather than slanted integral signs): \begin{quote} @@ -381,12 +393,12 @@ To see all the font options, refer to the \texttt{mathalfa} documentation \cite{ The class is designed for use with \texttt{newtxmath} and does not support the \texttt{unicode-math} package. -%% Dealing with complicated math in a section heading: optional argument of \section provides the pdfbookmark +%% Dealing with complicated math in a section heading: optional argument of \section provides the pdf bookmark %% without losing characters or producing warnings/errors. Note that bookmark can include simple math and \eqref{..}. %% newtxmath provides the option for upright Greek letters as \upomega (vs. \omega), etc. \subsection[Math in a Section Heading: \omega\cdot U=0]{Math in a Section Heading: $\tilde{\upomega}\cdot\hat{\mathrm{U}}=0$} -To include complicated math in a section heading without producing bookmark-related errors, use the optional argument of \verb|\section| to create the pdfbookmark. The heading above was set with the following command: +To include complicated math in a section heading without producing bookmark-related errors, use the optional argument of \verb|\section| to create the pdf bookmark. The heading above was set with the following command: \begin{quote}\raggedright \verb|\subsection[Math in a Section Heading:| \hspace*{1em}\verb|\omega\cdot U=0]{Math in a Section Heading:| @@ -395,7 +407,27 @@ To include complicated math in a section heading without producing bookmark-rela Note that bookmarks can include simple math. Also note that \texttt{newtxmath} provides the option to obtain upright Greek letters, such as \verb|\upomega| (vs.\ \verb|\omega|). -\subsection{Units and Nomenclature} ASME requires SI units. U.~S.\ style units may be follow in parentheses. Be sure to put your symbols into the nomenclature list, including the SI units. +\subsection{Units and Nomenclature} ASME requires SI units. U.~S.\ style units may follow in parentheses. Be sure to put your symbols into the nomenclature list, including the SI units. + + +%%%%%%%%%%%%%%%%%%% begin linewidth table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\begin{table}[t] +\newcolumntype{C}{>{$}c<{$}} % math-mode version of "c" column type, from array package +\caption{\label{tab:3}Table at full column width with columns in math mode} +\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}CCCC@{\extracolsep{\fill}}} +\toprule +X_{z} & X_{c} & X_{c,m} & X_{c,2}\rule{0pt}{8pt}\\ + 3.92069 & 5.70943 & 6.32429 & 7.08757\\[2pt] +\varepsilon (T_1) & \varepsilon^i (T_1) & \varepsilon^i (T_m) & \alpha (T_1, T_2)\\ +0.7258 & 0.6237 & 0.6807 & 0.7964 \\[2pt] +q_\textrm{gray} & q_\textrm{int, $T_1$} & q_\textrm{int, $T_m$} & q_\textrm{exact}\\ +400.2 & 462.1 & 371.0 & 371.8 \\ +\bottomrule +\end{tabular*} +\end{table} + +%%%%%%%%%%%%%%%%%%%% end linewidth table %%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -424,30 +456,12 @@ default setting is for PDF/A-3u with sRGB OutputIntent (\texttt{sRGB.icc}). If l options \texttt{[pdfapart=1 or 2 or 3]} and \texttt{[pdfaconformance=b or u]}. Note that accessible conformance~(\texttt{a}) is not currently possible with \LaTeX. -\subsection{Superiors Font} The \texttt{newtxtext} package includes a superiors font (numbers and letters) for use in footnote markers and superscripts. The option \texttt{[nodefaultsups]} enables this font. (The corresponding author mark in the author block will not change.) - -\subsection{Typewriter Font Options} This font is the sans-serif, monospaced font \texttt{inconsolata}. By default, the word spacing is variable, but option \texttt{[mono]} ends this behavior. A slashed zero is the default; option \texttt{[var0]} removes the slash. Option \texttt{[hyphenate]} enables hyphenation of the typewriter font.%(This option is not available if the \texttt{[fontspec]} option is used.) - - -%%%%%%%%%%%%%%%%%%% begin linewidth table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +As of late 2021, the \LaTeX 3 team is phasing in native support for PDF/A in the \LaTeX\ kernel, which eventually will make these +class options unnecessary when using an up-to-date installation. -\begin{table}[t] -\newcolumntype{C}{>{$}c<{$}} % math-mode version of "c" column type, from array package -\caption{\label{tab:3}Table at full column width with columns in math mode} -\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}CCCC@{\extracolsep{\fill}}} -\toprule -X_{z} & X_{c} & X_{c,m} & X_{c,2}\rule{0pt}{8pt}\\ - 3.92069 & 5.70943 & 6.32429 & 7.08757\\[2pt] -\varepsilon (T_1) & \varepsilon^i (T_1) & \varepsilon^i (T_m) & \alpha (T_1, T_2)\\ -0.7258 & 0.6237 & 0.6807 & 0.7964 \\[2pt] -q_\textrm{gray} & q_\textrm{int, $T_1$} & q_\textrm{int, $T_m$} & q_\textrm{exact}\\ -400.2 & 462.1 & 371.0 & 371.8 \\ -\bottomrule -\end{tabular*} -\end{table} - -%%%%%%%%%%%%%%%%%%%% end linewidth table %%%%%%%%%%%%%%%%%%%%%%% +\subsection{Superiors Font} The \texttt{newtxtext} package includes a superiors font (numbers and letters) for use in footnote markers and superscripts. The option \texttt{[nodefaultsups]} enables this font. (The corresponding author mark in the author block will not change.) +\subsection{Typewriter Font Options} This font is the sans-serif, monospaced font \texttt{inconsolata}. By default, the word spacing is variable, but option \texttt{[mono]} ends this behavior. A slashed zero is the default; option \texttt{[var0]} removes the slash. Option \texttt{[hyphenate]} enables hyphenation of the typewriter font. %%%%%%%%%%%%%%% begin two column table %%%%%%%%%%%%%%%%%% @@ -483,8 +497,9 @@ q_\textrm{gray} & q_\textrm{int, $T_1$} & q_\textrm{int, $T_m$} & q_\textrm{exa %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Conclusions} + The class \texttt{asmejour} and associated files are for typesetting preprints in the style of ASME journals. -Documentation is provided in this file and by comments in the \texttt{.tex} source code. Examples of references are shown in the \texttt{asmejour-sample.bib} file. The \texttt{asemjour.bst} file produces references following ASME's current formats. The code is compatible with both {\hologo{pdfLaTeX}} and \LuaLaTeX. This package is not a publication of ASME and is offered at no cost under the terms of the \href{https://ctan.org/license/mit}{MIT license}. +Documentation is provided in this file and by comments in the \texttt{.tex} source code. Examples of references are shown in the \texttt{asmejour-sample.bib} file. The \texttt{asemjour.bst} file produces references following ASME's current formats. The code is compatible with both {\hologo{pdfLaTeX}} and \LuaLaTeX. This package is not a publication of ASME and is offered at no cost under the terms of the \hrefurl{https://ctan.org/license/mit}{MIT license}. \begin{enumerate} \item First conclusion @@ -501,6 +516,7 @@ Acknowledge individuals, institutions, or companies that supported the authors i %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section*{Funding Data} + \begin{itemize} \item U.S.\ Department of Heat Transfer, Office of Important Ideas (DOHT-OII Award No.\ 3.14159265) \end{itemize} @@ -536,7 +552,7 @@ Acknowledge individuals, institutions, or companies that supported the authors i \end{nomenclature} -%%%%%%%%%%%%%%% APPENDICES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%% APPENDICES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Note that appendices will be "numbered" A, B, C, ... etc. Use \section, not \section* %% Subsections need not be numbered, use \subsection* @@ -576,21 +592,25 @@ The standard caption and section names will follow \texttt{babel}'s dictionary f The font encoding is set to T1 and utf-8 input is supported: %% If you have trouble with the next line (or the French text that follows), your file may not be saved in utf-8 format. You can delete these lines to resolve the issue. \typeout{If you have trouble with the next line, your file may not be saved in utf-8 format. You can delete that line to resolve the issue.} -àáâäæãåā èéęëêēė îïíīįì ôöòóœøōõ ûüùúū çćč ł ñń ßśš ÿ žźż - +\ifluatex\typeout{Under LuaLaTeX, some of these accents must be obtained as escaped characters, with \=a, \c{e}, \l, \.o, \oe, \v{z}, \'z, etc.}\fi +àáâäæãåā èéęëêēė îïíīįì ôöòóœøōõ ûüùúū çćč ł ñń ßśš ÿ žźż + No effort has been made to support customization of language-specific fonts (some fonts can be implemented using the \texttt{substitutefont} package~\cite{milde}). The bibliography style, \texttt{asmejour.bst}, is designed in English and aimed at \texttt{BibTeX}. Multilingual bibliographies can be supported using \texttt{BibLaTeX}. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \selectlanguage{french} \section{Discours Préliminaire de Fourier}\label{app:fourier} + Les causes primordiales ne nous sont point connues; mais elles sont assujetties à des lois simples et constantes, que l'on peut découvrir par l'observation, et dont l'étude est l'objet de la philosophie naturelle. La chale ur pénètre, comme la gravité, toutes les substances de l'univers, ses rayons occupent toutes les parties de l'espace. Le but de notre ouvrage est d'exposer les lois mathématiques que suit cet élément. Cette théorie formera désormais une des branches les plus importantes de la physique générale~\cite{fourier1822}. \selectlanguage{english} +% When you drop the [french] option, delete your .aux file as well, since [french] sets ":" as an active character. + -%%%%%%%%%%%%% BIBLIOGRAPHY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%% BIBLIOGRAPHY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \nocite{*} %% <=== delete this line - unless you wish to typeset the entire contents of your .bib file. diff --git a/macros/latex/contrib/asmejour/asmejour.bst b/macros/latex/contrib/asmejour/asmejour.bst index babfdabbaa..d3cb99b2e1 100644 --- a/macros/latex/contrib/asmejour/asmejour.bst +++ b/macros/latex/contrib/asmejour/asmejour.bst @@ -4,13 +4,13 @@ %% *** This bibtex style follows ASME journals *** %% %% - %% This file is asmejour.bst, fourth 1.04 dated 2020/04/15. + %% This file is asmejour.bst, version 1.05 dated 2021/12/23. %% %% This file was generated and edited by John Lienhard. %% This file is a derivative work under Clause 6 of the LPPL license. %% %% The generated file and the modifications are based on the formats that ASME is using in - %% published journal papers in early 2020. Details of the modifications follow. + %% published journal papers in early 2022. Details of the modifications follow. %% %% Created entry: @online{...} for web publications (and aliased it to @www and @electronic) %% Created fields: eventdate, urldate, urltype, venue, fourth, fourthtype @@ -64,12 +64,18 @@ %% provide format.alt.link to print the hyperlink if the report number is empty. %% provide institution.address function %% - %% Modifications in v1.04 ( ) + %% Modifications in v1.04 (2020/04/15) %% add hdl macro as a synonym for hndl %% separate format.serial.volume from format.bvolume; %% arrange format.bvolume to order vol and series as ", Vol. X of Series Title", which affects %% @book, @inbook, @incollection, and @proceedings. %% + %% Modifications in v1.05 (2021/12/23) + %% convert remaining http:// prefixes to https:// + %% replace \href{}{} in \eprint by \url + %% provide \hrefurl for compatibility with LaTeX3 pdfmanagement + %% use \hrefurl in doilink, rather than \href + %% add macro text for "ASME J. Heat Transfer-Trans. ASME" %% %% Author: John H. Lienhard V %% Department of Mechanical Engineering @@ -487,16 +493,16 @@ FUNCTION {eng.ord} MACRO {arxiv} {"https://arxiv.org/abs/"} -MACRO {googlebooks} {"http://books.google.com/books?id="} +MACRO {googlebooks} {"https://books.google.com/books?id="} -MACRO {hdl} {"http://hdl.handle.net/"} -MACRO {hndl} {"http://hdl.handle.net/"} +MACRO {hdl} {"https://hdl.handle.net/"} +MACRO {hndl} {"https://hdl.handle.net/"} -MACRO {jstor} {"http://www.jstor.org/stable/"} +MACRO {jstor} {"https://www.jstor.org/stable/"} -MACRO {oclc} {"http://www.worldcat.org/oclc/"} +MACRO {oclc} {"https://www.worldcat.org/oclc/"} -MACRO {pubmed} {"http://www.ncbi.nlm.nih.gov/pubmed/"} +MACRO {pubmed} {"https://www.ncbi.nlm.nih.gov/pubmed/"} MACRO {amr} {"Appl. Mech. Rev."} @@ -529,7 +535,7 @@ MACRO {jfe} {"ASME J. Fluids Eng."} MACRO {jfcst} {"ASME J. Fuel Cell Sci. Tech."} -MACRO {jht} {"ASME J. Heat Transfer"} +MACRO {jht} {"ASME J. Heat Transfer-Trans. ASME"} MACRO {jmse} {"ASME J. Manuf. Sci. E."} @@ -835,13 +841,13 @@ FUNCTION {doilink} { url empty$ { eprint empty$ { skip$ } - { "\href{" archive eprint * * "}{" * swap$ * "}" * } + { "\hrefurl{" archive eprint * * "}{" * swap$ * "}" * } if$ } - { "\href{" url * "}{" * swap$ * "}" * } + { "\hrefurl{" url * "}{" * swap$ * "}" * } if$ } - { "\href{https://doi.org/" doi * "}{" * swap$ * "}" * } + { "\hrefurl{https://doi.org/" doi * "}{" * swap$ * "}" * } if$ } if$ @@ -1912,7 +1918,9 @@ FUNCTION {begin.bib} write$ newline$ " \providecommand{\doi}{doi:\discretionary{}{}{}\begingroup \urlstyle{rm}\Url}\fi" write$ newline$ - "\providecommand{\eprint}[2][]{\href{#1#2}{#1#2}}" + "\providecommand{\eprint}[2][]{\urlprefix\url{#1#2}}" + write$ newline$ + "\providecommand{\hrefurl}[2][]{\href{#1}{#2}}" write$ newline$ } EXECUTE {begin.bib} diff --git a/macros/latex/contrib/asmejour/asmejour.cls b/macros/latex/contrib/asmejour/asmejour.cls index e5a6b6bdc1..48c33b0ed8 100644 --- a/macros/latex/contrib/asmejour/asmejour.cls +++ b/macros/latex/contrib/asmejour/asmejour.cls @@ -6,8 +6,8 @@ %% %% %% This file's version and date are: - \def\versionno{1.15} - \def\versiondate{2021/02/01\space} + \def\versionno{1.16} + \def\versiondate{2021/12/23\space} %% %% Author: John H. Lienhard V %% Department of Mechanical Engineering @@ -28,7 +28,8 @@ %% 10. Support inclusion of passages in languages other than English %% %% This class is compatible with either pdfLaTeX or LuaLaTeX. All packages required by the class -%% are in standard distributions, such as TeXLive, and are also available at CTAN (https://ctan.org/). +%% are in standard distributions, such as TeXLive, and are also available at CTAN (https://ctan.org/). +%% The use of an up-to-date, complete distribution is strongly recommended. %% %% The title block is set by specific commands that are described in the asmejour-template.tex file. %% @@ -66,11 +67,24 @@ \LoadClass[twoside,9pt,twocolumn]{extarticle} -\RequirePackage{xparse}% \entry{} command uses deprecated g argument; will drop this eventually -\RequirePackage{etoolbox}% dropped xpatch 28/02/20 +\ifdefined\NewDocumentCommand\else + \RequirePackage{xparse} +\fi + +\RequirePackage{etoolbox}% dropped xpatch 2020/02/28 \RequirePackage{ifthen} \RequirePackage{iftex}% check whether pdftex or another engine is used +\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}% backward compatibility (Thanks Ulrike Fischer) + +\DeclareDocumentCommand\LogNote{m}{% + \IfFormatAtLeastTF{2021/11/15}{% + \ClassNoteNoLine{asmejour}{#1}% New with this recent format + }{% + \ClassWarningNoLine{asmejour}{#1}% + } +} + %%%%%%%%%%%%%% Options for the class %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \RequirePackage{kvoptions}% this package calls kvsetkeys @@ -107,7 +121,7 @@ \aj@mainsettrue \ifthenelse{\equal{#1}{english}}{% \PassOptionsToPackage{pdflang=en}{hyperref}}{% - \ClassWarningNoLine{asmejour}{Selecting #1 as the primary language}% + \LogNote{Selecting #1 as the primary language} }% } @@ -118,7 +132,7 @@ \aj@mainsettrue% \ifthenelse{\equal{#1}{english}}{% \relax}{% - \ClassWarningNoLine{asmeconf}{Selecting #1 as the primary language}% + \LogNote{Selecting #1 as the primary language}% }% } \define@key{asmejour}{lang-second}[english]{% deprecated option @@ -132,9 +146,12 @@ \ifaj@mainset\relax\else \PassOptionsToPackage{main=english}{babel}% \PassOptionsToPackage{pdflang=en}{hyperref} - %\ClassWarningNoLine{asmejour}{Selecting English as the primary language, since main= not set}% + \ClassInfo{Selecting English as the primary language, since main= not set}% \fi +%% Suppress warnings about unused global options, 2021/12/01 +\DeclareDefaultOption{}% suppress warning about unused mathalfa and barcolor options + \ProcessKeyvalOptions{asmejour} %% Turn off these keys now that we're done with them @@ -149,36 +166,40 @@ \@DisableKeys{nodefaultsups;mathalfa;barcolor;main;lang;lang-second;lang-third} -%%%%%%% PDF/A Compliance Options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%% PDF/A Compliance Keys %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newif\ifaj@setpdfa\aj@setpdfafalse \newif\ifaj@pdfaone\aj@pdfaonefalse -\ifpdftex %% PDF/A compliance has only been configured for pdflatex +\ifpdftex %% pdf/a compliance has only been configured for pdflatex % -%%% set key [pdfa] to activate pdf/a compliance (default is pdf/A-3u) + %%% set key [pdfa] to activate pdf/a compliance (default is pdf/A-3u) \define@key{pdfaopt}{pdf-a}[true]{% \aj@setpdfatrue \PassOptionsToPackage{pdfa,pdfapart=3,pdfaconformance=u}{hyperref}% -} -%%% to select part 1, 2 or 3 + } + %%% to select part 1, 2 or 3 \define@key{pdfaopt}{pdfapart}[3]{% \PassOptionsToPackage{pdfapart=#1}{hyperref}% \ifthenelse{\equal{#1}{1}}{\aj@pdfaonetrue}{\relax}% -} -%% to select conformance b or u. NB: a is not possible with pdfLaTeX, and u is not possible with 1. + } + %% to select conformance b or u. NB: a is not possible with pdfLaTeX, and u is not possible with 1. \define@key{pdfaopt}{pdfaconformance}[u]{% \PassOptionsToPackage{pdfaconformance=#1}{hyperref}% -} - \ProcessKeyvalOptions{pdfaopt} + } \else - \ifaj@pdfaone\ClassWarningNoLine{asmejour}{PDF/A compliance option requires pdfLaTeX engine}\fi% + \define@key{pdfaopt}{pdf-a}[true]{% + \aj@setpdfatrue + } \fi +\ProcessKeyvalOptions{pdfaopt} + %% Done with these keys, so we can now disable them \def\@KeyFamily{pdfaopt} \@DisableKeys{pdf-a;pdfapart;pdfaconformance} + %%%%%%%%%% Further class options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Option to obtain line numbers [lineno] @@ -225,11 +246,11 @@ \newif\ifaj@contractor\aj@contractorfalse \DeclareOption{contractor}{\aj@contractortrue} -%% Option for slightly larger small capitals font [largesc], corrected 29 Jan 2021 +%% Option for slightly larger small capitals font [largesc], corrected 2021/01/29 \DeclareOption{largesc}{\PassOptionsToPackage{largesc=true}{newtxtext}}% largesc is a boolean key in newtxtext %% ASME word separation is greater than newtxtext defaults so change these parameters. -\PassOptionsToPackage{spacing=0.3em, stretch=0.18em, shrink=0.10em}{newtxtext}% increased shrink from 0.08, 30 Jan 21 +\PassOptionsToPackage{spacing=0.3em, stretch=0.18em, shrink=0.10em}{newtxtext}% increased shrink from 0.08, 2021/01/30 %% Option not to use latex default superscripts, instead using the newtxtext superiors font [nodefaultsups] \ifthenelse{\boolean{DefaultSups}}{\PassOptionsToPackage{defaultsups}{newtxtext}}{\relax} @@ -242,7 +263,7 @@ %% Option to hyphenate the typewriter font [hyphenate] \DeclareOption{hyphenate}{% \PassOptionsToPackage{hyphenate}{inconsolata}% - \ClassWarningNoLine{asmejour}{Allowing hyphenation of typewriter font}% + \LogNote{Allowing hyphenation of typewriter font}% } %% Option to enforce monospacing of words the typewriter font [mono] \DeclareOption{mono}{% @@ -253,7 +274,7 @@ \PassOptionsToPackage{var0}{inconsolata}% var0 is a key via xkeyval in inconsolata } -%% Suppress warnings about mathalfa keys as unused global options +%% Suppress warnings about keys as unused global options \DeclareOption*{} \ProcessOptions \relax @@ -266,7 +287,7 @@ %% ASME's pdf pages are 11.25 in. tall, not 11.00 in. \RequirePackage[sort&compress,numbers]{natbib} -\AtBeginDocument{\def\NAT@space{\relax}}% ASME puts no space between numerical references (4/5/20) +\AtBeginDocument{\def\NAT@space{\relax}}% ASME puts no space between numerical references (2020/04/05) \setlength\bibsep{0pt plus 1pt minus 0pt}% ASME keeps this tight \renewcommand*{\bibfont}{\footnotesize} @@ -295,10 +316,9 @@ \renewcommand*{\midrule}{\specialrule{0.5pt}{2pt}{3pt}} \renewcommand*{\bottomrule}{\specialrule{0.5pt}{1pt}{\doublerulesep}\specialrule{0.5pt}{0pt}{0pt}} -%%%%%%%%%%%%% Font related %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - +%%%%%%%%%%%%% PDF/A related %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifpdftex - \ifaj@setpdfa + \ifaj@pdfaone \pdfminorversion=4 % for pdf/a-1 need version 4, not 7 \else \pdfminorversion=7 % this selection is not required @@ -306,9 +326,25 @@ \RequirePackage[T1]{fontenc} \RequirePackage[utf8]{inputenc}% for backward compatibility with pre-2018 LaTeX distributions \else - \relax % will lose some accented characters this way... better to use fontspec... if the systems fonts exist... + \ifaj@setpdfa\ClassWarningNoLine{asmejour}{pdf-a option requires pdfLaTeX engine. Under LuaLaTeX, use % + \protect\DeclareDocumentMetadata{pdfstandard=A-3b} before \protect\begin{document}}\fi% + \ifluatex + \directlua{ + if pdf.getminorversion() \string~= 7 then + if (status.pdf_gone and status.pdf_gone > 0) + or (status.pdf_ptr and status.pdf_ptr > 0) then + tex.error("PDF version cannot be changed anymore") + else + pdf.setminorversion(7) + end + end + \fi + }% will lose some accented characters this way... better to use fontspec, if the systems fonts exist. \fi + +%%%%%%%%%%%%% Font related %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \RequirePackage{mathtools}% loads and extends amsmath \RequirePackage[]{babel} @@ -340,14 +376,13 @@ \tolerance 2500 \emergencystretch 3em -\setlength{\jot}{10pt}% <== default is 3pt - -%% multline has an "extra line" above it, so subtract from \abovedisplayskip to remove imbalance -\BeforeBeginEnvironment{multline}{\addtolength\abovedisplayskip{-7pt}} -\AfterEndEnvironment{multline}{\addtolength\abovedisplayskip{+7pt}} - -\allowdisplaybreaks % ASME allows these breaks - +%% TeX Gyre Heros Condensed is qhvc (regular is qhv). +\newcommand*{\CondSans}{\selectfont\fontfamily{qhvc}\selectfont} +\renewcommand\huge{\@setfontsize\huge{14}{14}} %... for author names only +\newcommand*{\CondSansBold}{\renewcommand\bfdefault{b}\selectfont\fontfamily{qhvc}\selectfont\bfseries} +\renewcommand\Huge{\@setfontsize\Huge{26.5}{26.5}} %... for title font only + +\RequirePackage{metalogo,hologo}% Access to various LaTeX logos (for use in the documentation) %% This provides sans serif italic and sans serif bold italic math. %% It's intended for use in the figure and table captions. @@ -356,13 +391,13 @@ \SetSymbolFont{letters}{sansbold}{OML}{ntxsfmi}{b}{it} \SetSymbolFont{lettersA}{sansbold}{U}{ntxsfmia}{b}{it} \SetSymbolFont{symbols}{sansbold}{LMS}{ntxsy}{b}{n} -\SetSymbolFont{largesymbols}{sansbold}{LMX}{ntxexx}{b}{n}% added 26 Jan 2021 -\SetSymbolFont{largesymbolsTXA}{sansbold}{U}{ntxexa}{b}{n}% added 26 Jan 2021 +\SetSymbolFont{largesymbols}{sansbold}{LMX}{ntxexx}{b}{n}% added 2021/01/26 +\SetSymbolFont{largesymbolsTXA}{sansbold}{U}{ntxexa}{b}{n}% added 2021/01/26 \SetSymbolFont{operators}{sansbold}{\encodingdefault}{\sfdefault}{\bfdefault}{n} \SetMathAlphabet{\mathsf}{sansbold}{\encodingdefault}{\sfdefault}{b}{n}% \mathsf is upright %% These lines are to provide math accents for the sans and sansbold math versions. -%% The accents from ntxsfmi work normally with regular times fonts. Added 27 Jan 2021 +%% The accents from ntxsfmi work normally with regular times fonts. Added 2021/01/27 \DeclareSymbolFont{lettersAB}{U}{ntxsfmia}{m}{it} \SetSymbolFont{lettersAB}{normal}{U}{ntxsfmia}{m}{it} \SetSymbolFont{lettersAB}{bold}{U}{ntxsfmia}{b}{it} @@ -379,8 +414,66 @@ \DeclareMathAccent{\dot}{\mathord}{lettersAB}{224} \DeclareMathAccent{\tilde}{\mathord}{lettersAB}{219} +%% Provide sans-serif *upright* Greek letters, following a suggestion by Michael Sharpe. 2021/12/22 +%% Following Sharpe's newtxsf implementation of the STIX fonts, under the LaTeX Project Public License. +%% (Note that \mathversion{sansbold} provides sans-serif *italic* Greek letters.) + +\DeclareMathSymbol{\sfGamma}{\mathalpha}{lettersAB}{0}% adjust to avoid overwriting newtxmath commands, +\DeclareMathSymbol{\sfDelta}{\mathalpha}{lettersAB}{1} +\DeclareMathSymbol{\sfTheta}{\mathalpha}{lettersAB}{2} +\DeclareMathSymbol{\sfLambda}{\mathalpha}{lettersAB}{3} +\DeclareMathSymbol{\sfXi}{\mathalpha}{lettersAB}{4} +\DeclareMathSymbol{\sfPi}{\mathalpha}{lettersAB}{5} + +\DeclareMathSymbol{\sfSigma}{\mathalpha}{lettersAB}{6} +\DeclareMathSymbol{\sfUpsilon}{\mathalpha}{lettersAB}{7} +\DeclareMathSymbol{\sfPhi}{\mathalpha}{lettersAB}{8} +\DeclareMathSymbol{\sfPsi}{\mathalpha}{lettersAB}{9} +\DeclareMathSymbol{\sfOmega}{\mathalpha}{lettersAB}{10} + +\DeclareMathSymbol{\sfalpha}{\mathalpha}{lettersAB}{11} +\DeclareMathSymbol{\sfbeta}{\mathalpha}{lettersAB}{12} +\DeclareMathSymbol{\sfgamma}{\mathalpha}{lettersAB}{13} +\DeclareMathSymbol{\sfdelta}{\mathalpha}{lettersAB}{14} +\DeclareMathSymbol{\sfepsilon}{\mathalpha}{lettersAB}{15} + +\DeclareMathSymbol{\sfzeta}{\mathalpha}{lettersAB}{16} +\DeclareMathSymbol{\sfeta}{\mathalpha}{lettersAB}{17} +\DeclareMathSymbol{\sftheta}{\mathalpha}{lettersAB}{18} +\DeclareMathSymbol{\sfiota}{\mathalpha}{lettersAB}{19} +\DeclareMathSymbol{\sfkappa}{\mathalpha}{lettersAB}{20} + +\DeclareMathSymbol{\sflambda}{\mathalpha}{lettersAB}{21} +\DeclareMathSymbol{\sfmu}{\mathalpha}{lettersAB}{22} +\DeclareMathSymbol{\sfnu}{\mathalpha}{lettersAB}{23} +\DeclareMathSymbol{\sfxi}{\mathalpha}{lettersAB}{24} +\DeclareMathSymbol{\sfpi}{\mathalpha}{lettersAB}{25} + +\DeclareMathSymbol{\sfrho}{\mathalpha}{lettersAB}{26} +\DeclareMathSymbol{\sfsigma}{\mathalpha}{lettersAB}{27} +\DeclareMathSymbol{\sftau}{\mathalpha}{lettersAB}{28} +\DeclareMathSymbol{\sfUpsilon}{\mathalpha}{lettersAB}{29} +\DeclareMathSymbol{\sfphi}{\mathalpha}{lettersAB}{30} + +\DeclareMathSymbol{\sfchi}{\mathalpha}{lettersAB}{31} +\DeclareMathSymbol{\sfpsi}{\mathalpha}{lettersAB}{32} +\DeclareMathSymbol{\sfomega}{\mathalpha}{lettersAB}{33} +\DeclareMathSymbol{\sfvarepsilon}{\mathalpha}{lettersAB}{34} +\DeclareMathSymbol{\sfvartheta}{\mathalpha}{lettersAB}{35} + +\DeclareMathSymbol{\sfvarpi}{\mathord}{lettersAB}{36} +\DeclareMathSymbol{\sfvarrho}{\mathord}{lettersAB}{37} +\DeclareMathSymbol{\sfvarsigma}{\mathord}{lettersAB}{38} +\DeclareMathSymbol{\sfvarphi}{\mathord}{lettersAB}{39} +\DeclareMathSymbol{\sfitvarkappa}{\mathalpha}{lettersAB}{40} +\DeclareMathSymbol{\sfvarkappa}{\mathalpha}{lettersAB}{40} +\DeclareMathSymbol{\sfitnabla}{\mathalpha}{lettersAB}{42} +\DeclareMathSymbol{\sfnabla}{\mathalpha}{lettersAB}{43} +\DeclareMathSymbol{\sfhslash}{\mathalpha}{lettersAB}{52}% this is not upright +\DeclareMathSymbol{\sfhbar}{\mathalpha}{lettersAB}{53}% this is not upright + %%% sans math version, potential value with PGFPlots, and provisionally called in subfigure captions. -%%% this is experimental, still needs stress testing. 30/01/2021 +%%% this is experimental, still needs stress testing. 2021/01/30 \DeclareMathVersion{sans} \SetSymbolFont{letters}{sans}{OML}{ntxsfmi}{m}{it} \SetSymbolFont{lettersA}{sans}{U}{ntxsfmia}{m}{it} @@ -391,13 +484,17 @@ \SetSymbolFont{operators}{sans}{\encodingdefault}{\sfdefault}{m}{n} \SetMathAlphabet{\mathsf}{sans}{\encodingdefault}{\sfdefault}{m}{n} -%% TeX Gyre Heros Condensed is qhvc (regular is qhv). -\newcommand*{\CondSans}{\selectfont\fontfamily{qhvc}\selectfont} -\renewcommand\huge{\@setfontsize\huge{14}{14}} %... for author names only -\newcommand*{\CondSansBold}{\renewcommand\bfdefault{b}\selectfont\fontfamily{qhvc}\selectfont\bfseries} -\renewcommand\Huge{\@setfontsize\Huge{26.5}{26.5}} %... for title font only - -\RequirePackage{metalogo,hologo}% Access to various LaTeX logos (for use in the documentation) + +%%%%%%%%%%%%%%%%% Some adjustments to math layout %%%%%%%%%%%%%%%%%%%%%%%%%%% + +\setlength{\jot}{10pt}% <== default is 3pt + +%% multline has an "extra line" above it, so subtract from \abovedisplayskip to remove imbalance +\BeforeBeginEnvironment{multline}{\addtolength\abovedisplayskip{-7pt}} +\AfterEndEnvironment{multline}{\addtolength\abovedisplayskip{+7pt}} + +\allowdisplaybreaks % ASME allows these breaks + %%%%%%%%%%%%%%%%% Equation and Line Numbering %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -414,7 +511,7 @@ \renewcommand{\linenumberfont}{\normalfont\footnotesize\color{red}}% \AtBeginDocument{\linenumbers}% \ifaj@balance - \ClassWarningNoLine{asmejour}{Package lineno loaded, so final column balancing will be disabled}% + \ClassWarningNoLine{asmejour}{Package lineno loaded, so final column balancing will be disabled}% \fi %%% Allow line numbering in AMS math environments. %%% postdisplaypenalty adjusted to avoid extra line number at end, see discussion here: https://tex.stackexchange.com/a/461192/ @@ -437,7 +534,7 @@ \ifaj@balance % balancing through flushend can produce weird errors \RequirePackage{flushend}% flushend package is NOT compatible with lineno \AtEndDocument{\flushcolsend}% - \ClassWarningNoLine{asmejour}{Calling flushend package to balance column height on last page}% + \LogNote{Calling flushend package to balance column height on last page}% \fi% \fi @@ -517,9 +614,9 @@ %% Produces an unmarked footnote about the revision date. %% This command is invoked by \date as part of \MakeTitlePage below. %% Text can be anything given as the argument to \date{..}. -\NewDocumentCommand{\revfootnote}{m}{\begin{NoHyper}\gdef\@thefnmark{}\@footnotetext{\hspace{-3pt}#1}\end{NoHyper}} +\NewDocumentCommand{\revfootnote}{m}{\begin{NoHyper}\def\@thefnmark{}\@footnotetext{\hspace{-3pt}#1}\end{NoHyper}}% \gdef -->\def 2021/12/23 -%% The above has been offset per style and modified to eliminate missing anchor warning from hyperref that following causes +%% The above has been offset per style and modified to eliminate missing anchor warning from hyperref that the following version causes %%\def\revfootnote{\gdef\@thefnmark{}\@footnotetext} @@ -603,36 +700,61 @@ %%%%%%%%%%%%%%%%% Hyperref %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\ifaj@setpdfa -% - %%% to assist with unicode glyph mapping, following M. Sharpe's recommendation in newtx documentation. - \pdfgentounicode=1 %% enable CMaps - \input glyphtounicode.tex %% lists of mappings - \InputIfFileExists{glyphtounicode-cmr.tex}{}{} %% additional mappings - \InputIfFileExists{glyphtounicode-ntx.tex}{}{} %% additional mappings -% -%%% a fairly generic RGB color profile, aimed at on-screen rendering (not print production) -\immediate\pdfobj stream attr{/N 3} file{sRGB.icc} -\pdfcatalog{% - /OutputIntents [ - << - /Type /OutputIntent - /S /GTS_PDFA1 - /DestOutputProfile \the\pdflastobj\space 0 R - /OutputConditionIdentifier (sRGB) - /Info (sRGB) - >> - ] -} +\newif\if@asme@pdfmanagement% Thanks to Ulrike Fischer +\ExplSyntaxOn +\bool_if:nTF + { + \bool_lazy_and_p:nn + {\cs_if_exist_p:N \pdfmanagement_if_active_p:} + { \pdfmanagement_if_active_p: } + } + { + \@asme@pdfmanagementtrue + } + { + \@asme@pdfmanagementfalse + } +\ExplSyntaxOff + +\ifpdftex + %%% to assist with unicode glyph mapping, following M. Sharpe's recommendation in the newtx documentation. + \IfFormatAtLeastTF{2020/10/01}{\relax}{% + \pdfgentounicode=1 %% enable CMaps; has moved into the latex kernel Oct 2020 + \input glyphtounicode.tex %% lists of mappings; has moved into the latex kernel Oct 2020 + } + \InputIfFileExists{glyphtounicode-cmr.tex}{}{} %% additional mappings + \InputIfFileExists{glyphtounicode-ntx.tex}{}{} %% additional mappings + + \ifaj@setpdfa + %%%% the pdfmanagement options are experimental, from Ulrike Fischer 2021/06/12 + \if@asme@pdfmanagement + \ClassInfo{asmejour}{pdfmanagement is defined. Class file will not load a color profile} + \else + \ClassInfo{asmejour}{pdfmanagement not defined. Class file will load a color profile}% + %%% a fairly generic RGB color profile, aimed at on-screen rendering (not print production) + \immediate\pdfobj stream attr{/N 3} file{sRGB.icc} + \pdfcatalog{% + /OutputIntents [ + << + /Type /OutputIntent + /S /GTS_PDFA1 + /DestOutputProfile \the\pdflastobj\space 0 R + /OutputConditionIdentifier (sRGB) + /Info (sRGB) + >> + ] + } + \fi + \fi \fi \RequirePackage{hyperxmp} %% to fix transfer of metadata to Acrobat pdf -\RequirePackage[% +\RequirePackage[psdextra]{hyperref} % recent kernel transition suggests providing most hyperref options via \hypersetup, + % but setting psdextra here (for additional math support in bookmarks) 2021/12/23 +\hypersetup{% unicode, % Unicode encoded PDF strings - psdextra, % additional support for math in pdf bookmarks pdfborder={0 0 0},% - bookmarks=true, % bookmarksnumbered=true,% bookmarksopen=true,% bookmarksopenlevel=1,% @@ -640,29 +762,32 @@ linkcolor=blue, % citecolor=blue, % urlcolor=blue, % - breaklinks=true,% - pdftitle={}, % <=== add in .tex file - pdfkeywords={}, % <=== add in .tex file + filecolor=red, % added 2021/12/23, to make certain broken links more apparent pdfnewwindow=true,% - pdfpagelayout=SinglePage, %TwoPageRight,% changed 12/08/2020 - pdfauthor={}, % <=== add in .tex file + pdfpagelayout=SinglePage, %TwoPageRight,% changed 2020/08/12 pdfdisplaydoctitle=true% - ]{hyperref} +} \urlstyle{same} % don't switch to typewriter font \RequirePackage{doi} % supports nasty characters in some doi's \renewcommand{\doitext}{doi:~} % change the default, {doi:}, to this for ASME specification \RequirePackage{bookmark} % improves handling of pdf bookmarks +\providecommand\hrefurl[2]{\href{#1}{#2}}% to address certain issues around URL recognition with new pdf management code, 2021/12/22 +%% This alias is also incorporated into asmejour.bst + %%%%%% Adjustments to accommodate hyperref bookmarks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% ==> recent and evolving development of \pdfstring removes all robust commands from bookmarks, so +%%% the following interventions may become unnecessary over time (2021/12/23). + %% Since \bm is useful in headings, this fix will reduce frequency with which %% alternate pdfstrings must be given in section command as \section[pdfstring]{texstring} \pdfstringdefDisableCommands{% \def\bm#1#{\relax}% } -%% Let's disable \( and \) in pdf bookmarks, 28/2/20 +%% Let's disable \( and \) in pdf bookmarks, 2020/02/28 \pdfstringdefDisableCommands{% \def\({\relax}% \def\){\relax}% @@ -673,7 +798,7 @@ \def\cite{\@gobble}% } -%% Ensure that tag color does not follow \eqref into bookmarks, 28/2/20 +%% Ensure that tag color does not follow \eqref into bookmarks, 2020/02/28 \pdfstringdefDisableCommands{% \def\eqref#1{(\ref{#1})}% } @@ -694,7 +819,7 @@ {\svsection*{#3}\phantomsection% {\IfNoValueTF {#2} {\addcontentsline{toc}{section}{#3}} - {\addcontentsline{toc}{section}{#2}}% remove trailing space 28/2/20 + {\addcontentsline{toc}{section}{#2}}% remove trailing space 2020/02/28 }% } {\IfNoValueTF {#2} @@ -722,21 +847,36 @@ \newlength\nomenwidth \newlength\savitemsep +%% ==> xparse "g" argument used in this version of \entry is deprecated; so have phased out this version, 2021/12/22 %% If the second argument of \entry is omitted, a bold section heading is produced, e.g. \entry{Greek Letters} -\NewDocumentCommand{\entry}{m g}{% - \IfNoValueTF{#2}{% - \itemsep12\p@ plus 4\p@ minus 4\p@% \bigskip - \goodbreak\item[\bfseries#1\hfill]\itemsep3\p@ plus 1\p@ minus 1\p@\@itempenalty=1000% - }{% - \item[\hfill#1${} = {}$]#2% - \@itempenalty=-\@lowpenalty% - \setlength\itemsep\savitemsep% - \settowidth\@widest{#1${} = {}$}% - \ifdim\@widest>\widest \global\setlength\widest\@widest\fi% - } +%\NewDocumentCommand{\entry}{m g}{% +% \IfNoValueTF{#2}{% +% \itemsep12\p@ plus 4\p@ minus 4\p@% \bigskip +% \goodbreak\item[\bfseries#1\hfill]\itemsep3\p@ plus 1\p@ minus 1\p@\@itempenalty=1000% +% }{% +% \item[\hfill#1${} = {}$]#2% +% \@itempenalty=-\@lowpenalty% +% \setlength\itemsep\savitemsep% +% \settowidth\@widest{#1${} = {}$}% +% \ifdim\@widest>\widest \global\setlength\widest\@widest\fi% +% } +%} + +\NewDocumentCommand{\entry}{m m}{% +\ifblank{#2}{% + \ClassWarningNoLine{asmejour}{The command \protect\entry should have two arguments. For subheadings, \protect\EntryHeading is preferred} + \itemsep12\p@ plus 4\p@ minus 4\p@% \bigskip + \goodbreak\item[\bfseries#1\hfill]\itemsep3\p@ plus 1\p@ minus 1\p@\@itempenalty=1000% + }{% + \item[\hfill#1${} = {}$]#2% + \@itempenalty=-\@lowpenalty% + \setlength\itemsep\savitemsep% + \settowidth\@widest{#1${} = {}$}% + \ifdim\@widest>\widest \global\setlength\widest\@widest\fi% + } } -%% A separate command command for nomenclature subheadings (xparse "g" argument used in \entry is deprecated) +%% A separate command command for nomenclature subheadings \NewDocumentCommand\EntryHeading{m}{% \itemsep12\p@ plus 4\p@ minus 4\p@% \bigskip \goodbreak\item[\bfseries#1\hfill]\itemsep3\p@ plus 1\p@ minus 1\p@\@itempenalty=1000% @@ -783,7 +923,7 @@ ]% }% \else - \ClassWarningNoLine{asmejour}{Omitting lists of figures and tables}% + \LogNote{Omitting lists of figures and tables}% \fi %%%%%%%%%%%%%%%% Author/Title/Abstract block %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -796,7 +936,9 @@ \NewCoffin{\Title} \NewCoffin{\firstrowauthorblock} -\SetHorizontalCoffin\firstrowauthorblock{} +\AtBeginDocument{% + \SetHorizontalCoffin\firstrowauthorblock{}% +}% corrected 2021/12/22 \newlength{\coffinsep}%%% space between coffins \setlength{\coffinsep}{4.5mm} @@ -836,11 +978,11 @@ } \providecommand{\@keywords}{\relax} -\NewDocumentCommand{\keywords}{m}{% changed to remove g option, 30/01/21 +\NewDocumentCommand{\keywords}{m}{% changed to remove g option, 2021/01/30 \long\def\@keywords{\par\vskip\baselineskip\noindent{\keywordname:} #1}% } -\NewDocumentCommand\@SetAbstract{+m}{% add + to enable blank lines, etc. 31/01/2021 +\NewDocumentCommand\@SetAbstract{+m}{% add + to enable blank lines, etc. 2021/01/31 \SetVerticalCoffin{\Abstract}{114mm}{% \noindent\itshape% #1 @@ -872,7 +1014,7 @@ \newcommand{\CAemail}[1]{\gdef\@CAemail{#1}}% legacy code, drop eventually -%% ASME prefers email to be in address block, not CA footnote; removed option 30/01/21 +%% ASME prefers email to be in address block, not CA footnote; removed option 2021/01/30 \NewDocumentCommand{\CorrespondingAuthor}{}{% \global\aj@CAtrue% \gdef\@CAsep{\relax}% legacy code, drop eventually @@ -898,7 +1040,7 @@ ] \ifaj@CA \addtocounter{footnote}{1} - \footnotetext{\CAwords\@CAsep \@CAemail}% includes legacy code, remove \@CA commands eventually + \footnotetext{\CAwords\@CAsep \@CAemail}% includes legacy code, will remove \@CA commands eventually \fi \ifaj@Date\revfootnote{\@Date}\else\relax\fi \ifaj@contractor\revfootnote{The United States Government retains, and by accepting the article for publication, the publisher acknowledges that the United States Government retains, a non-exclusive, paid-up, irrevocable, worldwide license to publish or reproduce the published form of this work, or allow others to do so, for United States Government purposes.}% diff --git a/macros/latex/contrib/censor/README b/macros/latex/contrib/censor/README index e3107c9423..fbe9d43755 100644 --- a/macros/latex/contrib/censor/README +++ b/macros/latex/contrib/censor/README @@ -23,3 +23,8 @@ V3.1 gives unrestricted use of \par in arguments to \blackout. Also, V3.2 allows control over the characteristics (depth and height) of the censor blackout rule. It also gives additional control on how to handle the censoring of periods. + +v4.0 overhauls the token censoring approach to incorporate tools from +the tokcycle package, to provide more flexibility when censored material +contains macros. + diff --git a/macros/latex/contrib/censor/censor.pdf b/macros/latex/contrib/censor/censor.pdf Binary files differindex 6a85c480dd..d5f14ea63d 100644 --- a/macros/latex/contrib/censor/censor.pdf +++ b/macros/latex/contrib/censor/censor.pdf diff --git a/macros/latex/contrib/censor/censor.sty b/macros/latex/contrib/censor/censor.sty index 49e1190619..6335b16ae3 100644 --- a/macros/latex/contrib/censor/censor.sty +++ b/macros/latex/contrib/censor/censor.sty @@ -1,7 +1,7 @@ % censor.sty -\def\censorversionnumber{3.22} +\def\censorversionnumber{4.0} \ProvidesPackage{censor} -[2018/11/15 \censorversionnumber +[2021/12/23 \censorversionnumber Provides capability for redaction of sensitive information] % @@ -30,15 +30,17 @@ % 3.21 - Fixed bug regarding \xblackout rules remaining after a % \StopCensoring % 3.22 - changed `\if to \ifx in definition of \bl@t, to handle macros like \% +% 4.0 - Recast \blackout and \xblackout in terms of tokcycle environments +% - Introduced \blackoutenv...\endblackoutenv and +% \xblackoutenv...\endxblackoutenv \usepackage{pbox} -\usepackage{ifnextok} \newlength\censorruledepth \newlength\censorruleheight \censorruledepth=-0.3ex% -0.3ex DEFAULT \censorruleheight=2.1ex% 2.1ex DEFAULT -\def\censordot{.}% versus \def\censordot{ }% +\def\censordot{\censor{.}}% versus \def\censordot{ }% \newcommand\censorrule[1]{\protect\rule[\censorruledepth]{#1}{\censorruleheight}} @@ -53,90 +55,57 @@ \newcommand\StopCensoring{% \let\censor\un@censor% \let\censorbox\un@censorbox% - \let\xblackout\blackout% + \renewcommand\censpace{ }% } \newcommand\RestartCensoring{% \renewcommand\censor{\@ifstar{\@cenlen}{\@cenword}}% \renewcommand\censorbox{\@ifstar{\censor@dim}{\censor@box}}% - \let\xblackout\sv@xblackout% + \let\censpace\sv@censpace% } -\let\sv@tilde~ - -\def\stringend{$} - -\long\def\blackout#1{\def~{-}\censor@Block#1\stringend\let~\sv@tilde} -\long\def\censor@Block{\IfNextToken\stringend{\@gobble}% - {\IfNextToken\@sptoken{ \bl@t{\censor@Block}}% - {\bl@t{\censor@Block}}}} - -% V2.00 DEFINITION: -% \def\bl@t#1#2{\censor{#2}#1} - -% V2.10 DEFINITION (MADE \long IN V3.1): -%\long\def\bl@t#1#2{\if\bpar#2\par\else\if.#2\censordot\else\censor{#2}\fi\fi#1} - -% V3.22 DEFINITION -\long\def\bl@t#1#2{\ifx\bpar#2\par\else\if.#2\censordot\else\censor{#2}\fi\fi#1} - -%\def\bpar{_} %V3.00 DEFINITION -\let\bpar\par %AS OF V3.1, CAN HANDLE \par - -\long\def\xblackout#1{\rule{0ex}{0ex}% - \def~{-}% - \def\@justpar{F}% - \def\@justperiod{F}% - \def\@justspace{F}% - \xcensor@Block#1\stringend% - \let~\sv@tilde% - } - -\let\sv@xblackout\xblackout - -\long\def\xcensor@Block{\IfNextToken\stringend{\@gobble}% - {\IfNextToken\@sptoken{ \def\@justspace{T}\xbl@t{\xcensor@Block}}% - {\xbl@t{\xcensor@Block}}}} - -\newlength\periodrlap\setlength\periodrlap{1.6ex} -\newlength\afterperiodlap\setlength\afterperiodlap{1.2ex} -\newlength\lletterlap\setlength\lletterlap{0.55ex} -\newlength\rletterlap\setlength\rletterlap{0.55ex} -\newlength\afterspacelap\setlength\afterspacelap{0.0ex} - -\def\@periodrlap{\rlap{\censorrule{\periodrlap}}} -\def\@afterperiodlap{\llap{\censorrule{\afterperiodlap}}} -\def\@lletterlap{\llap{\censorrule{\lletterlap}}} -\def\@rletterlap{\rlap{\censorrule{\rletterlap}}} -\def\@afterspacelap{\llap{\censorrule{\afterspacelap}}} - -\long\def\xbl@t#1#2{% - \ifx\par#2% - \par\def\@justpar{T}% - \else% - \if T\@justspace% - \rule{0ex}{1ex}\@afterspacelap% - \fi% - \if.#2% - \def\@justperiod{T}% - \@periodrlap% - \censordot% - \else% - \if F\@justpar% - \if T\@justperiod% - \@afterperiodlap% - \else% - \@lletterlap% - \fi% - \fi% - \censor{#2}% - \@rletterlap% - \def\@justpar{F}% - \def\@justperiod{F}% - \def\@justspace{F}% - \fi% - \fi% - #1% -} +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\usepackage{tokcycle}[2021/03/10] + + +\def\@dump#1{\addcytoks[1]{\expandafter\censor\expandafter{#1}}\def#1{}} +\def\@append#1#2{\tc@defx#1{#1#2}} + +\def\spacelap{0.6ex} +\def\censpace{\rlap{\censorrule{\spacelap}} \llap{\censorrule{\spacelap}}} +\let\sv@censpace\censpace + +\long\def\blackout#1{\blackoutenv#1\endblackoutenv} +\long\def\xblackout#1{\xblackoutenv#1\endxblackoutenv} + +\newif\ifexpandarg + +\xtokcycleenvironment\xblackoutenv + {\ifx.##1\@dump\censored@word\addcytoks[1]{\censordot}\else + \@append\censored@word{##1}% + \tcpeek\@next\ifx\@next\@tcEscapeptr\@dump\censored@word\fi\fi} + {\tctestifcon\ifexpandarg{\expandafter\processtoks\expandafter{\expanded{##1}}}% + {\processtoks{##1}}\@dump\censored@word\expandargfalse} + {\@dump\censored@word\tctestifx{~##1}{\@append\censored@word{##1}}% + {\tctestifx{\expanded##1}{\expandargtrue}{\addcytoks{##1}}}} + {\@dump\censored@word\addcytoks{\censpace}} + {\def\censored@word{}} + {\@dump\censored@word} +\xtokcycleenvironment\blackoutenv + {\ifx.##1\@dump\censored@word\addcytoks[1]{\censordot}\else + \@append\censored@word{##1}% + \tcpeek\@next\ifx\@next\@tcEscapeptr\@dump\censored@word\fi\fi} + {\tctestifcon\ifexpandarg{\expandafter\processtoks\expandafter{\expanded{##1}}}% + {\processtoks{##1}}\@dump\censored@word\expandargfalse} + {\@dump\censored@word\tctestifx{~##1}{\@append\censored@word{##1}}% + {\tctestifx{\expanded##1}{\expandargtrue}{\addcytoks{##1}}}} + {\@dump\censored@word\addcytoks{##1}} + {\def\censored@word{}} + {\@dump\censored@word} + + + +%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand\censorbox{\@ifstar{\censor@dim}{\censor@box}} \newcommand\censor@dim[4][]{{#1% @@ -152,3 +121,5 @@ % NOTE: A \protect\censorbox{} MAY BE REQUIRED INSIDE SOME ENVIRONMENTS \endinput + + diff --git a/macros/latex/contrib/censor/censor.tex b/macros/latex/contrib/censor/censor.tex index 1348942afa..e9990244f2 100644 --- a/macros/latex/contrib/censor/censor.tex +++ b/macros/latex/contrib/censor/censor.tex @@ -4,9 +4,6 @@ \parindent 0in \parskip 1em -\makeatletter -\long\def\bl@t#1#2{\ifx\bpar#2\par\else\ifx.#2\censordot\else\censor{#2}\fi\fi#1} -\makeatother \begin{document} @@ -15,7 +12,7 @@ \LARGE The \textsf{censor} Package\\ \small \rule{0in}{1em}Tools for Producing Redacted Documents\\ \large \rule{0in}{2em} Steven B. Segletes\\ -steven.b.segletes.civ@mail.mil\\ +SSegletes@verizon.net\\ \rule{0em}{2em}\today\\ v\censorversionnumber \end{center} @@ -196,7 +193,8 @@ detailed in Table 1. } -Additionally, as of version 2.0, there is provided a block-censor + +As of version 2.0, there is provided a block-censor capability, for redacting larger blocks of text. This new command is \verb|\blackout|, and is used in the form \verb|\blackout{Block of text}|. This nice thing about this command is @@ -219,87 +217,106 @@ CENSORED UNRESTRICTED OUTPUT: \hrulefill \blackout{% The Liberty missile, with charge diameter (CD) of 80~mm, revealed a penetration capability of 1.30, 1.19, and -1.37~CD in three recent tests into armor steel. -\bpar -New paragraph.} +1.37~CD in three recent tests into armor steel. xxx + +New paragraph. +} \hrulefill } -There is a caveat regarding the use of \verb|\blackout|. -The argument cannot end on so-called ``glue,'' such as a space -or a carriage return. The following examples are, thus, bad forms of -the \verb|\blackout| command: - -\verb|\blackout{Ends in space. Bad form }| +Prior to V4.0, \verb|\blackout| did not conveniently work across + environment boundaries, such as math or tabular mode. +One inconvenient option had been to \verb|\censor| text in the \texttt{tabular}, + cell by cell. +Alternatively, to blackout the whole tabular environment, you should use + the \verb|\censorbox| command as has been shown. +Presently, there is a third option---to censor cell-by-cell using a + shorthand notation. + +The \verb|\blackout| macro now allows uncensored content to be \textit{escaped} + from its argument by delimiting it between \verb+|...|+ bars. +Thus, the censoring directive \verb+\blackout{This |is a| test}+ renders as + \blackout{This |is a| test}. + +\begingroup + +\begin{verbatim} +\blackout{ +|\begin{tabular}{|c|c|} +\hline +Title 1 & Title 2 \\ +\hline +|a| & |bbb|\\ +|cc| & dd\\ +\hline +\end{tabular}| +} +\end{verbatim} -\verb|\blackout{Ends in carriage return. Bad form|\\ -\verb|}| +\blackout{ +|\begin{tabular}{|c|c|} +\hline +Title 1 & Title 2 \\ +\hline +|a| & |bbb|\\ +|cc| & dd\\ +\hline +\end{tabular}| +} +\StopCensoring +\blackout{ +|\begin{tabular}{|c|c|} +\hline +Title 1 & Title 2 \\ +\hline +|a| & |bbb|\\ +|cc| & dd\\ +\hline +\end{tabular}| +} -Secondly, periods are not censored (as of version 2.1). This is done -because it is necessary to preserve the period-space combination that -signifies end-of-sentence. In this way, {\LaTeX} can preserve -inter-word spacing in the redacted version that is identical to the -unredacted version. +\endgroup -Thirdly, \verb|\blackout| does not work across environment boundaries, -such as math or tabular mode. You can blackout text in the table, cell -by cell; But you cannot blackout the whole tabular environment with the -\verb|\blackout| command (instead, you should use the \verb|\censorbox| -command for tabular environments). -Finally, the argument to \verb|\blackout| can employ tokens; However, -the tokens are expanded into one large blackout, regardless of whether -the expanded token contains spaces. Thus +\noindent**v4.0 CHANGE**: +The restriction on \verb|\blackout| \textit{not} ending on glue + is no longer applicable. -\verb|\blackout{\today}| +Finally, the argument to \verb|\blackout| can, in limited situations, + process macros; However, + the macros are not expanded by default. +See section~\ref{S:A} for details on what is possible with respect to + the censoring of macro content with this package. -becomes \blackout{\today}, in spite of the fact that \verb|\today|, -given at the moment by \today, contains spaces. The author received some negative feedback concerning the appearance -resulting from a \verb|\blackout| command. Generally, people did not -like the fact that spaces were not blacked out, whether it was a concern -over security or merely cosmetic. To this end, the \verb|\xblackout| -command is introduced in V3.10, which blacks out the text more -completely, while simultaneously preserving the layout indentical to -that of the uncensored document. - -The additional blacking-out of the \verb|\xblackout| macro is controlled -by five resettable lengths which lap additional blacking atop the -result of \verb|\blackout|. By default, these lengths are defined as: - -\verb|\periodrlap = 1.6ex|\\ -\verb|\afterperiodlap = 1.2ex|\\ -\verb|\lletterlap = 0.55ex|\\ -\verb|\rletterlap = 0.55ex|\\ -\verb|\afterspacelap = 0.0ex| - -The length \verb|\periodrlap| is the length of right-lapped blackout -applied just before printing a period. Thus, this blacking is intended -to cover the period not treated by \verb|\blackout|. The length -\verb|\afterperiodlap| is a left-lapped blackout applied just prior to -word following a period. Its intent is to back-cover the extra-wide -spacing that follows a period. The length \verb|\lletterlap| is the -left-lapped blacking applied before a character. It will help cover -inter-word space if \verb|\afterspacelap| is not employed. The length -\verb|\rletterlap| is the right-lapped blacking applied after a -character, which as with \verb|\lletterlap|, can help cover inter-word -spacing if \verb|\afterspacelap| is not employed. Finally, there is -\verb|\afterspacelap| which, if employed, is a left-lapped blacking -applied before the character that follows a space. + resulting from a \verb|\blackout| command. Generally, people did not + like the fact that spaces were not blacked out. +To this end, the \verb|\xblackout| command is introduced in V3.10, which + \textit{cosmetically} blacks out the text more completely + (note, however, that underneath the more complete blackout are still + the word-length blackouts that otherwise compose \verb|\blackout|). + +As of v4.0 of the package, + the additional blacking-out of the \verb|\xblackout| macro is controlled + by one resettable length which laps additional blacking atop the + result of \verb|\blackout|. +This length is defined in the macro \verb|\spacelap|, with + a default value of \spacelap. + +During \verb|\xblackout|, a + right- and left-lapped blacking of dimension \verb|\spacelap| is + applied before and after each space character, respectively. The blacking from \verb|\xblackout| is intended to be less ``choppy'' than that of \verb|\blackout|. However, it too has some drawbacks. The -x-blacking will extend past the left and right margins. If a line of -output ends on a period (as we show in our example below), that line and -the beginning of the next line may have their blacked-out margins not in -uniformity with other lines, based on the settings of the various -lapping lengths employed. If \verb|\periodrlap| is too large, it could -blackout subsequent text in an unintended way. With all these caveats, -it may still be found preferable to \verb|\blackout|, as shown in the -example below. +x-blacking will extend past the margin(s). It is also +possible that not all margin extensions will be uniform in size. +With all these caveats, +it may still be found preferable to the \verb|\blackout| macro, as + shown in the example below. {\addtolength{\leftskip}{2.3em} UNCENSORED RESTRICTED SOURCE: \hrulefill @@ -318,7 +335,7 @@ UNCENSORED RESTRICTED OUTPUT: \hrulefill The Liberty missile, with charge diameter (CD) of 80~mm, revealed a penetration capability of 1.30, 1.19, and 1.37~CD in recent testing here. The tests were into armor steel. -\bpar + New paragraph} with open text. CENSORED UNRESTRICTED OUTPUT (\verb|\blackout{}|): \hrulefill @@ -327,7 +344,7 @@ CENSORED UNRESTRICTED OUTPUT (\verb|\blackout{}|): \hrulefill The Liberty missile, with charge diameter (CD) of 80~mm, revealed a penetration capability of 1.30, 1.19, and 1.37~CD in recent testing here. The tests were into armor steel. -\bpar + New paragraph} with open text. CENSORED UNRESTRICTED OUTPUT (\verb|\xblackout{}|): \hrulefill @@ -336,7 +353,7 @@ CENSORED UNRESTRICTED OUTPUT (\verb|\xblackout{}|): \hrulefill The Liberty missile, with charge diameter (CD) of 80~mm, revealed a penetration capability of 1.30, 1.19, and 1.37~CD in recent testing here. The tests were into armor steel. -\bpar + New paragraph} with open text. \hrulefill @@ -365,15 +382,15 @@ CENSORED UNRESTRICTED SOURCE: \hrulefill \verb|\def\Size{\censor*{2}}|\\ \verb|\def\TableOne{\censorbox*[\small]{26}{5}{3.5}}|\\ \verb||\\ -\verb|The {\Missile} missile, with charge diameter (CD) of|\\ -\verb|{\Size}~mm, revealed a penetration capability ranging from|\\ +\verb|The \Missile{} missile, with charge diameter (CD) of|\\ +\verb|\Size~mm, revealed a penetration capability ranging from|\\ \verb|1.19--1.37~CD in three recent tests into armor steel, as|\\ \verb|detailed in Table 1.|\\ \verb||\\ \verb|\begin{table}[ht]|\\ \verb|\begin{center}|\\ -\verb|\textbf{Table 1. {\Missile} Missile Test Data}\\|\\ -\verb|{\TableOne}|\\ +\verb|\textbf{Table 1. \Missile{} Missile Test Data}\\|\\ +\verb|\TableOne{}|\\ \verb|\end{center}|\\ \verb|\end{table}|\\ @@ -414,7 +431,7 @@ affect the size of the an ex and \verb|\baselineskip|. Because the redaction width is only approximate, it is possible that the censored and uncensored originals might have differing text -justification. In the text, the curly braces are placed around the +justification. In the text, the curly braces may be added after the keyword identifiers so as to produce the proper interaction with the surrounding whitespace and punctuation. @@ -528,6 +545,71 @@ It is not envisioned that the \verb|\blackout| or \verb|\xblackout| commands, discussed in the prior section, are used in this mode, where the source file is in an unsecure environment. +\section{Can I Censor Control Sequences?\label{S:A}} + +In general, the \textsf{censor} package is designed to operate on + literal text. +This is especially true if you are using the \verb|\censor| macro, which + is designed for use on a single word, rather than extended text. +However, it is also clear that an extended text passage may contain + various macro markup, for example, italic phrases. + +The \verb|\blackout| and \verb|\xblackout| macros can at least digest + control sequences in the input-text stream. +How the sequences are handled will require some user intervention. +By default, these macros will be echoed into the output stream in a literal + (unexpanded) form. + +Consider the following line of \LaTeX{} code: + +\verb|This is \textit{italic text}|\\ +\blackout{|This is \textit{italic text}|\\This is \textit{italic text}} + +It would normally render as in the 2nd line. +When included as part of the \verb|\blackout| argument, it renders as the + 3rd line. +The \verb|\textit| is still part of the blackout rendering, but the + \textit{input} to \verb|\textit| has been censored and the + censor rule does not change its presented shape under the influence + of \verb|\textit|. + +Some macros, however, expand to literal text. +Because they are, by default, carried literally into the output, they + will only expand into text \textit{after} the censoring has been + applied. +Consider the following line of \LaTeX{} code: + +\verb|Today's date is \today.|\\ +\blackout{|Today's date is \today.|\\Today's date is \today.} + +If the macro is expandable (and not all are), the \verb|\blackout| + and \verb|\xblackout| macros are set up to intercept callouts to + the primitive \verb|\expanded| and act upon them prior to censoring. +Therefore, with one small change to the above example, the problem + can be remedied: + +\verb|Today's date is \expanded{\today}.|\\ +\blackout{|Today's date is \expanded{\today}.|\\% + Today's date is \expanded{\today}.} + +If a control sequence is not expandable, then there is no way to + censor its \textit{output}. +Therefore, you have two options: you can remove it (and its arguments) + from the blackout altogether, or else you can leave it (and its arguments) + in the blackout, but ``escape'' them between $|$ escape character + delimiters. +In either case, however, the output of the unexpandable macro will be + visible to the reader, as in the example below, where the macro + \verb|\ref| and its argument are escaped from the blackout. + +%\settcEscapechar{|} +\verb+In Section |\ref{S:A}|, we discuss censored macros+\\ +\StopCensoring +\blackout{In Section |\ref{S:A}|, we discuss censored macros}\\ +\RestartCensoring +\blackout{In Section |\ref{S:A}|, we discuss censored macros} + + \section{Censor Marks} The censor (blacking) mark is a \verb|\rule| which has a depth @@ -540,17 +622,14 @@ the following two lengths. \verb| \censorruleheight=|length \upshape -In addition, it was mentioned that periods are not censored, so as to -preserve the ability of \LaTeX{} to produce censored output of -\textit{identical} spacing to the uncensored output. If, however, the -preservation of space is not essential, and the user does not wish to -have periods appear in the censored output, the definition -\verb|\censordot|, by default +When using \verb|\blackout| and \verb|\xblackout|, periods are + now censored by default. +If, however, you wish the prior approach of not censoring periods, + you may redefine \verb|\censordot| to something else, for example, -\verb| \def\censordot{.}| +\verb| \renewcommand\censordot{.}| -can be redefined as a blank space, as a null character, or something -else, at the users' discretion. +to make them visible in the censored document. \section{Usage Summary} @@ -558,19 +637,18 @@ The complete set of commands available to the \textsf{censor} package, to bring about text redaction, are:\\ {~\\ \verb| \censor{|\it text\tt\}\\ -\verb| \censor*{|\it width mult.\tt\}\\ +\verb| \censor*{|\it width multiplier\tt\}\\ \verb| \censorbox[|\it pre-commands\tt]\{\it object box\tt\}\\ \verb| \censorbox*[|\it pre-commands\tt]\{\it width mult.\tt\}\{\it height mult.\tt\}\{\it depth mult.\tt\}\\ \verb| \blackout{|\it extended text passage\tt\}\\ \verb| \xblackout{|\it extended text passage\tt\}\\ -\verb| \bpar| \rmfamily\upshape(\it retained for backward compatibility - only\upshape)\\ \verb| \StopCensoring|\\ \verb| \RestartCensoring|\\ \verb| \censorruledepth=|\it length\\ \verb| \censorruleheight=|length\\ -\verb| \def\censordot{.| \upshape or \it character\tt\}\\ +\verb| \renewcommand\spacelap{|\it length\tt\}\\ +\verb| \renewcommand\censordot{|\it token or instruction\tt\}\\ ~\\} The star ({\tt*}) version of the commands is envisioned when the source document is being created in an unsecure environment, whereas, the @@ -585,9 +663,6 @@ environments is often overridden by the environment). The use of pre-commands will typically be fontsize commands, so that measurements of ex's and \verb|\baselineskip| are done in a relevant fontsize. -The \verb|\bpar| command is no longer needed, as of V3.10. It is now -made equivalent to \verb|\par|. - Censoring may be dynamically turned off and on in a document with the use of the \verb|\StopCensoring| and \verb|\RestartCensoring| commands, respectively. The default is censoring `on.' @@ -596,36 +671,50 @@ respectively. The default is censoring `on.' Here is some added information that users of the package should know. -I have found that, in certain cases (for example, with captions created +\begin{itemize} + +\item As of package version v4.0, the token-cycling pseudo-environments of the + \textsf{tokcycle} package were used to process the tokens of + the \verb|\blackout| and \verb|\xblackout| macros. +While the syntax of these macros is unchanged, one has the additional + option of invoking them using the pseudo-environment syntax of + \textsf{tokcycle} as + +\verb|\blackoutenv Text to blackout\endblackoutenv|:\\ +\blackoutenv Text to blackout\endblackoutenv{} and\\ +\verb|\xblackoutenv Text to blackout\endxblackoutenv|:\\ +\xblackoutenv Text to blackout\endxblackoutenv. + +\item Because \verb|\blackout| and \verb|\xblackout| use + tokcycle-package environments to perform their actions, the + macro \verb|\settcEscapechar| can be used to reset the escape + character to something other than $|$, in accordance with + the documented \textsf{tokcycle}-package commands. + + +\item I have found that, in certain cases (for example, with captions created using the \textsf{boxhandler} package), the censorbox command needs to -be protected by way of \verb|\protect\censorbox{...}|. +be protected by way of \verb|\protect\blackout{...}|. -It is preferable not to apply \verb|\censor| to whitespace, or text +\item It is preferable not to apply \verb|\censor| to whitespace, or text justification could be adversely affected. If one wishes to censor a multi-word phrase, such as ``Little Bo Peep,'' it is recommended to do it as follows:\\ -\verb| \blackout{Little Bo Peep}|\\ +\verb| \xblackout{Little Bo Peep}|\\ If such a phrase is to be used repeatedly through a document, -it is most convenient to place it as a keyword identifier:\\ -\verb| \def\Name{\blackout{Little Bo Peep}}|\\ +it is most convenient to place it as a macro:\\ +\verb| \def\Name{\xblackout{Little Bo Peep}}|\\ such that subsequent reference is done indirectly:\\ -\verb| We examine the life of {\Name} in this report|\\ +\verb| We examine the life of \Name{} in this report,|\\ +\verb| assured that \Name{} line breaks.|\\ +\def\Name{\xblackout{Little Bo Peep}} +\verb| |We examine the life of \Name{} in this report, assured that + \Name{} line breaks.\\ (Even so, it should be noted that censoring can still affect text justification, because censored words are never hyphenated across line boundaries, whereas the original text may have been.) -Because the censor algorithm's - digest one token at a time, you have to be careful if - macros appear in the arguments to a \verb|\censor|, - \verb|\blackout|, or \verb|\xblackout|. -In particular, you have to locate the macro \textit{and its arguments} - in a group, for example, - \verb|\blackout{In equation {\ref{eq:A}},| \verb|you will see...}|. -The extra braces around \verb|\ref| and its argument are required - so that the censoring algorithm does not try to absorb the macro - without also absorbing its argument(s). - -Users have asked for color support in the package. +\item Users have asked for color support in the package. I do not wish to hardwire color into the package---however, if the \textsf{xcolor} package is loaded, the following preamble definition will force censoring to be @@ -640,7 +729,7 @@ Let's see if it works: {\let\svcensorrule\censorrule \renewcommand\censorrule[1]{\textcolor{red}{\svcensorrule{#1}}} -\addtolength\leftskip{2.3em} +\addtolength\leftskip{2em} Is this blacked out text censored in red?\\ \blackout{Is this blacked out text censored in red?}\par} @@ -649,6 +738,8 @@ This technique can be used at the user's discretion to provide color The value of \verb|\censorcolor| can be redefined on the fly to change the color of the censoring. +\end{itemize} + \section{Source Code} The source code for \textsf{censor} is so short as to be included below: diff --git a/macros/latex/contrib/easybook/easybook.dtx b/macros/latex/contrib/easybook/easybook.dtx index dfbf1feea7..99f5551d5d 100644 --- a/macros/latex/contrib/easybook/easybook.dtx +++ b/macros/latex/contrib/easybook/easybook.dtx @@ -15,7 +15,7 @@ %<*class> \NeedsTeXFormat{LaTeX2e}[2020/10/01] \RequirePackage{l3keys2e} -\ProvidesExplClass{easybook}{2021/12/22}{1.42B} +\ProvidesExplClass{easybook}{2021/12/22}{1.42C} {Typeset Chinese theses or books} \bool_set_false:N \l__eb_compile_draft_bool @@ -307,7 +307,7 @@ %<*package> \NeedsTeXFormat{LaTeX2e}[2020/10/01] \RequirePackage{l3keys2e,etoolbox} -\ProvidesExplPackage{easybase}{2021/12/22}{1.42B} +\ProvidesExplPackage{easybase}{2021/12/22}{1.42C} {Typeset Chinese theses or books} \cs_generate_variant:Nn \dim_set:Nn { NV } @@ -377,19 +377,19 @@ \@ifpackageloaded{#1} { \tl_if_blank:nTF {#2} - { \msg_warning:nnn { easybase } { package-reloaded-ii } {#1} } - { \msg_warning:nnnn { easybase } { package-reloaded-i } {#1} {#2} } + { \msg_warning:nnn { easybase } { package-repeat-load-ii } {#1} } + { \msg_warning:nnnn { easybase } { package-repeat-load-i } {#1} {#2} } } {#3\disable@package@load{#1}{}} } -\msg_new:nnn { easybase } { package-reloaded-i } +\msg_new:nnn { easybase } { package-repeat-load-i } { - The~macro~package~#1~has~been~reloaded. \\ + The~macro~package~#1~has~been~loaded~repeatedly. \\ Please~pass~the~arguments~by \\ the~\string\PassOptionsToPackage{#2}{#1}\ command. } -\msg_new:nnn { easybase } { package-reloaded-ii } - { The~macro~package~#1~has~been~reloaded. } +\msg_new:nnn { easybase } { package-repeat-load-ii } + { The~macro~package~#1~has~been~loaded~repeatedly. } \cs_set_eq:NN \eb@usepackage@save \usepackage \RenewDocumentCommand{\usepackage}{O{}m} { @@ -1854,7 +1854,7 @@ \SetEnumitemValue{font}{sf}{\color{ctex@emph}\normalfont\sffamily} \SetEnumitemValue{ref}{enumii}{\arabic{enumi}.\alph*} \SetEnumitemValue{ref}{enumiii}{\arabic{enumi}.\alph{enumii}.\roman*} -\setlist{nosep,align = left} +\setlist{nosep,align = left,mode = unboxed} \setlist*{labelsep = 0.5em,listparindent = 2em,leftmargin = *} \setlist[itemize,1]{label = bullet} \setlist[itemize,2]{label = endash} @@ -2432,7 +2432,7 @@ } %</package> %<*tcolorbox> -\ProvidesExplFile{eb-tcolorbox.cfg}{2021/12/22}{1.42B} +\ProvidesExplFile{eb-tcolorbox.cfg}{2021/12/22}{1.42C} {Customization of tcolorbox for easybook} \cs_set_protected:Npn \setexercise #1 diff --git a/macros/latex/contrib/easybook/easybook.pdf b/macros/latex/contrib/easybook/easybook.pdf Binary files differindex 9caa756ed7..4bed13fdee 100644 --- a/macros/latex/contrib/easybook/easybook.pdf +++ b/macros/latex/contrib/easybook/easybook.pdf diff --git a/macros/latex/contrib/easybook/easybook.tex b/macros/latex/contrib/easybook/easybook.tex index ff6f0c6a93..0aacb0e9c4 100644 --- a/macros/latex/contrib/easybook/easybook.tex +++ b/macros/latex/contrib/easybook/easybook.tex @@ -20,7 +20,7 @@ name = easybook, color-scheme = blue, title = EASYBOOK 使用手册, - version = v1.42B, + version = v1.42C, date = 2021/12/22, authors = 瞿毅, info = 排版简体中文学位论文和书籍, @@ -50,35 +50,40 @@ \SetTblrInner{hline{1,Z} = {0.8pt,Blue}} \ExplSyntaxOn\makeatletter +% * Do not add entries to the index +% - Leave the option value blank +\NewDocumentCommand{\kvsplit}{st-mm} + { + \item\code + { + \IfBooleanTF{#1}{\option*{#3}}{\option{#3}} + \cnltx@isvalue + \IfBooleanTF{#2}{#4}{\splitmarg{#4}} + } + } +% Traversal output parameters \newcommand{\splitmeta}[2][\code{,}] { \clist_clear:N \l_tmpa_clist - \clist_map_inline:nn {#2} - { \clist_put_right:Nn \l_tmpa_clist { \meta{##1} } } + \clist_map_inline:nn {#2} { \clist_put_right:Nn \l_tmpa_clist { \meta{##1} } } \clist_use:Nn \l_tmpa_clist {#1} } +% Add delimiters to parameters \newcommand{\newsplitarg}[4][\splitmeta] { \newcommand{#2}[1] {\code{\textcolor{argument}{#3\textnormal{#1{##1}}#4}}} } -\NewDocumentCommand{\kvsplit}{st-mm} - { - \item\code - { - \option{#3}\cnltx@isvalue - \IfBooleanTF{#2}{#4}{\IfBooleanTF{#1}{\Marg{#4}}{\splitmarg{#4}}} - } - } \newarg[\color{violet}\code]\Carg{\{}{\}} \newsplitarg{\splitoarg}{[}{]} \newsplitarg{\splitdarg}{(}{)} \newsplitarg{\splitmarg}{\{}{\}} +% Separator with vertical bar as parameter \newcommand{\spemmeta}{\splitmeta[\code{|}]} \newsplitarg[\spemmeta]{\spemcoarg}{[}{]} \newcommand{\harg}{\textcolor{argument}{\code{-}}} -\NewDocumentCommand{\passto}{smm} - {\IfBooleanF{#1}{\color{Blue}}#3\ifblank{#2}{}{\ttfamily[#2]}} +\newcommand{\black}[1]{\textcolor{black}{#1}} +\newcommand{\noitemsep}{\setlength{\itemsep}{0ex}} \newcommand{\insertblr}[2] { \begin{center} @@ -87,8 +92,6 @@ \end{tblr} \end{center} } -\newcommand{\black}[1]{\textcolor{black}{#1}} -\newcommand{\noitemsep}{\setlength{\itemsep}{0ex}} \renewcommand{\cnltx@package@abstract@width}{0.85\linewidth} \renewcommand{\cmltx@list@setup} { @@ -223,7 +226,7 @@ \opt{enmode}\Default! 同时开启 \option{newline} 和 \keyis-{scheme}{plain} 选项以符合英文原生风格。 \keychoice{paper}{a4paper,b5paper,c5paper,letterpaper,other paper}\Default{a4paper} - 文档页面尺寸选项将参数交给 \pkg*{geometry} 宏包处理,可使用它支持的所有纸张规格。建议选项值 \code{b5paper} 和 \keyis*-{zihao}{5},选项值 \code{a4paper} 和 \keyis*-{zihao}{-4} 配合。 + 文档页面尺寸选项将参数交给 \pkg*{geometry} 宏包处理,可使用它支持的所有标准纸张规格。 \keyval-{config}{配置文件列表}\Default 载入用户配置的文件名列表,文件列表以花括号包裹并以英文逗号分隔。文件名应包含如 \code{tex}、\code{def} 或 \code{cfg} 等扩展名。若配置文件不在当前文件夹则文件名需要包含路径。 \keybool{floatpage}\Default{false} @@ -440,7 +443,7 @@ \newcommand{\bracketsf}[1]{\textsf{[#1}} \ebstyle{brackets = {\bracketsf,]}} \end{ctexexam} - \kvsplit*{figurepath}{\meta{路径名1}\code{\}\{}\meta{路径名2}}\Default + \kvsplit-{figurepath}{\marg{路径名1}\marg{路径名2}}\Default 设置插入图片的文件夹路径名,可以有多个路径名,每个路径包含在括号分隔,只有一个路径时需要包含在两层括号内。 \end{options} @@ -624,7 +627,7 @@ 定理环境前的间距,使用 \pkg*{tcolorbox} 的盒子环境包装后被覆盖。 \keyval-{spacebelow}{弹性长度}\Default{0ex plus .1ex} 定理环境后的间距,使用 \pkg*{tcolorbox} 的盒子环境包装后被覆盖。 - \kvsplit*{notebraces}{\meta{左括号}\code{\}\{}\meta{右括号}}\Default{\Carg{(}\Carg{)}} + \kvsplit-{notebraces}{\marg{左括号}\marg{右括号}}\Default{\Carg{(}\Carg{)}} 设置定理题注两边的括号,两个必选参数分别代表左括号和右括号。 \keyval-{headformat}{标题排列}\Default{\cs*{NAME}\cs*{NUMBER}\cs*{NOTE}} 定理标题各组成元素的位置排列和格式。定理标题由定理名、编号和题注组成,\meta{标题排列} 中命令 \cs*{NAME}、\cs*{NUMBER} 和 \cs*{NOTE} 分别代表定理名、编号和题注。 @@ -674,24 +677,21 @@ \subsection{页面尺寸} \label{subsec:page margins} -模块 \module*{geoset} 会将除了前两个附加的选项交给页面尺寸宏包 \pkg*{geometry} 处理,并且支持它的键值列表,预置的页面尺寸与 \cls*{Word} 的默认值接近。下面列举的仅是一小部分选项,其它选项可查阅宏包帮助文档。当在此设置页面大小时,会覆盖 \option{paper} 选项的设置。 +模块 \module*{geoset} 会将除了前两个附加的选项交给页面尺寸宏包 \pkg*{geometry} 处理,并且支持它的键值列表,预置的页面尺寸与 \cls*{Word} 的默认值接近。下面列举几种代表性选项,其它选项可查阅宏包帮助文档。当在此设置纸张规格时,会覆盖文类选项 \option{paper} 的设置。 \begin{options}\noitemsep \keyval-{headruleskip}{页眉线间距}\Module{geoset}\Default*{1.5pt} \keyval-{footruleskip}{页脚线间距}\Default*{0.3\cs*{normalbaselineskip}} - \keyval*-{left}{页面左边距}\Default*{3.17cm} - \keyval*-{top}{页面上边距}\Default*{2.54cm} - \kvsplit{hmargin}{左边距,右边距} - \keyval*-{textwidth}{页面文本区宽度}\default{} - \keybool*{includehead}\Default*{false} + \kvsplit*{hdivide}{左边距,页面文本宽度,右边距} + \kvsplit*{hmargin}{左边距,右边距} + \keyval*-{textheight}{页面文本高度}\default{} + \keybool*{nofoot}\Default*{false} \begin{ctexexam} \ebgeoset { headruleskip = 3pt, - top = 2.5cm, - bottom = 2.5cm, - left = 3.2cm, - right = 3.2cm, - ignoreall + vscale = 0.9, + hdivide = {2cm,15cm,*}, + vcentering } \end{ctexexam} \end{options} diff --git a/macros/latex/contrib/termsim/README.md b/macros/latex/contrib/termsim/README.md new file mode 100644 index 0000000000..dd32b5bade --- /dev/null +++ b/macros/latex/contrib/termsim/README.md @@ -0,0 +1,81 @@ +Terminal simulation based on tcolorbox and minted/listings +======= + +`termsim` is a LaTeX package developed based on tcolorbox and minted/listings, which provides a environment `terminal`(`terminal*`) and a macro `\termfile`(`\termfile*`) to simulate Win10, Ubuntu and Mac terminal. + +The `terminal`(`terminal*`) evironment create a tcolorbox to simulate terminal with the eviroment body and the `\termfile`(`\termfile*`) macro from a source file. + +The OS type was selected from win10, mac and ubuntu and +the terminal theme was selected from dark and light with key-value option. + +All options can be set with `\termset` macro or `terminal`(`terminal*`) eniroment's and +`\termfile`(`\termfile*`) macro's option + +You can read the manual (in Chinese) for more details and examples. + +Contributing +------------ + +1. github repository: + 1. repository: [termsim](https://github.com/registor/termsim) + 2. Issues and pull requests are welcome. [issue](https://github.com/registor/termsim/issues) or [pull request](https://github.com/registor/termsim/pulls). + +2. gitee repository: + 1. repository: [termsim](https://gitee.com/nwafu_nan/termsim) + 2. Issues and pull requests are welcome. [issue](https://gitee.com/nwafu_nan/termsim/issues) or [pull request](https://gitee.com/nwafu_nan/termsim/pulls). + +基于tcolorbox的终端模拟宏包 +======= + +`termsim`是一个基于tcolorbox的用LaTeX3开发的终端模拟LaTeX宏包,它提供了用于模拟终端窗口的`terminal`(`terminal*`)环境和`\termfile`(`\termfile*`)命令,以模拟Win10、Ubuntu或Mac的终端窗口。 + +`terminal`(`terminal*`)环境根据环境内容创建一个`tcolorbox`盒子用于模拟终端窗口, +`\termfile`(`\termfile*`)命令根据载入的文件内容创建一个`tcolorbox`盒子用于模拟终端窗口。 + +可以通过`terminal`(`terminal*`)环境或`\termfile`(`\termfile*`)命令的`key-value`选项设置操作系统类型(win10、mac或ubuntu), + +所有选项即可以通过环境或命令选项设置,也可以通过`\termset`命令进行设置。 + +可以通过阅读宏包手册(中文)以也解该宏包更多的使用细节和使用样例。 + +### 参与贡献 +--------------------- + +1. github仓库: + (1). 仓库地址: [termsim](https://github.com/registor/termsim) + (2). Issues和PR: [issue](https://github.com/registor/termsim/issues) or [pull request](https://github.com/registor/termsim/pulls). + +2. gitee仓库: + (1). 仓库地址: [termsim-l3](https://gitee.com/nwafu_nan/termsim) + (2). Issues and PR: [issue](https://gitee.com/nwafu_nan/termsim/issues) or [pull request](https://gitee.com/nwafu_nan/termsim/pulls). + +Copyright and Licence +--------------------- + + Copyright (C) 2020-2021 by Nan Geng <nangeng@nwafu.edu.cn> + ---------------------------------------------------------------------- + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either + version 1.3c of this license or (at your option) any later + version. This version of this license is in + http://www.latex-project.org/lppl/lppl-1-3c.txt + and the latest version of this license is in + http://www.latex-project.org/lppl.tx \IfBooleanTF{#1} + { + \bool_set_true:N \l_@@_comment_bool + }{ +t + and version 1.3 or later is part of all distributions of + LaTeX version 2005/12/01 or later. + + This work has the LPPL maintenance status "maintained". + + The Current Maintainer of this work is Nan Geng. + + This package consists of the file termsim.dtx, + and the derived files termsim.sty, + termsim.pdf, + termsim.ins, + README.md (this file). + diff --git a/macros/latex/contrib/termsim/build.sh b/macros/latex/contrib/termsim/build.sh new file mode 100755 index 0000000000..bdbeaf7a88 --- /dev/null +++ b/macros/latex/contrib/termsim/build.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +xetex termsim.dtx &&\ +xelatex -shell-escape termsim.dtx &&\ +makeindex -s gind.ist -o termsim.ind termsim.idx &&\ +makeindex -s gglo.ist -o termsim.gls termsim.glo &&\ +xelatex -shell-escape termsim.dtx &&\ +xelatex -shell-escape termsim.dtx &&\ +xelatex -shell-escape termsim.dtx diff --git a/macros/latex/contrib/termsim/termsim.dtx b/macros/latex/contrib/termsim/termsim.dtx new file mode 100644 index 0000000000..856192470a --- /dev/null +++ b/macros/latex/contrib/termsim/termsim.dtx @@ -0,0 +1,1548 @@ +% \iffalse meta-comment +% !TEX program = XeLaTeX +%<*internal> +\iffalse +%</internal> +%<*readme> +Terminal simulation based on tcolorbox and minted/listings +======= + +`termsim` is a LaTeX package developed based on tcolorbox and minted/listings, which provides a environment `terminal`(`terminal*`) and a macro `\termfile`(`\termfile*`) to simulate Win10, Ubuntu and Mac terminal. + +The `terminal`(`terminal*`) evironment create a tcolorbox to simulate terminal with the eviroment body and the `\termfile`(`\termfile*`) macro from a source file. + +The OS type was selected from win10, mac and ubuntu and +the terminal theme was selected from dark and light with key-value option. + +All options can be set with `\termset` macro or `terminal`(`terminal*`) eniroment's and +`\termfile`(`\termfile*`) macro's option + +You can read the manual (in Chinese) for more details and examples. + +Contributing +------------ + +1. github repository: + 1. repository: [termsim](https://github.com/registor/termsim) + 2. Issues and pull requests are welcome. [issue](https://github.com/registor/termsim/issues) or [pull request](https://github.com/registor/termsim/pulls). + +2. gitee repository: + 1. repository: [termsim](https://gitee.com/nwafu_nan/termsim) + 2. Issues and pull requests are welcome. [issue](https://gitee.com/nwafu_nan/termsim/issues) or [pull request](https://gitee.com/nwafu_nan/termsim/pulls). + +基于tcolorbox的终端模拟宏包 +======= + +`termsim`是一个基于tcolorbox的用LaTeX3开发的终端模拟LaTeX宏包,它提供了用于模拟终端窗口的`terminal`(`terminal*`)环境和`\termfile`(`\termfile*`)命令,以模拟Win10、Ubuntu或Mac的终端窗口。 + +`terminal`(`terminal*`)环境根据环境内容创建一个`tcolorbox`盒子用于模拟终端窗口, +`\termfile`(`\termfile*`)命令根据载入的文件内容创建一个`tcolorbox`盒子用于模拟终端窗口。 + +可以通过`terminal`(`terminal*`)环境或`\termfile`(`\termfile*`)命令的`key-value`选项设置操作系统类型(win10、mac或ubuntu), + +所有选项即可以通过环境或命令选项设置,也可以通过`\termset`命令进行设置。 + +可以通过阅读宏包手册(中文)以也解该宏包更多的使用细节和使用样例。 + +### 参与贡献 +--------------------- + +1. github仓库: + (1). 仓库地址: [termsim](https://github.com/registor/termsim) + (2). Issues和PR: [issue](https://github.com/registor/termsim/issues) or [pull request](https://github.com/registor/termsim/pulls). + +2. gitee仓库: + (1). 仓库地址: [termsim-l3](https://gitee.com/nwafu_nan/termsim) + (2). Issues and PR: [issue](https://gitee.com/nwafu_nan/termsim/issues) or [pull request](https://gitee.com/nwafu_nan/termsim/pulls). + +Copyright and Licence +--------------------- + + Copyright (C) 2020-2021 by Nan Geng <nangeng@nwafu.edu.cn> + ---------------------------------------------------------------------- + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either + version 1.3c of this license or (at your option) any later + version. This version of this license is in + http://www.latex-project.org/lppl/lppl-1-3c.txt + and the latest version of this license is in + http://www.latex-project.org/lppl.tx \IfBooleanTF{#1} + { + \bool_set_true:N \l_@@_comment_bool + }{ +t + and version 1.3 or later is part of all distributions of + LaTeX version 2005/12/01 or later. + + This work has the LPPL maintenance status "maintained". + + The Current Maintainer of this work is Nan Geng. + + This package consists of the file termsim.dtx, + and the derived files termsim.sty, + termsim.pdf, + termsim.ins, + README.md (this file). + +%</readme> +%<*internal> +\fi +\begingroup + \def\temp{LaTeX2e} +\expandafter\endgroup\ifx\temp\fmtname\else +\csname fi\endcsname +%</internal> +%<*install> + +\input ctxdocstrip % + +\let\MetaPrefix\relax + +\preamble + + Copyright (C) 2020-2021 by Nan Geng <nangeng@nwafu.edu.cn> +-------------------------------------------------------------------------- + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either + version 1.3c of this license or (at your option) any later + version. This version of this license is in + http://www.latex-project.org/lppl/lppl-1-3c.txt + and the latest version of this license is in + http://www.latex-project.org/lppl.txt + and version 1.3 or later is part of all distributions of + LaTeX version 2005/12/01 or later. + + This work has the LPPL maintenance status "maintained". + + The Current Maintainer of this work is Nan Geng. + +-------------------------------------------------------------------------- + +\endpreamble + +\postamble + + This package consists of the file termsim.dtx, + and the derived files termsim.sty, + termsim.pdf, + termsim.ins, + README.md. +\endpostamble + +\declarepostamble\emptypostamble +\endpostamble + +\def\MetaPrefix{-- } + + +\let\MetaPrefix\DoubleperCent + +\generate + { +%</install> +%<*internal> + \usedir{source/xelatex/termsim} + \file{termsim.ins} {\from{\jobname.dtx}{install}} +%</internal> +%<*install> + \usedir{xetex/xelatex/termsim} + \file{termsim.sty} {\from{\jobname.dtx}{package}} + \nopreamble\nopostamble + \usedir{doc/xelatex/termsim} + \file{README.md} {\from{\jobname.dtx}{readme}} + } + +\endbatchfile +%</install> +%<*internal> +\fi +%</internal> +%<package>\NeedsTeXFormat{LaTeX2e}[2020/10/01] +%<package>\RequirePackage{expl3} +%<+package>\GetIdInfo$Id: termsim.dtx 1.0.0 2021-12-14 08:00:00 +0800 Nan Geng <nangeng@nwafu.edu.cn> $ +%<package> {Terminal simulation with tcolorbox and minted/listings.} +%<package>\ProvidesExplPackage{\ExplFileName} +%<package> {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} +%<*driver> +\documentclass{ctxdoc} +\usepackage{minted} +\usepackage{listings} +\usepackage{xcolor} +\usepackage{xcolor-material} +\usepackage{termsim} +\renewcommand*\marg[1]{\{\meta{#1}\}} +\renewcommand*\oarg[1]{[\meta{#1}]} +\renewcommand*\parg[1]{(\meta{#1})} +\NewDocumentCommand{\init}{+v}{\hspace{\fill}初始值~=~\textcolor{blue}{\bfseries#1}} +\DeclareDocumentCommand\opt{m}{\texttt{#1}} +\DeclareDocumentCommand\kvopt{mm} + {\texttt{#1\breakablethinspace=\breakablethinspace#2}} +\def\breakablethinspace{\hskip 0.16667em\relax} +\begin{document} +%<!--CODEDOC--> \DisableImplementation + \EnableImplementation + \DocInput{\jobname.dtx} + \IndexLayout + \PrintChanges + \PrintIndex +\end{document} +%</driver> +% \fi +% +% \changes{v1.0.0}{2021/12/14}{开始编写模板} +% +% \CheckSum{376} +% \GetFileId{termsim.sty} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% \title{\bfseries\pkg{termsim}:终端窗口模拟宏包\\\bfseries\pkg{termsim}:terminal simulation pachage} +% \author{耿楠\\ \path{nangeng@nwafu.edu.cn}} +% \date{\filedate\qquad\fileversion\thanks{\url{https://github.com/registor/termsim}}\thanks{\url{https://gitee.com/nwafu_nan/termsim}}} +% \maketitle +% +% \begin{documentation} +% +% \begin{abstract} +% +% \pkg{termsim} 是一个基于\pkg{tcolorbox}宏包,用\LaTeX3 开发的 \LaTeX 宏包, +% 它提供了用于模拟Win10、Ubuntu和Mac的终端窗口的\env{terminal}环境和\tn{termfile}命令, +% \env{terminal}环境将环境中的内容在模拟的终端窗口中输出, +% 而\tn{termfile}命令用于将指定的文件读入后在模拟的终端窗口中输出。 +% 同时提供了\env{terminal*}环境和\tn{termfile*}命令,用于模拟带底线注释的终端窗口。 +% 操作系统类型和终端窗口颜色主题等样式, +% 可以通过\tn{termset}命令或\env{terminal}(\env{terminal*})环境和 +% \tn{termfile}(\tn{termfile*})命令的可选项进行设置。 +% +% \end{abstract} +% +% \tableofcontents +% +% \section{简要说明} +% +% \pkg{termsim} 是一个用于模拟Win10、Ubuntu和Mac终端窗口的\LaTeX{}宏包, +% 用于实现对Win10、Mac或Ubuntu终端窗口的模拟排版。 +% +% \section{用户接口} +% +% \subsection{\env{terminal}和\env{terminal*}环境} +% +% \begin{function}[added=2021-12-17,updated=2021-12-17]{terminal,terminal*} +% \begin{syntax} +% \tn{begin}\{terminal\} \oarg{外观选项} \Arg{窗口标题} +% ..... +% \tn{end}\{terminal\} +% +% \tn{begin}\{terminal*\} \oarg{外观选项} \oarg{底线注释} \Arg{窗口标题} +% ..... +% \tn{end}\{terminal*\} +% \end{syntax} +% +% 排版终端窗口,内容来自于由环境内容, +% 可以通过\Arg{窗口标题}为窗口设置标题。 +% +% \oarg{外观选项}中通过key-value方式设置终端窗口的外观。 +% +% 星号环境\texttt{terminal*}用于为终端窗口添加底线注释, +% 注意此时需要在\oarg{外观选项}后提供\oarg{底线注释}内容。 +% +% 终端窗口的外观也可以通过\tn{termset}命令的逗号分隔 +% key-value列表进行设置。 +% +% \end{function} +% \begin{Verbatim}[frame=none,numbers=left,gobble=5] +% \centering +% \termset{os=win10,theme=dark,shstretch=1.0} +% \begin{terminal}{窗口标题} +% C:\Users\Administrator 的目录 +% 2018/07/21 15:39 <DIR> . +% 2018/07/21 15:39 <DIR> .. +% 2018/07/13 08:35 <DIR> 3D Objects +% 2018/07/13 08:35 <DIR> Contacts +% 2018/08/06 07:46 <DIR> Desktop +% 2 个文件 6,029,312 字节 +% 18 个目录 14,035,107,840 可用字节 +% \end{terminal} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\termset{os=win10,theme=dark,shstretch=1.0} +%\begin{terminal}{窗口标题} +%C:\Users\Administrator 的目录 +%2018/07/21 15:39 <DIR> . +%2018/07/21 15:39 <DIR> .. +%2018/07/13 08:35 <DIR> 3D Objects +%2018/07/13 08:35 <DIR> Contacts +%2018/08/06 07:46 <DIR> Desktop +% 2 个文件 6,029,312 字节 +% 18 个目录 14,035,107,840 可用字节 +%\end{terminal} +%\end{minipage} +%\end{center} +% +% \subsection{\tn{termfile}和\tn{termfile*}命令} +% +% \begin{function}[added=2021-12-18,updated=2021-12-18]{\termfile,\termfile*} +% \begin{syntax} +% \tn{termfile} \oarg{外观选项} \Arg{窗口标题} \Arg{内容文件} +% \tn{termfile*} \oarg{外观选项} \oarg{底线注释} \Arg{窗口标题} \Arg{内容文件} +% \end{syntax} +% +% 排版终端窗口,内容来自于由\Arg{内容文件}, +% 可以通过\Arg{窗口标题}为窗口设置标题。 +% +% \oarg{外观选项}中通过key-value方式设置终端窗口的外观。 +% +% 星号命令\tn{termfile*}用于为终端窗口添加底线注释, +% 注意此时需要在\oarg{外观选项}后提供\oarg{底线注释}内容。 +% +% 排版样式也可以通过\tn{termset}命令的逗号分隔的 +% key-value列表进行设置。 +% \end{function} +% +% \newpage +% +% \begin{Verbatim}[frame=none,numbers=left,gobble=5] +% \centering +% \termfile{窗口标题}{test.bat} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\termfile{窗口标题}{test.bat} +%\end{minipage} +%\end{center} +% +%\subsection{\tn{termset}命令} +% +% \begin{function}[added=2021-12-18,updated=2021-12-18]{\termset} +% \begin{syntax} +% \tn{termset} \marg{键值列表} +% \end{syntax} +% \tn{termset} 的参数是一组由(英文)逗号分隔的选项列表, +% 列表中的选项采用 \kvopt{\meta{key}}{\meta{value}} 形式。 +% 部分选项的\meta{value} 可以省略。 +% 对于同一选项,后续设置会覆盖以前的设置。 +% +% 多数选项都设有默认值。 +% +% \tn{termset} 采用 \LaTeX3 风格的键值设置,支持不同类型以及多种 +% 层次的选项设定。键值列表中,“|=|”左右的空格不影响设置;但需注意, +% 参数列表中\textbf{不可以出现空行}。 +% +% 布尔型的参数 \kvopt{\meta{选项}}{true} 中的“|= true|”可以省略。 +% \end{function} +% +% \section{选项说明} +% +% \pkg{termsim}宏包提供了一系列选项,以设置终端窗口外观样式。 +% 载入\pkg{termsim}宏包后,以下选项均可通过用户接口命令\tn{termset}进行设置。 +% 同时,这些选项也可以通过\env{terminal}(\env{terminal*})环境或 +% \tn{termfile}(\tn{termfile*})命令的\oarg{外观选项}进行设置。 +% +% \subsection{代码引擎} +% +% \begin{function}[added=2021-12-18,updated=2021-12-18]{minted} +% \begin{syntax} +% minted = <\TTF> \init{true} +% \end{syntax} +% \opt{minted} 用于设置代码排版引擎,如为\textbf{true}则使用\pkg{minted}宏包 +% 排版终端窗口中的内容,如为\textbf{false}则使用\pkg{listings}宏包排版 +% 终端窗口中的内容。默认值为\textbf{true}。 +% \end{function} +% +% \subsection{操作系统} +% +% \begin{function}[added=2021-12-18,updated=2021-12-18]{os} +% \begin{syntax} +% os = <win10|mac|ubuntu> \init{win10} +% \end{syntax} +% \opt{os} 用于设置终端窗口的操作系统类型,默认值为\textbf{win10}。 +% \end{function} +% +% \subsection{颜色主题} +% +% \begin{function}[added=2021-12-18,updated=2021-12-18]{theme} +% \begin{syntax} +% theme = <dark|light|white> \init{dark} +% \end{syntax} +% \opt{theme} 用于设置终端窗口的颜色主题,默认值为\textbf{dark}。 +% \end{function} +% +% \subsection{代码样式} +% +% \begin{function}[added=2021-12-18,updated=2021-12-18]{shstyle} +% \begin{syntax} +% shstyle = \Arg{代码样式} \init{bw} +% \end{syntax} +% \opt{shstyle} 用于设置终端窗口内容(代码)的样式,仅对\textbf{minted} +% 引擎有效,默认值为\textbf{bw}。 +% \end{function} +% +% \subsection{代码字号} +% +% \begin{function}[added=2021-12-18,updated=2021-12-18]{shsize} +% \begin{syntax} +% shsize = \Arg{字号命令} \init{\small} +% \end{syntax} +% \opt{shsize} 用于设置终端窗口内容(代码)的字号,仅对\textbf{minted} +% 引擎有效,默认值为\textbf{\tn{small}}。 +% \end{function} +% +% \subsection{底线注释格式} +% +% \begin{function}[added=2021-12-18,updated=2021-12-18]{commentf} +% \begin{syntax} +% commentf = \Arg{格式命令组} \init{\small\sffamily} +% \end{syntax} +% \opt{commentf} 用于设置终端窗口底线注释的格式, +% 默认值为\textbf{\tn{small}\tn{sffamily}}。 +% \end{function} +% +% \subsection{代码行距} +% +% \begin{function}[added=2021-12-18,updated=2021-12-18]{shstretch} +% \begin{syntax} +% shstretch = \Arg{浮点数} \init{1.0} +% \end{syntax} +% \opt{shstretch} 用于设置终端窗口内容(代码)的行距,仅对\textbf{minted} +% 引擎有效,取浮点数。默认值为\textbf{1.0}。 +% \end{function} +% +% \newpage +% +% \section{排版样例} +% +% \pkg{termsim}宏包可用于需要排版操作系统终端窗口的场合, +% 以避免使用截图。终端窗口可以带/不带底线注释,也可以 +% 是暗色(dark)、亮色(light)或白色(white)颜色主题。 +% +% \subsection{Win10终端窗口} +% +% \subsubsection{\env{terminal}/\env{terminal*}环境} +% +% \begin{Verbatim}[frame=none,numbers=left,gobble=5] +% \centering +% \termset{os=win10,theme=dark,shstretch=1.0} +% \begin{terminal}{窗口标题} +% C:\Users\Administrator 的目录 +% 2018/07/21 15:39 <DIR> . +% 2018/07/21 15:39 <DIR> .. +% 2018/07/13 08:35 <DIR> 3D Objects +% 2018/07/13 08:35 <DIR> Contacts +% 2018/08/06 07:46 <DIR> Desktop +% 2 个文件 6,029,312 字节 +% 18 个目录 14,035,107,840 可用字节 +% \end{terminal} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\termset{os=win10,theme=dark,shstretch=1.0} +%\begin{terminal}{窗口标题} +%C:\Users\Administrator 的目录 +%2018/07/21 15:39 <DIR> . +%2018/07/21 15:39 <DIR> .. +%2018/07/13 08:35 <DIR> 3D Objects +%2018/07/13 08:35 <DIR> Contacts +%2018/08/06 07:46 <DIR> Desktop +% 2 个文件 6,029,312 字节 +% 18 个目录 14,035,107,840 可用字节 +%\end{terminal} +%\end{minipage} +%\end{center} +% +% \begin{Verbatim}[frame=none,numbers=left,gobble=5] +% \centering +% \begin{terminal*}[os=win10,theme=light][底线注释]{窗口标题} +% C:\Users\Administrator 的目录 +% 2018/07/21 15:39 <DIR> . +% 2018/07/21 15:39 <DIR> .. +% 2018/07/13 08:35 <DIR> 3D Objects +% 2018/07/13 08:35 <DIR> Contacts +% 2018/08/06 07:46 <DIR> Desktop +% 2 个文件 6,029,312 字节 +% 18 个目录 14,035,107,840 可用字节 +% \end{terminal*} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\begin{terminal*}[os=win10,theme=light][底线注释]{窗口标题} +%C:\Users\Administrator 的目录 +%2018/07/21 15:39 <DIR> . +%2018/07/21 15:39 <DIR> .. +%2018/07/13 08:35 <DIR> 3D Objects +%2018/07/13 08:35 <DIR> Contacts +%2018/08/06 07:46 <DIR> Desktop +% 2 个文件 6,029,312 字节 +% 18 个目录 14,035,107,840 可用字节 +%\end{terminal*} +%\end{minipage} +%\end{center} +% +% +% \subsubsection{\tn{termfile}/\tn{termfile*}命令} +% +% \begin{Verbatim}[frame=none,numbers=left] +% \centering +% \termset{os=win10,theme=dark} +% \termfile{窗口标题}{test.bat} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\termset{os=win10,theme=dark} +%\termfile{窗口标题}{test.bat} +%\end{minipage} +%\end{center} +% +% \begin{Verbatim}[frame=none,numbers=left] +% \centering +% \termfile*[os=win10,theme=light][底线注释]{窗口标题}{test.bat} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\termfile*[os=win10,theme=light][底线注释]{窗口标题}{test.bat} +%\end{minipage} +%\end{center} +% +% \newpage +% \subsection{Mac终端窗口} +% +% \subsubsection{\env{terminal}/\env{terminal*}环境} +% +% \begin{Verbatim}[frame=none,numbers=left,gobble=5] +% \centering +% \termset{os=mac,theme=dark} +% \begin{terminal}{窗口标题} +% xxxxxx@xxxxxx-lap:~$ ls +% Desktop Downloads p2 Public Templates Videos +% Documents Music Pictures snap '#test#' workspace +% xxxxxx@xxxxxx-lap:~$ +% \end{terminal} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\termset{os=mac,theme=dark} +%\begin{terminal}{窗口标题} +%xxxxxx@xxxxxx-lap:~$ ls +%Desktop Downloads p2 Public Templates Videos +%Documents Music Pictures snap '#test#' workspace +%xxxxxx@xxxxxx-lap:~$ +%\end{terminal} +%\end{minipage} +%\end{center} +% +% \begin{Verbatim}[frame=none,numbers=left,gobble=5] +% \centering +% \begin{terminal*}[os=mac,theme=light][底线注释]{窗口标题} +% xxxxxx@xxxxxx-lap:~$ ls +% Desktop Downloads p2 Public Templates Videos +% Documents Music Pictures snap '#test#' workspace +% xxxxxx@xxxxxx-lap:~$ +% \end{terminal*} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\begin{terminal*}[os=mac,theme=light][底线注释]{窗口标题} +%xxxxxx@xxxxxx-lap:~$ ls +%Desktop Downloads p2 Public Templates Videos +%Documents Music Pictures snap '#test#' workspace +%xxxxxx@xxxxxx-lap:~$ +%\end{terminal*} +%\end{minipage} +%\end{center} +% +% \subsubsection{\tn{termfile}/\tn{termfile*}命令} +% +% \begin{Verbatim}[frame=none,numbers=left] +% \centering +% \termset{os=mac,theme=dark} +% \termfile{窗口标题}{testls} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\termset{os=mac,theme=dark} +%\termfile{窗口标题}{testls} +%\end{minipage} +%\end{center} +% \newpage +% \begin{Verbatim}[frame=none,numbers=left] +% \centering +% \termfile*[os=mac,theme=light][底线注释]{窗口标题}{testls} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\termfile*[os=mac,theme=light][底线注释]{窗口标题}{testls} +%\end{minipage} +%\end{center} +% +% \subsection{Ubuntu终端窗口} +% +% \subsubsection{\env{terminal}/\env{terminal*}环境} +% +% \begin{Verbatim}[frame=none,numbers=left,gobble=5] +% \centering +% \termset{os=ubuntu,theme=dark} +% \begin{terminal}{窗口标题} +% xxxxxx@xxxxxx-lap:~/Desktop $ +% git clone git@gitee.com:xxxxxx/xxxxxx +% 正克隆到 'xxxxxx'... +% remote: Enumerating objects: 106, done. +% remote: Counting objects: 100% (106/106), done. +% remote: Compressing objects: 100% (105/105), done. +% remote: Total 106 (delta 9), reused 0 (delta 0) +% 接收对象中: 100% (106/106), 237.88 MiB | 730.00 KiB/s, +% 完成. +% 处理 delta 中: 100% (9/9), 完成. +% 正在检出文件: 100% (75/75), 完成. +% xxxxxx@xxxxxx-lap:~/Desktop $ +% \end{terminal} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\termset{os=ubuntu,theme=dark} +%\begin{terminal}{窗口标题} +%xxxxxx@xxxxxx-lap:~/Desktop $ +%git clone git@gitee.com:xxxxxx/xxxxxx +%正克隆到 'xxxxxx'... +%remote: Enumerating objects: 106, done. +%remote: Counting objects: 100% (106/106), done. +%remote: Compressing objects: 100% (105/105), done. +%remote: Total 106 (delta 9), reused 0 (delta 0) +%接收对象中: 100% (106/106), 237.88 MiB | 730.00 KiB/s, +%完成. +%处理 delta 中: 100% (9/9), 完成. +%正在检出文件: 100% (75/75), 完成. +%xxxxxx@xxxxxx-lap:~/Desktop $ +%\end{terminal} +%\end{minipage} +%\end{center} +% +% \begin{Verbatim}[frame=none,numbers=left,gobble=5] +% \centering +% \begin{terminal*}[os=ubuntu,theme=light][底线注释]{窗口标题} +% xxxxxx@xxxxxx-lap:~/Desktop $ +% git clone git@gitee.com:xxxxxx/xxxxxx +% 正克隆到 'xxxxxx'... +% remote: Enumerating objects: 106, done. +% remote: Counting objects: 100% (106/106), done. +% remote: Compressing objects: 100% (105/105), done. +% remote: Total 106 (delta 9), reused 0 (delta 0) +% 接收对象中: 100% (106/106), 237.88 MiB | 730.00 KiB/s, +% 完成. +% 处理 delta 中: 100% (9/9), 完成. +% 正在检出文件: 100% (75/75), 完成. +% xxxxxx@xxxxxx-lap:~/Desktop $ +% \end{terminal*} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\begin{terminal*}[os=ubuntu,theme=light][底线注释]{窗口标题} +%xxxxxx@xxxxxx-lap:~/Desktop $ +%git clone git@gitee.com:xxxxxx/xxxxxx +%正克隆到 'xxxxxx'... +%remote: Enumerating objects: 106, done. +%remote: Counting objects: 100% (106/106), done. +%remote: Compressing objects: 100% (105/105), done. +%remote: Total 106 (delta 9), reused 0 (delta 0) +%接收对象中: 100% (106/106), 237.88 MiB | 730.00 KiB/s, +%完成. +%处理 delta 中: 100% (9/9), 完成. +%正在检出文件: 100% (75/75), 完成. +%xxxxxx@xxxxxx-lap:~/Desktop $ +%\end{terminal*} +%\end{minipage} +%\end{center} +% +% \subsubsection{\tn{termfile}/\tn{termfile*}命令} +% +% \begin{Verbatim}[frame=none,numbers=left] +% \centering +% \termset{os=ubuntu,theme=dark} +% \termfile{窗口标题}{testsh} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\termset{os=ubuntu,theme=dark} +%\termfile{窗口标题}{testsh} +%\end{minipage} +%\end{center} +% +% \begin{Verbatim}[frame=none,numbers=left] +% \centering +% \termfile*[os=ubuntu,theme=light][底线注释]{窗口标题}{testsh} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\termfile*[os=ubuntu,theme=light][底线注释]{窗口标题}{testsh} +%\end{minipage} +%\end{center} +% +% 也可以使用\texttt{white}颜色主题,使用白底黑字排版,以便 +% 打印输出。 +% +% \begin{Verbatim}[frame=none,numbers=left,gobble=5] +% \centering +% \termset{os=ubuntu,theme=white} +% \begin{terminal}{窗口标题} +% xxxxxx@xxxxxx-lap:~/Desktop $ +% git clone git@gitee.com:xxxxxx/xxxxxx +% 正克隆到 'xxxxxx'... +% remote: Enumerating objects: 106, done. +% remote: Counting objects: 100% (106/106), done. +% remote: Compressing objects: 100% (105/105), done. +% remote: Total 106 (delta 9), reused 0 (delta 0) +% 接收对象中: 100% (106/106), 237.88 MiB | 730.00 KiB/s, +% 完成. +% 处理 delta 中: 100% (9/9), 完成. +% 正在检出文件: 100% (75/75), 完成. +% xxxxxx@xxxxxx-lap:~/Desktop $ +% \end{terminal} +% \end{Verbatim} +% +%\begin{center} +%\begin{minipage}{0.75\textwidth} +%\termset{os=ubuntu,theme=white} +%\begin{terminal}{窗口标题} +%xxxxxx@xxxxxx-lap:~/Desktop $ +%git clone git@gitee.com:xxxxxx/xxxxxx +%正克隆到 'xxxxxx'... +%remote: Enumerating objects: 106, done. +%remote: Counting objects: 100% (106/106), done. +%remote: Compressing objects: 100% (105/105), done. +%remote: Total 106 (delta 9), reused 0 (delta 0) +%接收对象中: 100% (106/106), 237.88 MiB | 730.00 KiB/s, +%完成. +%处理 delta 中: 100% (9/9), 完成. +%正在检出文件: 100% (75/75), 完成. +%xxxxxx@xxxxxx-lap:~/Desktop $ +%\end{terminal} +%\end{minipage} +%\end{center} +% +% \end{documentation} +% +% \StopEventually{} +% +% \begin{implementation} +% +% \section{代码实现} +% +% 该宏包使用 \LaTeX3 语法编写,依赖 \pkg{expl3} 环境, +% 并需调用 \pkg{l3packages}、\pkg{tcolorbox}、\pkg{minted} +% \pkg{listings}、\pkg{fontawesome5}等宏包。 +% +% 按照 \LaTeX3 语法,代码中的空格、换行、回车与制表符会完全被忽略, +% 而下划线“|_|”和冒号“|:|”则可作为一般字母使用。 +% 正常的空格可以使用“|~|”代替;至于 |~| 原来所表示的“带子”, +% 则要用 \LaTeXe{} 的原始命令 \tn{nobreakspace} 代替。 +% +% 以下代码中有一些形如 \textcolor[HTML]{2E3191}{\textsf{<*package>}} +% 的标记,这是 \pkg{DocStrip} 中的“guard”,用来选择性地提取文件。 +% “\textsf{*}”和“\textsf{/}”分别表示该部分的开始和结束。不含 +% “\textsf{*}”和“\textsf{/}”的 guard 出现在行号右侧,它们用来确定 +% 单独一行代码的归属。这些 guard 的颜色深浅不一,用以明确嵌套关系。 +% +% 另有若干形如 \textcolor[HTML]{AD1457}{\textsf{<@@=termsim>}} 的 guard, +% 它们由 \pkg{l3docstrip} 定义,用来标识名字空间(模块)。 +% +% \subsection{环境检测与准备} +% +% \begin{macrocode} +%<*package> +%<@@=termsim> +% \end{macrocode} +% +% \subsection{载入宏包} +% +% 载入必要的宏包 +% +% \begin{macrocode} +\RequirePackage { xtemplate, l3keys2e, xparse } +% \end{macrocode} +% +% 载入\pkg{fontawesome5}、\pkg{tcolorbox}、\pkg{varwidth}、 +% \pkg{amssymb}、\pkg{xcolor}、\pkg{etoolbox}宏包。 +% +% \begin{macrocode} +\RequirePackage {fontawesome5, tcolorbox, varwidth, amssymb, xcolor, etoolbox} +% \end{macrocode} +% +% 解决Expl3中\pkg{tcolorbox}和\pkg{tikz}附加库无法加载的 +% 补丁(需要\pkg{etoolbox}宏包支持) +% +% \url{https://tex.stackexchange.com/questions/57424/using-of-usetikzlibrary-in-an-expl3-package-fails} +% +% \begin{macrocode} +\ExplSyntaxOff +\patchcmd +{\tcb@input@library@in} + {% + \input\tcbpkgprefix#1\relax% + } + {% + \@pushfilename + \input\tcbpkgprefix#1\relax% + \@popfilename + } + {}{} + +\patchcmd +{\pgfutil@InputIfFileExists} + {\input #1} + {% + \@pushfilename + \xdef\@currname{#1}% + \input #1 % + \@popfilename + } + {}{} +\ExplSyntaxOn +% \end{macrocode} +% +% 解决minted的autogobble选项与Python3的兼容性问题 +% 和fancyvrb宏包命令变更的问题 +% +% \url{https://github.com/gpoore/minted/issues/316} +% +% \begin{macrocode} +\ExplSyntaxOff +\RequirePackage {regexpatch} % for starred \xpatchcmd which can replace all +\makeatletter +% trick, in order to get the integer value from either a macro or register +% in an expandable way +\def\minted@use@FancyVerbStartNum{\the\numexpr\FancyVerbStartNum} +\def\minted@use@FancyVerbStopNum{\the\numexpr\FancyVerbStopNum} + +% patch for fivesum computation +\xpatchcmd*\minted@pygmentize + {\ifx\FancyVerbStartNum\z@ 0\else\FancyVerbStartNum\fi} + {\minted@use@FancyVerbStartNum} + {}{\PatchFailed} +\xpatchcmd*\minted@pygmentize + {\ifx\FancyVerbStopNum\z@ 0\else\FancyVerbStopNum\fi} + {\minted@use@FancyVerbStopNum} + {}{\PatchFailed} + +% patch for option "autogobble" +\xpatchcmd\minted@autogobble + {\ifx\FancyVerbStartNum\z@ 0\else\FancyVerbStartNum\fi} + {\minted@use@FancyVerbStartNum} + {}{\PatchFailed} +\xpatchcmd\minted@autogobble + {\ifx\FancyVerbStopNum\z@ 0\else\FancyVerbStopNum\fi} + {\minted@use@FancyVerbStopNum} + {}{\PatchFailed} +\makeatother +\ExplSyntaxOn +% \end{macrocode} +% +% 载入\pkg{tcolorbox}和\pkg{tikz}附加库 +% +% \begin{macrocode} +\tcbuselibrary{skins, xparse, breakable} +\usetikzlibrary{shapes.geometric} +% \end{macrocode} +% +% \subsection{定义颜色} +% +% \begin{macrocode} +\definecolor{mpurple}{RGB}{48,10,36} +\definecolor{mgray}{RGB}{70,72,67} +\definecolor{ogray}{RGB}{148,147,141} +\definecolor{oorange}{RGB}{233,101,56} +\definecolor{termimal}{RGB}{80,78,70} +\definecolor{linux}{RGB}{0,39,51} +\definecolor{windows}{HTML}{00B294} +\definecolor{cvgrayc}{RGB}{247,247,247} +\definecolor{cvgray}{RGB}{220,220,220} +\definecolor{cvgrayb}{RGB}{153,153,153} +\definecolor{cvblue}{RGB}{223,238,255} +\definecolor{zhanqing}{RGB}{0,51,113} +\definecolor{chengse}{RGB}{250,140,53} + +\definecolor{AppleRed}{RGB}{255,95,86} +\definecolor{AppleYellow}{RGB}{255,189,46} +\definecolor{AppleGreen}{RGB}{39,201,63} +\definecolor{AppleGray}{HTML}{D8D6D9} + +\definecolor{WinGray}{HTML}{FFFFFF} +\definecolor{WinBlue}{HTML}{1883D7} +% \end{macrocode} +% +% \subsection{终端盒子图标设计} +% +% 用TikZ绘制Ubuntu终端盒子的最小化、关闭和最大化图标 +% +% \begin{macrocode} +\newcommand{\UbuntuMin}{% + \begin{tikzpicture}[x=2.4ex,y=2.4ex,line~width=0.15ex,scale=1] + \shade[shading=ball,left~color=ogray,right~color=ogray!50!white] (0,0) circle (0.5); + \draw[termimal](-0.3,0)--(0.3,0); + \end{tikzpicture} +} +\newcommand{\UbuntuClose}{% + \begin{tikzpicture}[x=2.4ex,y=2.4ex,line~width=0.15ex,scale=1] + \shade[shading=ball,left~color=oorange,right~color=oorange!70!white] (0,0) circle (0.5); + \draw[termimal](-0.25,-0.25)--(0.25,0.25); + \draw[termimal](-0.25,0.25)--(0.25,-0.25); + \end{tikzpicture} +} +\newcommand{\UbuntuMax}{% + \begin{tikzpicture}[x=2.4ex,y=2.4ex,line~width=0.15ex,scale=1] + \shade [shading=ball,left~color=ogray,right~color=ogray!50!white] (0,0) circle (0.5); + \draw[termimal](-0.25,-0.2)rectangle(0.25,0.2); + \end{tikzpicture} +} +% \end{macrocode} +% +% 绘制Windows Logo +% +% \begin{macrocode} +\newcommand{\WindowsLogo}{% + \begin{tikzpicture}[square/.style={regular~polygon,regular~polygon~sides=4}, + scale=0.65, every~node/.style={scale=0.65}] + \node[square,draw,fill=black,text=white] at (0, 0) (a) {\small\faTerminal}; + \end{tikzpicture} +} +% \end{macrocode} +% +% \subsection{终端盒子样式设计} +% +% 定义Mac终端盒子的tcolorbox样式 +% +% \begin{macrocode} +\tcbset{% + skin=enhanced,% + apple/.style={% + halign~title=center,% + skin=bicolor,% + boxrule=0.5mm,% + breakable,% + frame~style={% + draw=AppleGray,% + left~color=AppleGray,% + right~color=AppleGray% + },% + overlay~unbroken = {% + \node[inner~sep=0pt,anchor=north~west,yshift=-4pt,xshift=10pt,text=white] + at (frame.north~west) {\textcolor{AppleRed}{\faCircle}$\,$ + \textcolor{AppleYellow}{\faCircle}$\,$ + \textcolor{AppleGreen}{\faCircle}}; + },% + overlay~first = {% + \node[inner~sep=0pt,anchor=north~west,yshift=-4pt,xshift=10pt,text=white] + at (frame.north~west) {\textcolor{AppleRed}{\faCircle}$\,$ + \textcolor{AppleYellow}{\faCircle}$\,$ + \textcolor{AppleGreen}{\faCircle}}; + },% + fonttitle=\sffamily,%\bfseries,% + fontupper=\small\sffamily,% + fontlower=\small\sffamily% + }, + appledark/.style={% + apple,% + colback=black,% + colupper=white,% + colbacktitle=AppleGray,% + colframe=AppleGray,% + coltitle=black% + %coltext=MyLightGray + }, + applelight/.style={% + apple,% + colback=cvgrayc,% + colupper=black,% + colbacktitle=AppleGray,% + colframe=AppleGray,% + coltitle=black% + },% + applewhite/.style={% + apple,% + colback=white,% + colupper=black,% + colbacktitle=AppleGray,% + colframe=AppleGray,% + coltitle=black% + },% +}% +% \end{macrocode} +% +% 定义Win10终端盒子的tcolorbox样式 +% +% \begin{macrocode} +\tcbset{% + skin=enhanced,% + win10/.style={% + skin=bicolor,% + boxrule=0.1mm,% + %toptitle=1ex, + sharp~corners, + breakable,% + colbacktitle=WinGray,% + colframe=WinGray,% + coltitle=black,% + fonttitle=\sffamily,%\bfseries, + fontupper=\small\sffamily, + fontlower=\small\sffamily, + frame~style={% + draw=WinBlue,% + left~color=WinBlue,% + right~color=WinBlue% + },% + overlay~unbroken = {% + \node[inner~sep=0pt,anchor=north~west,yshift=-3pt,xshift=1.2pt,text=black] + at (frame.north~west){\WindowsLogo}; + \node[inner~sep=0pt,anchor=north~east,yshift=-5pt,xshift=-8pt,text=black] + at (frame.north~east){\rule{0.8em}{0.6pt}\quad$\square$\quad{\Large$\times$}}; + },% + overlay~first = {% + \node[inner~sep=0pt,anchor=north~west,yshift=-3pt,xshift=1.0pt,text=black] + at (frame.north~west){\WindowsLogo}; + \node[inner~sep=0pt,anchor=north~east,yshift=-5pt,xshift=-8pt,text=black] + at (frame.north~east){\rule{0.8em}{0.6pt}\quad$\square$\quad{\Large$\times$}}; + }% + }, + win10dark/.style={ + win10,% + colback=black,% + colupper=white,% + %coltext=white% + }, + win10light/.style={ + win10,% + colback=white,% + colupper=black,% + %coltext=black% + }, + win10white/.style={ + win10,% + colback=white,% + colupper=black,% + %coltext=white% + }, +}% +% \end{macrocode} +% +% 定义Ubuntu终端盒子的tcolorbox样式 +% +% \begin{macrocode} +\tcbset{% + skin=enhanced,% + ubuntu/.style={% + halign~title=center,% + skin=bicolor,% + boxrule=0.5mm,% + breakable,% + overlay~unbroken = {% + \node[inner~sep=0pt,anchor=north~east,yshift=-3.5pt,xshift=-5pt,text=white] + at (frame.north~east){\UbuntuMin$\,$\UbuntuMax$\,$\UbuntuClose};% + },% + overlay~first = {% + \node[inner~sep=0pt,anchor=north~east,yshift=-3.5pt,xshift=-5pt,text=white] + at (frame.north~east){\UbuntuMin$\,$\UbuntuMax$\,$\UbuntuClose};% + },% + fonttitle=\sffamily,% + fontupper=\small\sffamily,% + fontlower=\small\sffamily% + }, + udark/.style={% + ubuntu,% + frame~style={% + draw=mgray,% + left~color=mgray,% + right~color=mgray% + },% + colback=mpurple,% + colupper=white,% + colbacktitle=mgray,% + colframe=mgray,% + coltitle=white% + %coltext=MyLightGray + }, + ulight/.style={% + ubuntu,% + frame~style={% + draw=cvgrayb,% + left~color=cvgrayb,% + right~color=cvgrayb% + },% + colback=cvgrayc,% + colupper=black,% + colbacktitle=cvgrayb,% + colframe=cvgrayb,% + coltitle=black% + },% + uwhite/.style={% + ubuntu,% + frame~style={% + draw=cvgrayb,% + left~color=cvgrayb,% + right~color=cvgrayb% + },% + colback=white,% + colupper=black,% + colbacktitle=cvgrayb,% + colframe=cvgrayb,% + coltitle=black% + },% +}% +% \end{macrocode} +% +% \subsection{内部变量声明} +% +% \begin{variable}{\l_@@_minted_bool, +% \l_@@_comment_bool, +% \l_@@_os_type_int, +% \l_@@_color_theme_int, +% \l_@@_code_style_tl, +% \l_@@_code_fontsize_tl, +% \l_@@_comment_format_tl, +% \l_@@_baseline_stretch_tl, +% \l_@@_linenumber_sep_tl +% } +% 定义变量。 +% +% \begin{macrocode} +\bool_new:N \l_@@_minted_bool +\bool_new:N \l_@@_comment_bool +\int_new:N \l_@@_os_type_int +\int_new:N \l_@@_color_theme_int +% +\tl_new:N \l_@@_shell_style_tl +\tl_new:N \l_@@_shell_fontsize_tl +\tl_new:N \l_@@_comment_format_tl +\tl_new:N \l_@@_shell_baseline_stretch_tl +\tl_new:N \l_@@_linenumber_sep_tl +% \end{macrocode} +% \end{variable} +% +% \subsection{选项处理} +% +% 定义 |termsim| 键值类。 +% \begin{macrocode} +\keys_define:nn { termsim } + { +% \end{macrocode} +% +% \begin{macro}{minted} +% 是否使用minted宏包排版代码,默认为true。 +% \begin{macrocode} + minted .bool_set:N = \l_@@_minted_bool, + minted .default:n = true, + minted .initial:n = true, +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{os} +% 选择操作系统,默认为Win10。 +% \begin{macrocode} + os .choice:, + os .value_required:n = true, + os .choices:nn = + { win10, mac, ubuntu } + { \int_set_eq:NN \l_@@_os_type_int \l_keys_choice_int }, + os .initial:n = win10, +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{theme} +% 选择终端窗口颜色主题,默认为dark。 +% \begin{macrocode} + theme .choice:, + theme .value_required:n = true, + theme .choices:nn = + { dark, light, white } + { \int_set_eq:NN \l_@@_color_theme_int \l_keys_choice_int }, + theme .initial:n = dark, +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{shstyle} +% 代码样式 +% \begin{macrocode} + shstyle .tl_set:N = \l_@@_shell_style_tl, + shstyle .initial:n = bw, +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{shsize} +% 代码字号 +% \begin{macrocode} + shsize .tl_set:N = \l_@@_shell_fontsize_tl, + shsize .initial:n = \small, +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{commentf} +% 注释格式 +% \begin{macrocode} + commentf .tl_set:N = \l_@@_comment_format_tl, + commentf .initial:n = \small\sffamily, +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{shstrech} +% 基线伸展系数 +% \begin{macrocode} + shstretch .tl_set:N = \l_@@_shell_baseline_strech_tl, + shstretch .initial:n = 1.0, +% \end{macrocode} +% \end{macro} +% +% 处理未知选项。 +% \begin{macrocode} + unknown .code:n = { \@@_error:n { unknown-option } } + } +\msg_new:nnn { termsim } { unknown-option } + { package~ option~ "\l_keys_key_tl"~ is~ unknown. } +% \end{macrocode} +% +% 参数默认值 +% \begin{macrocode} +\keys_set:nn { termsim } + { + minted = true, + os = win10, + theme = dark, + } +% \end{macrocode} +% +% \subsection{选项用户接口} +% +% \begin{macro}{\termset} +% 选项设置用户接口。 +% \begin{macrocode} +\NewDocumentCommand \termset { m } + { \keys_set:nn { termsim } {#1} } +% \end{macrocode} +% \end{macro} +% +% \subsection{内部函数} +% +% \begin{macro}{\@@_minted_tcbset:} +% 设置终端盒子minted宏包参数。 +% +% \begin{macrocode} +\cs_new:Npn \@@_minted_tcbset:n #1 + { + \tcbset{ + listing~engine=minted,% + minted~style=\tl_use:N \l_@@_shell_style_tl,% + minted~options={% + breaklines,% + fontsize=\tl_use:N \l_@@_shell_fontsize_tl,% + baselinestretch=#1,% + breaksymbolleft={},% + linenos=false,% + },% + minted~language=bash% + } + } +\cs_generate_variant:Nn \@@_minted_tcbset:n {V} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_listings_tcbset:} +% 设置终端盒子listings宏包参数。 +% +% \begin{macrocode} +\cs_new:Npn \@@_listings_tcbset: + { + \lstset{% general command to set parameter(s) + basicstyle=\ttfamily\tl_use:N \l_@@_shell_fontsize_tl, % print whole listing small + keywordstyle=\color{chengse}\bfseries,% + identifierstyle=, % nothing happens + breaklines=true, + commentstyle=\itshape\color{gray}, + stringstyle=\ttfamily, % typewriter type for strings + numbers=left,% + numberstyle=\tl_use:N \l_@@_shell_fontsize_tl\sffamily\color[rgb]{0.5,0.5,1.0},% + }% + } +\cs_generate_variant:Nn \@@_minted_tcbset:n {V} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_comment_tcbset:} +% 设置终端盒子底线注释。 +% +% \begin{macrocode} +\cs_new:Npn \@@_comment_tcbset:n #1 + { + \bool_if:NTF { \l_@@_comment_bool } + { + \tcbset{% + listing~and~comment,% + colbacklower=tcbcolback!5!yellow!10!white,% + collower=linux,% + comment={\tl_use:N \l_@@_comment_format_tl~#1},% + } + }{ + \tcbset{ listing~only,} + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_terminal_theme_select:} +% 选择终端盒子颜色主题。 +% +% \begin{macrocode} +\cs_new:Npn \@@_terminal_theme_select: + { + \int_case:nn {\l_@@_os_type_int} + { + {1}{ + \int_case:nn {\l_@@_color_theme_int} + { + {1}{ + \tcbset{ win10dark, } + } + {2}{ + \tcbset{ win10light, } + } + {3}{ + \tcbset{ win10white, } + } + } + } + {2}{ + \int_case:nn {\l_@@_color_theme_int} + { + {1}{ + \tcbset{ appledark, } + } + {2}{ + \tcbset{ applelight, } + } + {3}{ + \tcbset{ applewhite, } + } + } + } + {3}{ + \int_case:nn {\l_@@_color_theme_int} + { + {1}{ + \tcbset{ udark, } + } + {2}{ + \tcbset{ ulight, } + } + {3}{ + \tcbset{ uwhite, } + } + } + } + } + } +% \end{macrocode} +% \end{macro} +% +% \subsection{定义排版环境和命令} +% +% \begin{macrocode} +\bool_if:NTF \l_@@_minted_bool + { +% \end{macrocode} +% +% 使用\pkg{minted}宏包排版代码 +% +% \begin{macrocode} + \tcbuselibrary{minted} +% \end{macrocode} +% +% 定义不带底线注释的窗口模拟环境\env{terminal} +% +% \begin{macrocode} + \NewDocumentEnvironment{ terminal }{O{} O{} m } + { + \bool_set_false:N \l_@@_comment_bool + \group_begin: + \IfNoValueF{#1}{ \keys_set:nn { termsim } { #1 } } + \@@_comment_tcbset:n { #2 } + \@@_terminal_theme_select: + \@@_minted_tcbset:V \l_@@_shell_baseline_stretch_tl + \tcbset{ title={#3} }% + \tcblisting{} + }{ + \endtcblisting + \group_end: + } +% \end{macrocode} +% +% 定义带底线注释的窗口模拟环境\env{terminal*} +% +% \begin{macrocode} + \NewDocumentEnvironment{ terminal* }{O{} O{} m } + { + \bool_set_true:N \l_@@_comment_bool + \group_begin: + \IfNoValueF{#1}{ \keys_set:nn { termsim } { #1 } } + \@@_comment_tcbset:n { #2 } + \@@_terminal_theme_select: + \@@_minted_tcbset:V \l_@@_shell_baseline_stretch_tl + \tcbset{ title={#3} }% + \tcblisting{} + }{ + \endtcblisting + \group_end: + } +% \end{macrocode} +% +% 定义带/不带底线注释的从文件读取内容的命令\tn{termfile}/\tn{termfile*} +% +% \begin{macrocode} + \NewDocumentCommand \termfile { s O{} O{} m m } + { + \IfBooleanTF{#1} + { + \bool_set_true:N \l_@@_comment_bool + }{ + \bool_set_false:N \l_@@_comment_bool + } + + \group_begin: + \IfNoValueF{#2}{ \keys_set:nn { termsim } { #2 } } + \@@_comment_tcbset:n { #3 } + \@@_terminal_theme_select: + \@@_minted_tcbset:V \l_@@_shell_baseline_stretch_tl + \tcbset{ + title={#4}, + listing~file={#5}, + }% + \tcbinputlisting{ } + \group_end: + } + }{ +% \end{macrocode} +% +% 使用\pkg{listings}宏包排版代码,并设置代码样式。 +% +% \begin{macrocode} + \tcbuselibrary{listings}% 用listings排版代码 + + \@@_listings_tcbset: + +% \end{macrocode} +% +% 定义不带底线注释的窗口模拟环境\env{terminal} +% +% \begin{macrocode} + \NewDocumentEnvironment{ terminal }{O{} O{} m } + { + \bool_set_false:N \l_@@_comment_bool + \group_begin: + \IfNoValueF{#1}{ \keys_set:nn { termsim } { #1 } } + \@@_comment_tcbset:n { #2 } + \@@_terminal_theme_select: + \tcbset{ + title={#3}, + listing~options={ + language=bash, + numbers=none, + } + }% + \tcblisting{} + }{ + \endtcblisting + \group_end: + } +% \end{macrocode} +% +% 定义带底线注释的窗口模拟环境\env{terminal*} +% +% \begin{macrocode} + \NewDocumentEnvironment{ terminal* }{O{} O{} m } + { + \bool_set_true:N \l_@@_comment_bool + \group_begin: + \IfNoValueF{#1}{ \keys_set:nn { termsim } { #1 } } + \@@_comment_tcbset:n { #2 } + \@@_terminal_theme_select: + \tcbset{ + title={#3}, + listing~options={ + language=bash, + numbers=none, + } + }% + \tcblisting{} + }{ + \endtcblisting + \group_end: + } +% \end{macrocode} +% +% 定义带/不带底线注释的从文件读取内容的命令\tn{termfile}/\tn{termfile*} +% +% \begin{macrocode} + \NewDocumentCommand \termfile { s O{} O{} m m } + { + \IfBooleanTF{#1} + { + \bool_set_true:N \l_@@_comment_bool + }{ + \bool_set_false:N \l_@@_comment_bool + } + \group_begin: + \IfNoValueF{#2}{ \keys_set:nn { termsim } { #2 } } + \@@_comment_tcbset:n { #3 } + \@@_terminal_theme_select: + \tcbset{ + title={#4}, + listing~file={#5}, + listing~options={ + language=bash, + numbers=none, + },% + }% + \tcbinputlisting{ } + \group_end: + } + } +% \end{macrocode} +% +% \begin{macrocode} +\endinput +% \end{macrocode} +% +% \begin{macrocode} +%</package> +% \end{macrocode} +% +% \end{implementation} +% +% \Finale +% +\endinput diff --git a/macros/latex/contrib/termsim/termsim.pdf b/macros/latex/contrib/termsim/termsim.pdf Binary files differnew file mode 100644 index 0000000000..3c904bfb98 --- /dev/null +++ b/macros/latex/contrib/termsim/termsim.pdf |