From 7c33483242d8e20f8f809e76ec9a3406db2dbfab Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Tue, 31 Jan 2023 03:01:43 +0000 Subject: CTAN sync 202301310301 --- macros/latex/contrib/naive-ebnf/naive-ebnf.dtx | 32 ++++++++++++++++++++----- macros/latex/contrib/naive-ebnf/naive-ebnf.pdf | Bin 443528 -> 542463 bytes 2 files changed, 26 insertions(+), 6 deletions(-) (limited to 'macros/latex/contrib/naive-ebnf') diff --git a/macros/latex/contrib/naive-ebnf/naive-ebnf.dtx b/macros/latex/contrib/naive-ebnf/naive-ebnf.dtx index 6213cf6d52..cdd047a30f 100644 --- a/macros/latex/contrib/naive-ebnf/naive-ebnf.dtx +++ b/macros/latex/contrib/naive-ebnf/naive-ebnf.dtx @@ -50,7 +50,7 @@ %\NeedsTeXFormat{LaTeX2e} %\ProvidesPackage{naive-ebnf} %<*package> -[2023-01-29 0.0.2 EBNF in Plain Text] +[2023-01-30 0.0.3 EBNF in Plain Text] % %<*driver> \documentclass{ltxdoc} @@ -81,7 +81,7 @@ % % \section{Introduction} % -% This package helps render a +% This package helps render an % \href{https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form}{Extended Backus-Naur Form} % using plain text notation: % \begin{docshot} @@ -97,6 +97,8 @@ % \end{document} % \end{docshot} +% \DescribeMacro{ebnf} +% The |ebnf| environment \emph{doesn't} add any formatting to the paragraph, but only replaces the plain text symbols, such as ``|:=|'' and ``||'' with proper \LaTeX{} commands. % The following syntax is understood inside the |ebnf| environment: % \begin{itemize} % \item |:=| separates the left-hand side from the right-hand side of the production rule; @@ -133,6 +135,19 @@ % with \terminal{)}. % \end{document} % \end{docshot} +% It's possible to use them in math-mode too, for example: +% \docshotOptions{firstline=6,lastline=8} +% \begin{docshot} +% \documentclass{article} +% \pagestyle{empty} +% \usepackage[paperwidth=3in]{geometry} +% \usepackage{naive-ebnf} +% \begin{document} +% If $\terminal{(} f_1 \nonterminal{Var} +% \terminal{)}$ is always true, then +% $f_1$ is a tautology. +% \end{document} +% \end{docshot} % \section{Package Options} @@ -187,12 +202,15 @@ % \begin{macro}{\terminal} % \changes{0.0.2}{2023/01/29}{New command \texttt{\char`\\terminal} added, to enable rendering terminal symbols outside of the \texttt{ebnf} environment.} +% \changes{0.0.3}{2023/01/30}{Quotes fixed in both text and math modes.} % Then, we a command to render a single terminal: % \begin{macrocode} \makeatletter -\newcommand\terminal[1]{% +\newcommand\terminal[1]{{% \relax\ifmmode\else\ttfamily\fi% - \ebnf@color{gray}{"}#1\ebnf@color{gray}{"}} + \ebnf@color{gray}{\relax\ifmmode\textsf{``}\else{\sffamily``}\fi}% + #1% + \ebnf@color{gray}{\relax\ifmmode\textsf{''}\else{\sffamily''}\fi}}} \makeatother % \end{macrocode} % \end{macro} @@ -202,8 +220,10 @@ % Then, we a command to render a single non-terminal: % \begin{macrocode} \makeatletter -\newcommand\nonterminal[1] - {\(\ebnf@color{gray}{\langle}\textsf{#1}\ebnf@color{gray}{\rangle}\)} +\newcommand\nonterminal[1]{% + \ebnf@color{gray}{\relax\ifmmode\langle\else\(\langle\)\fi}% + \relax\ifmmode\textsf{#1}\else{\sffamily#1}\fi% + \ebnf@color{gray}{\relax\ifmmode\rangle\else\(\rangle\)\fi}} \makeatother % \end{macrocode} % \end{macro} diff --git a/macros/latex/contrib/naive-ebnf/naive-ebnf.pdf b/macros/latex/contrib/naive-ebnf/naive-ebnf.pdf index fdf6d14f90..cfb0270b4c 100644 Binary files a/macros/latex/contrib/naive-ebnf/naive-ebnf.pdf and b/macros/latex/contrib/naive-ebnf/naive-ebnf.pdf differ -- cgit v1.2.3