diff options
Diffstat (limited to 'macros/latex/contrib/ffcode/ffcode.dtx')
-rw-r--r-- | macros/latex/contrib/ffcode/ffcode.dtx | 201 |
1 files changed, 63 insertions, 138 deletions
diff --git a/macros/latex/contrib/ffcode/ffcode.dtx b/macros/latex/contrib/ffcode/ffcode.dtx index c6d717c7b5..e3c430c8de 100644 --- a/macros/latex/contrib/ffcode/ffcode.dtx +++ b/macros/latex/contrib/ffcode/ffcode.dtx @@ -50,18 +50,20 @@ %<package>\NeedsTeXFormat{LaTeX2e} %<package>\ProvidesPackage{ffcode} %<*package> -[03.10.2022 0.5.0 Fixed Font Code] +[2022-10-30 0.5.1 Fixed Font Code] %</package> %<*driver> \documentclass{ltxdoc} \usepackage[T1]{fontenc} \usepackage[tt=false,type1=true]{libertine} \usepackage{microtype} +\AddToHook{env/verbatim/begin}{\microtypesetup{protrusion=false}} \usepackage{href-ul} \usepackage{ffcode} \usepackage{amsmath} \usepackage{multicol} \usepackage{xcolor} +\usepackage[dtx,runs=2]{docshots} \PageIndex \EnableCrossrefs \CodelineIndex @@ -86,86 +88,51 @@ % and make sure it looks nice. Install it from CTAN and then % use like this (pay attention to |\ff| command % and |ffcode| environment): -% \begin{multicols}{2} -% \setlength{\parskip}{0pt} -% \raggedcolumns -%\iffalse -%<*verb> -%\fi -\begin{verbatim} -\documentclass{article} -\usepackage{ffcode} -\begin{document} -The function \ff{fibo()} -is recursive: -\begin{ffcode} -int fibo(int n) { - if (n < 2) { - return n; |$\label{ln:ret}$| - } - return fibo(n-1)+fibo(n-2); -} -\end{ffcode} -The line no.~\ref{ln:ret} -terminates it. -\end{document} -\end{verbatim} -%\iffalse -%</verb> -%\fi -% -% \columnbreak -% -% The function \ff{fibo()} is recursive: -% -%\iffalse -%<*verb> -%\fi -\begin{ffcode} -int fibo(int n) { - if (n < 2) { - return n; |$\label{ln:ret}$| - } - return fibo(n-1)+fibo(n-2); -} -\end{ffcode} -%\iffalse -%</verb> -%\fi -% -% The line no.~\ref{ln:ret} terminates it. -% \end{multicols} +% \begin{docshot} +% \documentclass{article} +% \usepackage{ffcode} +% \pagestyle{empty} +% \begin{document} +% The function \ff{fibo()} +% is recursive: +% \begin{ffcode} +% int fibo(int n) { +% if (n < 2) { +% return n; |$\label{ln:ret}$| +% } +% return fibo(n-1)+fibo(n-2); +% } +% \end{ffcode} +% The line no.~\ref{ln:ret} +% terminates it. +% \end{document} +% \end{docshot} % \section{Package Options} -% \begin{macro}{nopygments} +% \DescribeMacro{nopygments} % You have to run |pdflatex| with |--shell-escape| flag % in order to let |minted| (the package we use) to run Pygments % and format the code. If you don't want this to happen, % just use |nopygments| option. -% \end{macro} -% \begin{macro}{noframes} +% \DescribeMacro{noframes} % If you want to omit the light gray frames around |\ff| % texts, use the package option |noframes|. -% \end{macro} -% \begin{macro}{nobars} +% \DescribeMacro{nobars} % To omit the vertical gray bar at the left side of each snippet, % use |nobars| option of the package. -% \end{macro} -% \begin{macro}{nonumbers} +% \DescribeMacro{nonumbers} % To omit the line numbers, use |nonumbers| option of the package. -% \end{macro} -% \begin{macro}{nocn} +% \DescribeMacro{nocn} % By default, the numbering is continuous: line numbers start at the % first snippet and increment until the end of the document. If you % want them to start from one at each snippet, use |nocn| % (stands for ``no continuous numbering'') % option of the package. -% \end{macro} % \section{Typesetting} @@ -178,86 +145,40 @@ int fibo(int n) { % The command |\ff| behaves differently in math mode --- it doesn't % add gray frames: -% \begin{multicols}{2} -% \setlength{\parskip}{0pt} -% \raggedcolumns -%\iffalse -%<*verb> -%\fi -\begin{verbatim} -\documentclass{article} -\usepackage{ffcode} -\begin{document} -\begin{equation} -x = \int_\ff{home}^N f(x). -\end{equation} -\end{document} -\end{verbatim} -%\iffalse -%</verb> -%\fi -% -% \columnbreak -% -%\iffalse -%<*verb> -%\fi -% \begin{equation} +% \begin{docshot} +% \documentclass{article} +% \usepackage{ffcode} +% \usepackage{mathtools} +% \pagestyle{empty} +% \begin{document} +% \begin{equation*} % x = \int_\ff{home}^N f(x). -% \end{equation} -%\iffalse -%</verb> -%\fi -% \end{multicols} +% \end{equation*} +% \end{document} +% \end{docshot} % \section{Line Highlighting} % You can highlight some lines in your |ffcode| environment, % or can use any other additional configuration parameters from % |minted| package: - -% \begin{multicols}{2} -% \setlength{\parskip}{0pt} -% \raggedcolumns -%\iffalse -%<*verb> -%\fi -\begin{verbatim} -\documentclass{article} -\usepackage{ffcode} -\begin{document} -\begin{ffcode*} - {highlightlines={1,4-5}} -while (true) { - print("Hello!") - print("Enter your name:") - scan(x) - print("You name is " + x) -} -\end{ffcode*} -\end{document} -\end{verbatim} -%\iffalse -%</verb> -%\fi -% -% \columnbreak -% -%\iffalse -%<*verb> -%\fi -\begin{ffcode*}{highlightlines={7,10-11}} -while (true) { - print("Hello!") - print("Enter your name:") - scan(x) - print("You name is " + x) -} -\end{ffcode*} -%\iffalse -%</verb> -%\fi -% \end{multicols} +% \begin{docshot} +% \documentclass{article} +% \usepackage[paperwidth=3in]{geometry} +% \usepackage{ffcode} +% \pagestyle{empty} +% \begin{document} +% \begin{ffcode*} +% {highlightlines={1,4-5}} +% while (true) { +% print("Hello!") +% print("Enter your name:") +% scan(x) +% print("You name is " + x) +% } +% \end{ffcode*} +% \end{document} +% \end{docshot} % Using this second argument of |ffcode*| (with the trailing asterisk), % you can provide any other options from |minted| package to the @@ -266,8 +187,7 @@ while (true) { % \StopEventually{} % \section{Implementation} - -% \changes{v0.2.0}{2021/07/10}{Initial version} +% \changes{v0.1.0}{2021/06/10}{Initial version} % First, we parse package options: % \begin{macrocode} @@ -276,10 +196,14 @@ while (true) { \DeclareOptionX{nopygments}{\PassOptionsToPackage{draft=true}{minted}} \newif\ifff@noframes \DeclareOptionX{noframes}{\ff@noframestrue} +% \changes{v0.4.0}{2022/01/09}{Package option "nobars" added.} \newif\ifff@nobars \DeclareOptionX{nobars}{\ff@nobarstrue} +% \changes{v0.2.0}{2021/06/13}{Package options "nonumbers" +% and "noframes" added.} \newif\ifff@nonumbers \DeclareOptionX{nonumbers}{\ff@nonumberstrue} +% \changes{v0.3.0}{2021/09/07}{Package option "nocn" added.} \newif\ifff@nocn \DeclareOptionX{nocn}{\ff@nocntrue} \ProcessOptionsX\relax @@ -306,7 +230,7 @@ while (true) { framerule=1pt,rulecolor=gray,frame=leftline} \fi \else - \renewcommand{\theFancyVerbLine}{\textcolor{gray} + \renewcommand{\theFancyVerbLine}{\textcolor{gray}% {\tiny\oldstylenums{\ttfamily\arabic{FancyVerbLine}}}} \ifff@nocn \ifff@nobars @@ -337,10 +261,11 @@ while (true) { % \begin{macro}{\ff@print} % Then, we define supplementary commands |\ff@print| and |\ff@printx|: +% \changes{v0.5.1}{2022/10/30}{Now, the command "ff" ignores italic and bold and always prints "texttt" as it should be.} % \begin{macrocode} \makeatletter \newcommand\ff@print{\begingroup\obeyspaces\ff@printx} -\newcommand\ff@printx[1]{\texttt{#1}\endgroup} +\newcommand\ff@printx[1]{\textnormal{\texttt{#1}}\endgroup} \makeatother % \end{macrocode} % \end{macro} @@ -368,7 +293,7 @@ while (true) { \newcommand\ff[1]{\relax\ifmmode% {\ff@rule\ff@print{#1}}% \else% - {\ff@box{\ff@rule\ff@print{#1}}} + {\ff@box{\ff@rule\ff@print{#1}}}% \fi} \fi\makeatother % \end{macrocode} |