From d83f7d0c41e0dd7d39867577281bc4473963d1ee Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 1 Dec 2017 22:20:57 +0000 Subject: sasnrdisplay (1dec17) git-svn-id: svn://tug.org/texlive/trunk@45963 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/sasnrdisplay/README | 11 +- .../doc/latex/sasnrdisplay/SASnRdisplay.pdf | Bin 192028 -> 202937 bytes .../doc/latex/sasnrdisplay/SASnRdisplay.tex | 182 ++++++++++++++------- .../tex/latex/sasnrdisplay/SASnRdisplay.cfg | 4 +- .../tex/latex/sasnrdisplay/SASnRdisplay.sty | 62 ++++--- 5 files changed, 176 insertions(+), 83 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/sasnrdisplay/README b/Master/texmf-dist/doc/latex/sasnrdisplay/README index 43a15e8b86f..3415240e897 100644 --- a/Master/texmf-dist/doc/latex/sasnrdisplay/README +++ b/Master/texmf-dist/doc/latex/sasnrdisplay/README @@ -1,4 +1,4 @@ -% (C) Lars Madsen, daleif@imf.au.dk, 2012/10/10 +% (C) Lars Madsen, daleif@math.au.dk, 2017/12/01 % This material is subject to the LaTeX Project Public License. % See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html % for the details of that license. @@ -20,6 +20,13 @@ packages. HISTORY: +2017/12/01 + +* now requires a listings newer than 2015/06/04, so we have the R lang spec +* Added R lang calls to the base R style +* Added countbylistings option +* A few extra things added to the manual (utf8) + 2014/03/07 * bad test for \chapter, fix by using \ifundef instead @@ -38,4 +45,4 @@ HISTORY: /Lars Madsen -daleif@imf.au.dk +daleif@math.au.dk diff --git a/Master/texmf-dist/doc/latex/sasnrdisplay/SASnRdisplay.pdf b/Master/texmf-dist/doc/latex/sasnrdisplay/SASnRdisplay.pdf index fec356366b7..ebc1b9aa47b 100644 Binary files a/Master/texmf-dist/doc/latex/sasnrdisplay/SASnRdisplay.pdf and b/Master/texmf-dist/doc/latex/sasnrdisplay/SASnRdisplay.pdf differ diff --git a/Master/texmf-dist/doc/latex/sasnrdisplay/SASnRdisplay.tex b/Master/texmf-dist/doc/latex/sasnrdisplay/SASnRdisplay.tex index c317da93077..b51648e6dc8 100644 --- a/Master/texmf-dist/doc/latex/sasnrdisplay/SASnRdisplay.tex +++ b/Master/texmf-dist/doc/latex/sasnrdisplay/SASnRdisplay.tex @@ -1,6 +1,6 @@ -% $LastChangedDate: 2012-03-27 12:21:37 +0200 (Tue, 27 Mar 2012) $ -% $LastChangedRevision: 1479 $ -% $LastChangedBy: daleif $ +% $LastChangedDate: 2017-12-01 15:08:05 +0100 (Fri, 01 Dec 2017) $ +% $LastChangedRevision: 1923 $ +% $LastChangedBy: daleif@math.au.dk $ \documentclass[a4paper,article]{memoir} @@ -33,7 +33,8 @@ \newcommand\pkg{\texttt{SASnRdisplay}\xspace} -%\setsecnumdepth{none} +\setsecnumdepth{subsection} +\settocdepth{subsection} \setsecheadstyle{\large\slshape\bfseries\memRTLraggedright} \usepackage[svgnames,dvipsnames]{xcolor} @@ -118,22 +119,48 @@ noneedspace \newenvironment{question}[1]{ \subsubsection*{\textnormal{\textit{\color{BrickRed}#1}}} \phantomsection - \addcontentsline{toc}{subsection}{#1} + \addcontentsline{toc}{subsubsection}{#1} }{} \lstnewenvironment{solution}[1][]{ \lstset{style=Show,gobble=2,columns=fixed,#1} }{} -\usepackage{hyperref} +\usepackage[ +colorlinks, +breaklinks, +plainpages=false, +pdfpagelabels, +pdfencoding = auto, +bookmarksnumbered, +unicode, +]{hyperref} + + +\title{The \textsf{SASnRdisplay} package} +\author{Lars Madsen\thanks{Email: daleif@math.au.dk, \SnRversion}} + +\definecolor{linkcolour}{rgb}{0,0.2,0.6} +\definecolor{citecolour}{rgb}{0,0.6,0.2} +\definecolor{urlcolour} {rgb}{0.8,0,0.8} + + +\hypersetup{ + pdftitle={The \textsf{SASnRdisplay} package}, + pdfauthor={\copyright\ Lars Madsen 2017}, + linkcolor=linkcolour, + citecolor=citecolour, + filecolor=urlcolour, + urlcolor=urlcolour, +} + + \settocdepth{subsection} \pagestyle{plain} \begin{document} -\title{The \textsf{SASnRdisplay} package} -\author{Lars Madsen\thanks{Email: daleif@imf.au.dk,\SnRversion}} \maketitle \chapter*{Introdution} @@ -264,6 +291,10 @@ Available options: \item[consecutive] Use this if you just want consecutive numbering throughout, that is the number of say \SAS code, is not reset at every new chapter or section. +\item[countbylistings] Here we will leave the counters alone and just + use the one that comes with \texttt{listings}. This (of course) + disables \texttt{countbysection}, \texttt{countbychapter} and + \texttt{consecutive}. \item[noautotitles-r, noautotitles-sas] Do not automatically add a number to any of the code and outputs. It can still be added manually by using the \texttt{caption=\marg{text}} option. @@ -357,7 +388,7 @@ of either overwriting one of these pieces or override a special user style which is executed as the last style (and thus overwrites any former style). -The settings can be seen in section~\ref{cha:defa-list-style}. The +The settings can be seen in Section~\ref{cha:defa-list-style}. The styles are broken into smaller pieces. In some cases it make sense to change one of these smaller pieces, in other cases it is easier to add stuff to the provided \texttt{\meta{name}-\meta{type}-user} @@ -374,7 +405,29 @@ possible to add to a \texttt{listings} style. Thus you will have to add all your setting for, say, \texttt{r-user}, into one single call to \cs{lstdefinestyle}. -\subsection*{Colors} + +\subsection{Font} + +\begin{question}{I'd like to change the font size} + The gereral fontsize (not comments) is handled by the keyword + \texttt{basicstyle}, so you can change the font size for SAS code + in two ways, + \begin{solution} + \lstdefinestyle{sas-code-user}{ + basicstyle=\ttfamily\footnotesize + } + \end{solution} + or by overwriting the default SAS code font setting: + \begin{solution} + \lstdefinestyle{sas-code-fonts}{ + basicstyle = \ttfamily\small, + } + \end{solution} +\end{question} + + + +\subsection{Colors} \label{sec:colors} The default colors are \texttt{SnRFrame} \showcolor{SnRFrame} for the @@ -436,7 +489,7 @@ to \texttt{SnRFrameGray} \showcolor{SnRFrameGray} and \texttt{SnRBGGray} -\subsection*{Frames} +\subsection{Frames} \label{sec:frames} Listings supports a number of different types of frames, see the @@ -469,7 +522,7 @@ A user may want to experiment with the keys \endgroup -\subsection*{Captions} +\subsection{Captions} \label{sec:captions-1} This is not a configuration as such but rather a hint to how one adds @@ -538,7 +591,7 @@ Note that numbered construction without a caption are typeset as \end{question} -\subsection*{Keywords} +\subsection{Keywords} \label{sec:keywords} \begin{question}{In a presentaion, I'd like to highlight a word} @@ -587,7 +640,7 @@ Note that numbered construction without a caption are typeset as \end{question} -\subsection*{Escape to \LaTeX} +\subsection{Escape to \LaTeX} \label{sec:escape-latex} This is a very handy feature and can e.g.\ be used to get formatted @@ -615,59 +668,68 @@ in the \meta{options} for the environment or the input macro. \fancybreak{} -The \texttt{listings} manual, \cite[section~4.14]{listings} list other +The \texttt{listings} manual, \cite[Section~4.14]{listings} list other features related to escaping back to normal \LaTeX\ formatting. -\subsection*{Input encodings} +\subsection{Input encodings (e.g. UTF8)} \label{sec:input-encodings} \begin{question}{I keep getting errors when I include my program, something about undefined chars!?} - There are two things at play here: firstly \texttt{listings} does - not support two-byte UTF8 (\texttt{listings} need to do a lot of - parsing, that and parsing may break when dealing with two-byte - UTF8), secondly one may have a situation where the main document - encoding is different from the encoding being used in code filers - being included. - - Let us try and handle the later first. We assume you are using the - \texttt{inputenc} package. Then one can specify that, say, all code - should be interpreted with, say, the \texttt{latin1} encoding. Here - is how for included \SAS code: - \begin{solution} - \lstdefinestyle{sas-include-code-user}{ - inputencoding=latin1 - } - \end{solution} + The problem here is that \texttt{listings} cannot cope with so-called two two-byte characters, + \texttt{listings} needs to do a lot of parsing which may break when dealing with e.g. two-byte + UTF8 chars (essentially all non-acsii chars). + + At the moment, no-one have made a UTF8 compatible version of \texttt{listings}, so we need to cope + somehow. + + We will be assuming you are working with UTF8 files (both on the LaTeX side, and any including + source code), UTF8 is recommended nowadays, so we will ignore working purely in latin1 (which + \texttt{listings} has no issues with at all). \fancybreak{} - The other situation, i.e.\ the included\footnote{The solution is - only available for included files.} file is written in UTF8. Here - a solution exist if the two-byte UTF8 file, can safely be - transformed into a one-byte encoding such as \texttt{latin1}. And - example of this could be the situation with an \R file, written in - UTF8, including the Danish vowels æøå, but other that those only US - ascii is being used. A file like this can easily be recoded as a - \texttt{latin1} based file. - - There is a package (\texttt{listingsutf8}) can than handle this. It - extends the file inclusion feature and extend the input encoding - syntax. In the case described above, adding \texttt{listingsutf8} to - your preamble, and using + First scenario: Assuming all your \texttt{listings} presented material comes from external + sources, e.g. they are inputted, and assuming your UTF8 sources code is compatible with the latin1 + encoding (aka Western European languages), then you can simply additionally use the package + \texttt{listingsutf8}. It extends the file inclusion feature and extend the input encoding + syntax. Add \texttt{listingsutf8} to your preamble, and using \begin{solution} \lstdefinestyle{r-include-code-user}{ inputencoding=utf8/latin1 } \end{solution} - may solve the problem. See \cite{listingsutf8} for a bit more details. + will attempt to auto convert the included code into latin1 before handing it off to + \texttt{listings}. See \cite{listingsutf8} for a bit more details. + + \fancybreak{} + + Another solution, which works very well is using the the \texttt{literate} option. The value of + this key is read in triples, and is basically saying, if you see this char, typeset this + instead. Here is an example with the Danish æøå: + \begin{solution} + \lstdefinestyle{r-code-user}{ + literate={æ}{\ae}1% + {Æ}{\AE}1% + {ø}{\o}1% + {Ø}{\O}1% + {å}{\aa}1% + {Å}{\AA}1,% + } + \end{solution} + (add the comma after the last one). There are several examples on + \url{http://tex.stackexchange.com} if you search for + ``\texttt{listings literate}''. + + As for the syntax of the triple: \marg{input}\marg{typeset output}\marg{length}. + \end{question} -\subsection*{Other} +\subsection{Other} \label{sec:other} \begin{question}{I'd like to have line numbers} @@ -804,9 +866,9 @@ QUIT; /* a standard SAS comment */ whereas \begin{SASoutput} - TABLE OF NIVEAU BY FAG + TABLE OF NIVEAU BY SUBJECT - NIVEAU FAG + NIVEAU SUBJECT Frequency| Percent | @@ -836,9 +898,9 @@ whereas comes from \begin{Show} \begin{SASoutput} - TABLE OF NIVEAU BY FAG + TABLE OF NIVEAU BY SUBJECT - NIVEAU FAG + NIVEAU SUBJECT Frequency| Percent | @@ -938,6 +1000,8 @@ then one will get the \texttt{basicstyle} plus bold face (if possible) for things that are emphasized. \getsniplet{rcharsandbreaks}{\texttt{r-chars-and-breaks}} \getsniplet{rmarkup}{\texttt{r-markup}} +\R lang setting was added 2017/12/01 and requires a \texttt{listings} +newer from 2015 or later. \getsniplet{rframe}{\texttt{r-frame}} \getsniplet{rcolors}{\texttt{r-colors}} \noindent @@ -951,6 +1015,10 @@ being black by default. Note that by default, the inline style for \verb|\Rinline|, shares nothing with the rest of the \R configuration and is loaded on its own. +\R lang setting was added 2017/12/01 and requires a \texttt{listings} +newer from 2015 or later. + + \subsection{\R user styles} \label{sec:user-styles} @@ -1050,7 +1118,7 @@ input encoding for, say, all included code files. -\subsection*{Extra SAS keywords} +\subsection{Extra SAS keywords} \label{sec:extra-sas-keywords} Jørgen Granfeldt supplied extra \SAS keywords to supplement those @@ -1073,20 +1141,20 @@ Here is the current list. \begin{thebibliography}{9} \RaggedRight \bibitem{xcolor} Uwe Kern, \emph{Extending \LaTeX's color facilities: - the \textsf{xcolor} package}, 2006. + the \textsf{xcolor} package}, 2016. \addCTAN{/macros/latex/contrib/xcolor/}. \bibitem{listings} Various, \emph{The \textsf{listings} Package}, - 1996--2007. \addCTAN{/macros/latex/contrib/listings/}. + 1996--2015. \addCTAN{/macros/latex/contrib/listings/}. \bibitem{etoolbox} - Philipp Lehman, + Philipp Lehman, Joseph Wright, \emph{The etoolbox Package -- An e-TeX Toolbox for Class and Package - Authors}, 2011. \addCTAN{/macros/latex/contrib/listings/etoolbox}. + Authors}, 2017. \addCTAN{/macros/latex/contrib/listings/etoolbox}. \bibitem{listingsutf8} - Heiko Oberdiek, \emph{The \textsf{listingsutf8} package}, 2007. + Heiko Oberdiek, \emph{The \textsf{listingsutf8} package}, 2016. \addCTAN{/macros/latex/contrib/oberdiek/}. \bibitem{caption} Axel Sommerfelt, \emph{Customizing captions of diff --git a/Master/texmf-dist/tex/latex/sasnrdisplay/SASnRdisplay.cfg b/Master/texmf-dist/tex/latex/sasnrdisplay/SASnRdisplay.cfg index 8bf14571ee0..3749c8f3a15 100644 --- a/Master/texmf-dist/tex/latex/sasnrdisplay/SASnRdisplay.cfg +++ b/Master/texmf-dist/tex/latex/sasnrdisplay/SASnRdisplay.cfg @@ -10,8 +10,8 @@ %% %% This work has the LPPL maintenance status "maintained". %% -%% The Current Maintainer of this work is Lars Madsen (daleif@imf.au.dk) -%% Data supplied by J\o rgen Granfeldt (jqrgen@imf.au.dk) +%% The Current Maintainer of this work is Lars Madsen (daleif@math.au.dk) +%% Data supplied by J\o rgen Granfeldt (jqrgen@math.au.dk) %% % how to use: % diff --git a/Master/texmf-dist/tex/latex/sasnrdisplay/SASnRdisplay.sty b/Master/texmf-dist/tex/latex/sasnrdisplay/SASnRdisplay.sty index 7fd8d1bc48b..d3a26dab11a 100644 --- a/Master/texmf-dist/tex/latex/sasnrdisplay/SASnRdisplay.sty +++ b/Master/texmf-dist/tex/latex/sasnrdisplay/SASnRdisplay.sty @@ -1,10 +1,10 @@ -\ProvidesPackage{SASnRdisplay}[2014/03/07 v0.93 by daleif] +\ProvidesPackage{SASnRdisplay}[2017/12/01 v0.95 by daleif] -\newcommand\SnRversion{v0.93 2014/03/07} +\newcommand\SnRversion{v0.95 2017/12/01} -%% $LastChangedDate: 2012-10-15 16:01:29 +0200 (Mon, 15 Oct 2012) $ -%% $LastChangedRevision: 1552 $ -%% $LastChangedBy: daleif $ +%% $LastChangedDate: 2017-12-01 15:09:40 +0100 (Fri, 01 Dec 2017) $ +%% $LastChangedRevision: 1924 $ +%% $LastChangedBy: daleif@math.au.dk $ %% %% This package can be distributed and/or modified under the @@ -17,12 +17,12 @@ %% %% This work has the LPPL maintenance status "maintained". %% -%% The Current Maintainer of this work is Lars Madsen (daleif@imf.au.dk). +%% The Current Maintainer of this work is Lars Madsen (daleif@math.au.dk). %% -\RequirePackage{listings} +\RequirePackage{listings}[2015/06/04] \RequirePackage{xkeyval,xcolor,etoolbox,caption,needspace} @@ -100,6 +100,7 @@ \newtoggle{SnRcountbysection} \newtoggle{SnRcountbychapter} \newtoggle{SnRcountconsecutive} +\newtoggle{SnRcountbylistings} \DeclareOptionX{consecutive}{\toggletrue{SnRcountconsecutive}} \DeclareOptionX{countbysection}{\toggletrue{SnRcountbysection}} \DeclareOptionX{countbychapter}{% @@ -111,6 +112,12 @@ } } + +% added 2017/12/01 in response to +% https://tex.stackexchange.com/q/181110/3929 +\DeclareOptionX{countbylistings}{\toggletrue{SnRcountbylistings}} + + \let\SnRneedspaceCommand\@gobble \newlength\SnRneedspace \let\SnRneedspaceSAScode \SnRneedspace @@ -225,26 +232,33 @@ \dolistloop\SnRtypes } +% added 2017/12/01, if option given, then don't create or mess with counters +\iftoggle{SnRcountbylistings}{}{ -\iftoggle{SnRcountconsecutive}{ - \SnRsetupcounters{}% no dominant counter -}{ - \iftoggle{SnRcountbysection}{ - \SnRsetupcounters{section} - }{ % must be after chapter - \SnRsetupcounters{chapter} + \iftoggle{SnRcountconsecutive}{ + \SnRsetupcounters{}% no dominant counter + }{ + \iftoggle{SnRcountbysection}{ + \SnRsetupcounters{section} + }{ % must be after chapter + \SnRsetupcounters{chapter} + } } -} +} % This is inspired from the memoir class, it enables us to alias the % listings counter such that we can have different series % It will locally make one counter behave like another counter % it also handles the \the -\newcommand*{\SnRletcountercounter}[2]{% - \csletcs{c@#1}{c@#2} - \csletcs{the#1}{the#2} - \SnRHrefNumber{#2} +\iftoggle{SnRcountbylistings}{ + \let\SnRletcountercounter\@gobbletwo +}{ + \newcommand*{\SnRletcountercounter}[2]{% + \csletcs{c@#1}{c@#2} + \csletcs{the#1}{the#2} + \SnRHrefNumber{#2} + } } @@ -345,7 +359,8 @@ % this is for basic configuration of the inline version % rinline \lstdefinestyle{r-inline}{ - basicstyle = \ttfamily + basicstyle = \ttfamily, + language = R, % R lang added 2017/12/01 } % end rinline % Spaces above and after, plus caption and internal lineskip (note @@ -380,9 +395,12 @@ extendedchars = true, % special chars allowed, be aware of utf8 } % end rcharsandbreaks + + %morecomment = [s]{\#}{\^^M}, % comment from # to the end of the line + % rmarkup -\lstdefinestyle{r-markup}{ % this only make sense for code - morecomment = [s]{\#}{\^^M}, % comment from # to the end of the line +\lstdefinestyle{r-markup}{ % this only make sense for code + language = R, % R lang added 2017/12/01 commentstyle = \normalfont\slshape\ttfamily\footnotesize, } % end rmarkup -- cgit v1.2.3