3

I need to render an ASCII file for printing in a way that removes ambiguity if (very unlikely) one decides to type it in and validate the signatures.

Essentially, I need a monospace typesetter that would typeset a 'blank space' symbol for space, a CR/LF symbol (and proceed to the next line for readability) whenever a CR/LF is encountered, etc., making it obvious if there are any trailing whitespaces before the CR/LF, if there is a character present, etc.

Is there a font that already accomplishes that goal? *nix utility? TeX module/package/derived system?

Is this even the proper SE site for this kind of questions? Would you think I'd have better luck at SuperUser? StackOverflow?

  • the standard verbatim* environment does spaces (but not by default end of line) although could easily be added – David Carlisle Jun 3 '14 at 13:07
  • Have you considered the a2ps *nix utility. As far as I remember it is configurable to fulfill your needs. – user31729 Jun 3 '14 at 13:45
  • I've looked at a2ps - I haven't seen a good example on how that could be done - do you know of a good documentation for it? – qdot Jun 3 '14 at 14:28
5

Do you mean something like this? In this case, I made @ active to denote the end of the verbatim each line, so that it could both detect prior spaces, as well as typeset a <cr> to signify the end of line. (See ADDENDUM for update)

\documentclass{article}
\usepackage{verbatimbox}
\def\rlwd{.5pt}
\begin{document}
\catcode`@=\active
\def@{<cr>}
\def\tmp{\setbox2=\hbox{0}%
  \def\ {\makebox[\wd2]{\rule{\rlwd}{2pt}\rule{3pt}{\rlwd}\rule{\rlwd}{2pt}}}%
}
\begin{verbnobox}[\tmp]
This is a test         @
more test      @
The end@
\end{verbnobox}
\catcode`@=12
\end{document}

enter image description here

If one did not like the confusion of having the <cr> in the same font as the verbatim, one could alter it thus:

\documentclass{article}
\usepackage{verbatimbox,xcolor}
\def\rlwd{.5pt}
\begin{document}
\catcode`@=\active
\def@{\textcolor{red}{{\tiny\rmfamily\bfseries$<$cr$>$}}}
\def\tmp{\setbox2=\hbox{0}%
  \def\ {\makebox[\wd2]{\rule{\rlwd}{2pt}\rule{3pt}{\rlwd}\rule{\rlwd}{2pt}}}%
}
\begin{verbnobox}[\tmp]
This is a test         @
more test      @
The end@
\end{verbnobox}
\catcode`@=12
\end{document}

enter image description here

ADDENDUM

Since this answer was originally provided I have learned that verbatim environment and even the \verb macro have star variants (e.g., verbatim*) which provide the visible space glyph. Thus, no extra packages are actually needed.

\documentclass{article}
\begin{document}
\catcode`@=\active
\def@{<cr>}
\begin{verbatim*}
This is a test         @
more test      @
The end@
\end{verbatim*}
\catcode`@=12
\end{document}

enter image description here

1

Some modification to fancyvrb allows you to reformat the end-of-line character (below I've used \CR):

enter image description here

\documentclass{article}
\usepackage{fancyvrb}
\newcommand{\CR}{<cr>}

\makeatletter

\begingroup
\catcode`\^^M=\active
\gdef\FancyVerbGetLine#1^^M{%
  \@nil%
  \FV@CheckEnd{#1}%
  \ifx\@tempa\FV@EnvironName%            % True if end is found
    \ifx\@tempb\FV@@@CheckEnd\else\FV@BadEndError\fi%
    \let\next\FV@EndScanning%
  \else%
    \def\FV@Line{#1\CR}%
    \def\next{\FV@PreProcessLine\FV@GetLine}%
  \fi%
  \next}%
\endgroup

\makeatother

\begin{document}

\begin{Verbatim}[showspaces=true]
This is a test         @
more test      @
The end@
\end{Verbatim}

\end{document}

The definition of \FancyVerbGetLine was taken directly from fancyvrb.dtx and modified to insert \CR as part of the definition of \FV@line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.