summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-03-06 22:10:33 +0000
committerKarl Berry <karl@freefriends.org>2014-03-06 22:10:33 +0000
commit3731208d7fb52ead680b0a31cae7e086b536a97b (patch)
tree3e639885dc67904ab8a3867ec9b17a7ebeae3705
parentdce368d510dc3ccdacfd71146a8fbd05bb74f82d (diff)
numberedblock (6mar14)
git-svn-id: svn://tug.org/texlive/trunk@33109 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/numberedblock/testnumberedblock.pdfbin35138 -> 75098 bytes
-rw-r--r--Master/texmf-dist/doc/latex/numberedblock/testnumberedblock.tex24
-rw-r--r--Master/texmf-dist/tex/latex/numberedblock/numberedblock.sty34
3 files changed, 42 insertions, 16 deletions
diff --git a/Master/texmf-dist/doc/latex/numberedblock/testnumberedblock.pdf b/Master/texmf-dist/doc/latex/numberedblock/testnumberedblock.pdf
index cdfd2713b3f..2a4066df62f 100644
--- a/Master/texmf-dist/doc/latex/numberedblock/testnumberedblock.pdf
+++ b/Master/texmf-dist/doc/latex/numberedblock/testnumberedblock.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/numberedblock/testnumberedblock.tex b/Master/texmf-dist/doc/latex/numberedblock/testnumberedblock.tex
index b12dc3c6725..0e66a6a2628 100644
--- a/Master/texmf-dist/doc/latex/numberedblock/testnumberedblock.tex
+++ b/Master/texmf-dist/doc/latex/numberedblock/testnumberedblock.tex
@@ -1,11 +1,11 @@
\documentclass[10pt]{article}
\usepackage{numberedblock}
-
+\textheight 7.7in
\begin{document}
-
-\parindent 0.3in
+%DEFAULTS:
%\setlength\maxblocklabelsize{-.4in}
-\setlength\blockindent{0.0in}
+%\setlength\blockindent{0.2in}
+%\renewcommand\blocklabel[1]{[\textit{\arabic{#1}}]}
This is a test of the \textsf{numberedblock} style packcage, which is
specially designed to produce sequentially numbered BLOCKS of code (note
@@ -15,20 +15,21 @@ can get numbered in a document). While specialized for numbering code
blocks, the commands can actually number other items, as well, in fact
anything that fits in a \LaTeX{} box.
-If the code block contains no special characters, one can simply use the
+If the code block contains no special characters
+(or is already a box), one can simply use the
command form, called \verb,\numblock,. It cannot handle verbatim text,
but must use standard \LaTeX{} escape sequences (for line breaks,
contiguous spaces, special characters, etc.). It puts the output in a
-tt font , which is the same used in the verbatim environment:
+tt font, which is the same as used in the verbatim environment:
\numblock{This text is the\\argument to the command\\where double
-slashes have been\\used for line breaks}
+slashes have been\\used for line breaks\nblabel{nb:A}}
Most useful, however, there is also the \verb,numVblock, environment,
which handles verbatim text, as seen in the next example:
-\begin{numVblock}
-This is the numVblock
+\begin{numVblock}[\nbVlabel{nb:B}]
+This is a labeled numVblock
environment, which (<--see contiguous spaces here)
succeeds in
incorporating verbatim text like
@@ -36,7 +37,9 @@ incorporating verbatim text like
\end{numVblock}
As envisioned the \verb,numVblock, environment would be ideally suited
-for displaying small code blocks as part of documentation. The code can
+for displaying small code blocks as part of documentation, and I can
+{\bfseries (NEW!!)} even reference
+the numbered blocks~\ref{nb:A} and \ref{nb:B}. The code can
contain contiguous spaces and special characters:
\begin{numVblock}
@@ -60,5 +63,4 @@ box, rather than as formatted text.
Don't forget, there are settable parameters to define the block
left-indent, the format of the label, and (if needed) the labels' max
width/placement.
-
\end{document}
diff --git a/Master/texmf-dist/tex/latex/numberedblock/numberedblock.sty b/Master/texmf-dist/tex/latex/numberedblock/numberedblock.sty
index b093da67942..1c2cf01cd9a 100644
--- a/Master/texmf-dist/tex/latex/numberedblock/numberedblock.sty
+++ b/Master/texmf-dist/tex/latex/numberedblock/numberedblock.sty
@@ -1,6 +1,14 @@
-\ProvidesPackage {numberedblock} [2007/03/16 v1.01]
+\ProvidesPackage {numberedblock} [2014/02/24 v1.10]
%
-% by Steven B. Segletes, for the public domain.
+% by Steven B. Segletes
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
%
% numberedblock provides several routines
% intended to print out a block of code with a unique,
@@ -33,11 +41,15 @@
% addition, special LaTeX characters need to be quoted in the
% appropriate manner of LaTeX.
%
-% \numblock{Line 1 of code\\Line 2 of code\\Line 3...}
+% \numblock{Line 1 of code\\Line 2 of code\\Line 3...\nblabel{mylabel}}
+%
+% A label may set to the code block with \nblabel{}.
%
-% In contrast, the numVblock environment is a verbatim environment:
+% In contrast, the numVblock environment is a verbatim environment.
+% A label may be passed to numVblock through an optional argument, via
+% \nbVlabel{}.
%
-% \begin{numVblock}{
+% \begin{numVblock}[\nbVlabel{mylabel}]
% program test
% implicit none
% integer a, x
@@ -53,11 +65,23 @@
% of fixed-width characters. The counter named blocknum is used to
% index the code block sequence.
%
+% V1.1 - Added the hyperref-compatible capability to label and
+% reference numbered blocks.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\@ifundefined{verbatim@processline}{\RequirePackage{verbatim}}{}
\usepackage{verbatimbox}
+%%%%% LABELING CAPABILITY
+% See: http://tex.stackexchange.com/questions/160466/
+% how-can-one-refer-to-a-part-of-an-equation
+\AtBeginDocument{\let\nb@label\label}
+\newcounter{nb@counter}
+\newcommand{\nblabel}[1]{\def\@currentlabel{\theblocknum}\nb@label{#1}}
+\newcommand{\nbVlabel}[1]{\setcounter{nb@counter}{\theblocknum}\stepcounter{nb@counter}%
+ \def\@currentlabel{\thenb@counter}\nb@label{#1}}
+%%%%%
+
\newsavebox{\@savedverbbox}
\newlength\maxblocklabelsize
\newlength\blockindent