As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


TeX and LaTeX

From sasCommunity
Jump to: navigation, search

Known LaTeX users in the SAS community

What is it about LaTeX?

http://www.latex-project.org/

  • MyPaper.tex is a text file
  • contains mark-up language, similar to html or xml
  • edit with any text editor
  • output file is MyPaper.pdf, with live links
  • can copy all or part of one or more MyProgram.sas files
  • references or bibliography are easy

Where do I get the software?

Which DocumentClass?

http://www.infomap.com/

RefArt Kludge for SUGconf

This style file redefines the LaTeX maketitle command to produce a paper-number + title + author which conforms to SAS User Group conference paper guidelines.

%% name: C:\SASpapers\00refart\refart-sugconf.sty
%% RJF2 11/23/2007 9:00AM
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{refart-sugconf}[11/23/2007]
\let\@papernumber\relax%
\newcommand{\sugconfpapernumber}[1]{\def\@papernumber{#1}}
\renewcommand{\maketitle}{
\maxipagerulefalse%refart
\begin{maxipage}%
   \begin{center}%
      \if\@papernumber\relax\else%
      \fontsize{10}{18}\selectfont{\bf\@papernumber\\}\medskip
      \fi%
      \fontsize{14}{18}\selectfont{\bf\@title      \\}\smallskip
      \fontsize{12}{14}\selectfont{   \@author       }
      \end{center}%
   \end{maxipage}%
\maxipageruletrue%refart
}%end maketitle
\renewcommand{\rmdefault}{phv}%Adobe Helvetica san-serif
%\renewcommand{\rmdefault}{pnc}%Adobe Ncntrsbk       serif
%\renewcommand{\rmdefault}{ppl}%Adobe Palatino      serif
%\renewcommand{\rmdefault}{put}%Adobe Utopia        serif
%\renewcommand{\rmdefault}{ptm}%Adobe Times         serif
\renewcommand{\sfdefault}{phv}%Helvetica
\renewcommand{\ttdefault}{pcr}%Courier          monospace
\endinput

RefArt and RefArt-SUGconf example

%% name: D:\SASpapers-archive\00refart\refart-test.tex
%% RJF2 3/22/2007 8:10AM
%\documentclass[10pt,smallborder]{refart}%*-margins=0.25 in, for screen viewing only
\documentclass[10pt]{refart}
\usepackage{refart-sugconf}
\pdfoutput=0%out=job.dvi
\pdfoutput=1%out=job.pdf
\sugconfpapernumber{draft \today}%
%\sugconfpapernumber{\relax}%SUG conference: no page numbers

\title {Demonstration of LaTeX for SAS User Group Conference Authors
       }%end title
\author{Ronald J. Fehd,
        Centers for Disease Control and Prevention, Atlanta, GA, USA
       }%end author
\usepackage[bookmarks   =false%SUG conf style guide
           ,pdfkeywords ={list of SUG conf Keywords goes here}%
           ,pdfsubject  ={SUG conf Subject different from title}%
           ,pdfstartview=FitBH%fit width of page to the window
           ,pdfusetitle%author and title
]{hyperref}
\begin{document}%
\pdfcompresslevel=9%best compression level for text and image
\maketitle

\section*{Abstract}
This is the abstract.

This is the pdfsubject: \makeatletter\@pdfsubject\makeatother

These are the pdfkeywords: \makeatletter\@pdfkeywords\makeatother


\section{Introduction}

This is a demonstration of VerbatimInput.

\VerbatimInput[firstline=1,lastline=8]{\jobname}

\renewcommand\FileNameExt{\jobname}
\VerbatimInput[firstline=9,lastline=17]{\FileNameExt}

\vfill
\hfill This is the last page of \jobname\ as of \today. %\time
\label{LastPage}\end{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput


Fehd posted a message to the texhax listserv with information about implementing the Information Mapping Block Label when using the RefArt class with a macro named marginparX.

How do I submit a document for processing?

See also: Batch_processing_under_Windows

rem      MyPaper.bat
pdfLaTeX MyPaper
rem 01-LaTeX-this.bat
call 03-set-filename
pdfLaTeX  %filename%
rem 02-TeXprocs-this.bat
call 03-set-filename
call   bibTeX  %filename%
call makeindex %filename%
call pdfLaTeX  %filename%
call pdfLaTeX  %filename%
call pdfLaTeX  %filename%
rem 03-set-filename.bat
set filename=Fehd-list-proc-routine-CallXinc
rem set filename=Fehd-list-proc-routine-CallXinc-slides

How do I add References?

http://www.bibtex.org/

Make a file: MyPaper.bib

The file MyPaper.bib is a lookup table for your citations.

%name: MyPaper.bib for MyPaper.tex see \bibliography{\jobname}
@inproceedings{sgf2007.113,
    booktitle={Proceedings of the SAS Global Forum},
    year     = 2007,
    author   ={Ronald J. Fehd and Art Carpenter},
    title    ={List Processing Basics: Creating and Using Lists of Macro Variables},
    note     ={Hands On Workshop, 20 pp.; comparison of methods:
              making and iterating macro arrays, scanning macro variable,
              writing calls to macro variable, write to file then include,
              call execute and nrstr;
              11 examples, bibliography},
    url      ={http://www2.sas.com/proceedings/forum2007/113-2007.pdf}}
@inproceedings{sas-wiki.making.utilities,
    booktitle={SAS Community Wiki},
    year     = 2008,
    author   ={Zeno, et alia},
    title    ={Utilities},
    note     ={category; miscellaneous parameterized include routines and subroutines},
    url      ={http://www.sascommunity.org/wiki/Category:Utility}}

Citations of Wikipedia

Make a file: MyPaper.tex

Use these commands to setup and reference your bibliography entries.

%preamble == setup
\bibliographystyle{plainnat}%provides full name
%\bibliographystyle{unsrtnat}%provides live url
\usepackage[numbers]{natbib}%usage: \citet{key} returns: NameLast [cite-#]
\usepackage[hyphens]{url}%allow line breaks in url
\newcommand{\CiteT}[2]{\citet[\href{#2}{#1}]{#1}}%end CiteT

%document
%references
Check this paper \citet{sgf2007.113}
or this one:      \cite{sgf2007.113}

List Processing Basics,
\CiteT{sgf2007.113}{http://www2.sas.com/proceedings/forum2007/113-2007.pdf}
demonstrate the timing of the error of using call execute of macros
without the macro function \%nrstr.

%listing of references
\nocite{*}%lists all entries in MyPaper.bib, whether cited or not
\renewcommand{\refname}{\subsection{Bibliography}}
\bibliography{\jobname}%generates thebib environment from \jobname.bib

Citations from multiple *.bib files

\bibliography{\jobname,sas-wiki}%multiple *.bib files separated by comma, NO SPACES

Packages

LaTeX has many helpful packages, add-ons, developed by its international user community.

Beamer

Darby and Fehd and Flom and Wilcox are using the beamer class to produce pdf that look and work like ppt.

http://latex-beamer.sourceforge.net/

Advantages:

  • frames can have overlays and (dis)appearing text
  • logo
  • navigation bar
  • page x of y
  • table of contents


Use this file as a template for your presentation:

Page X of Y in each slide, lower right corner.

%preamble
\title[Short Title%
      \hspace{8em} pg. \alert{\thepage}\ of \pageref{LastPage}%
      ]%short title in square brackets
      {Long, Verbose, Main Title}

You will have to adjust the amount of white space between "Short Title" and "pg. X of Y" by increasing the number of em spaces.

  • "Short Title" ... \hspace{3em} ... pg. X of Y
  • "Short Title" ... \hspace{8em} ... ... ... ... pg. X of Y

The last slide must have a label of LastPage.

\label{LastPage}%used in short title: of %\pageref{LastPage}%
\end{frame}
\end{document}
\endinput

Here is template for a frame with a program listing:

%preamble:
\newcommand{\FontSize}{large}
\begin{frame}[fragile]{Title}{Subtitle}
\begin{\FontSize}
PROC Print data   =  \alert{&Data.}
\pause
          (where  =        (&Where.));
\alt<3->
\begin{semiverbatim}
PROC Print data   =  &Data.
          (where  =        (&Where.));
           title2   "&Data..&Where. ";
run;
\end{semiverbatim}
\end{\FontSize}
%note in lower right corner
\vfill \hfill is.a subroutine: no calls
\end{frame}

You can use these commands within the semiverbatim environment.

  • \pause
  • \alert{text in red},
  • \alt<3-> shown from overlay three onward
  • \uncover<4->{text of overlay 4 to uncover in brackets}

Stacking the description environment with the \relax command.

\begin{frame}{Summary}{Magic}
   \begin{description}
      \item[Data Struc.] \relax
      \begin{itemize}
         \item \texttt{if 0 then set \&CxData.}
         \item \texttt{array Mvar(\alert{*}) character}
         \end{itemize}
      \item[Loop] \relax
      \begin{itemize}

         \item \texttt{do I = 1 to dim(Mvar) \alert{-2}}
         \end{itemize}
      \item[Process] \relax
      \begin{itemize}
         \item \texttt{Name  = vname(Mvar(I))}
         \item \texttt{Stmnt =  catx(' ' ,'\%let',Name,'=',Mvar(I)}
         \end{itemize}
      \end{description}
\label{lastPage}%used in short title: of %\pageref{lastPage}%
\end{frame}

BeamerPoster

BeamerPoster lets you use Beamer methods to create posters of any size. Peter Flom created a NESUG poster using BeamerPoster and TextPos.

FancyVerb

%preamble == setup
\newcommand\FileNameExt{FileName.ext}
%\newcommand\PathTo{../sas/}%SAS programs are in sibling directory

\usepackage{fancyvrb}%VerbatimInput
\usepackage{upquote}%use vertical quotes (') not left quote (`)
%http://tug.org/mailman/htdig/texhax/2008-January/009825.html
%FancyVerb SETtings changes defaults for MyPaper.tex == MyPaper.pdf
\fvset{fontsize=\relsize{-2}
      ,frame=single%none leftline topline bottomline lines single
%     ,frame=leftline%none leftline topline bottomline lines single
      ,firstline=1%integer
%     ,lastline=1%integer
%     ,firstnumber=last%auto:1 last integer
%     ,label=\FileNameExt%label={[top line]bottom line}
%     ,labelposition=%none topline bottomline all
      ,numbers=left%none left right
      ,numberblanklines=false
      }%end fvset
%document usage
This is a demonstration of VerbatimInput.

list MyPaper.tex

\VerbatimInput{\jobname}

list just the first 8 lines

\VerbatimInput[firstline=1,lastline=8]{\jobname}


\renewcommand\FileNameExt{MyPaper.tex}
Now the label is \FileNameExt

\VerbatimInput[firstline=9,lastline=17,label=continued]{\FileNameExt}

\renewcommand\FileNameExt{MyProgram.sas}
and that program: \FileNameExt

\VerbatimInput[label=\FileNameExt]{\PathTo\FileNameExt}

HyperRef

http://www.tug.org/applications/hyperref/ftp/doc/manual.html

The HyperRef Package must be loaded last, after all other packages, except minitoc, because it redefines LaTeX internal referencing commands.

\usepackage[bookmarks   =false%SUGI style guide
           ,pdfusetitle%author and title
           ,pdfstartview=FitBH%fit width of page to the window
]{hyperref}%
\begin{document}%
\pdfcompresslevel=9%best compression level for text and image
\maketitle
\section*{Abstract}
This is the abstract.

\section{Introduction}
\end{document}%

Listings

http://www.ctan.org/tex-archive/macros/latex/contrib/listings/

Listings lets you have code from various languages (including SAS) formatted nicely in LaTeX.

TextPos

http://nxg.me.uk/dist/textpos/

TextPos lets you place text exactly on a page, using either absolute or relative distances. This is especially useful for posters.

Recommendations

TexHax Listserv

Books

Comprehensive TeX Archive Network (CTAN)

Writing Discipline

  • Information Mapping

--macro maven == the radical programmer 11:00, 7 November 2008 (EST)


Related Links

Practical Tex Journal

See also: