| 1 |
\documentclass[10pt]{article} |
| 2 |
\usepackage{numberedblock} |
| 3 |
\textheight 7.7in |
| 4 |
\begin{document} |
| 5 |
%DEFAULTS: |
| 6 |
%\setlength\maxblocklabelsize{-.4in} |
| 7 |
%\setlength\blockindent{0.2in} |
| 8 |
%\renewcommand\blocklabel[1]{[\textit{\arabic{#1}}]} |
| 9 |
|
| 10 |
This is a test of the \textsf{numberedblock} style packcage, which is |
| 11 |
specially designed to produce sequentially numbered BLOCKS of code (note |
| 12 |
the individual code lines are not numbered, but the whole block gets a |
| 13 |
single number, for later reference (much in the same way that equations |
| 14 |
can get numbered in a document). While specialized for numbering code |
| 15 |
blocks, the commands can actually number other items, as well, in fact |
| 16 |
anything that fits in a \LaTeX{} box. |
| 17 |
|
| 18 |
If the code block contains no special characters |
| 19 |
(or is already a box), one can simply use the |
| 20 |
command form, called \verb,\numblock,. It cannot handle verbatim text, |
| 21 |
but must use standard \LaTeX{} escape sequences (for line breaks, |
| 22 |
contiguous spaces, special characters, etc.). It puts the output in a |
| 23 |
tt font, which is the same as used in the verbatim environment: |
| 24 |
|
| 25 |
\numblock{This text is the\\argument to the command\\where double |
| 26 |
slashes have been\\used for line breaks\nblabel{nb:A}} |
| 27 |
|
| 28 |
Most useful, however, there is also the \verb,numVblock, environment, |
| 29 |
which handles verbatim text, as seen in the next example: |
| 30 |
|
| 31 |
\begin{numVblock}[\nbVlabel{nb:B}] |
| 32 |
This is a labeled numVblock |
| 33 |
environment, which (<--see contiguous spaces here) |
| 34 |
succeeds in |
| 35 |
incorporating verbatim text like |
| 36 |
@##$%*$%$()||}{?><\\\ |
| 37 |
\end{numVblock} |
| 38 |
|
| 39 |
As envisioned the \verb,numVblock, environment would be ideally suited |
| 40 |
for displaying small code blocks as part of documentation, and I can |
| 41 |
{\bfseries (NEW!!)} even reference |
| 42 |
the numbered blocks~\ref{nb:A} and \ref{nb:B}. The code can |
| 43 |
contain contiguous spaces and special characters: |
| 44 |
|
| 45 |
\begin{numVblock} |
| 46 |
program test |
| 47 |
implicit none |
| 48 |
integer a, x |
| 49 |
c$$$$$$$$$$$$$$$$$$$$$$$$$ |
| 50 |
a = 0 |
| 51 |
x = 1 |
| 52 |
10 a = a + x |
| 53 |
if (a .eq. 100) stop |
| 54 |
goto 10 |
| 55 |
end |
| 56 |
\end{numVblock} |
| 57 |
|
| 58 |
Below, I test the \verb,\numblock, command with the argument as a |
| 59 |
box, rather than as formatted text. |
| 60 |
|
| 61 |
\numblock{\fbox{Testing, 1,2,3 testing a box}} |
| 62 |
|
| 63 |
Don't forget, there are settable parameters to define the block |
| 64 |
left-indent, the format of the label, and (if needed) the labels' max |
| 65 |
width/placement. |
| 66 |
\end{document} |