diff options
author | Karl Berry <karl@freefriends.org> | 2013-03-10 22:33:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-03-10 22:33:09 +0000 |
commit | 24c665a0318bee395de0d1f35c1174119174e644 (patch) | |
tree | 74065e6feabfdb8ef54b0b78ba1dd576dcaa4c57 /Master/texmf-dist/doc/latex/newenviron | |
parent | 2b46f54da2f55e9244638b6cb630a53ae805cd94 (diff) |
newenviron (10mar13)
git-svn-id: svn://tug.org/texlive/trunk@29331 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/newenviron')
-rw-r--r-- | Master/texmf-dist/doc/latex/newenviron/README | 44 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/newenviron/newenviron-examples.tex | 74 |
2 files changed, 118 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/newenviron/README b/Master/texmf-dist/doc/latex/newenviron/README new file mode 100644 index 00000000000..9bb80720ceb --- /dev/null +++ b/Master/texmf-dist/doc/latex/newenviron/README @@ -0,0 +1,44 @@ +This is the README file for the 'newenviron' package. + +AUTHOR + +Ahmed Musa + +VERSION + +Version 1.0, 2013/02/10. + +LOCATION ON CTAN + +macros/latex/contrib/newenviron/ + +LICENSE + +Copyright (c) 2013 Ahmed Musa + +This software is author-maintained. Permission is granted to copy, +distribute and/or modify this software under the terms of the +LaTeX Project Public License, version 1.3 or higher. This software +is provided 'as it is', without warranty of any kind, either +expressed or implied, including, but not limited to, the implied +warranties of merchantability and fitness for any particular purpose. + +SUMMARY + +The 'newenviron' package provides the commands \newenviron and +\renewenviron that can be used to define environments whose bodies +will be collected in the macros \envbody and \<env name>body. These +macros can used to apply some code to the environment body at invocation +time. + +The user-defined environments can be mixed and nested to any depth, +both at definition and invocation times. + +There also exist the commands \EveryBeginOfEnvironment and +\EveryEndOfEnvironment for adding code to the start or end of the +environment at invocation time. + +See the accompanying example file 'newenviron-examples.tex'. + + +% End of README file of newenviron.sty diff --git a/Master/texmf-dist/doc/latex/newenviron/newenviron-examples.tex b/Master/texmf-dist/doc/latex/newenviron/newenviron-examples.tex new file mode 100644 index 00000000000..58b80bfea84 --- /dev/null +++ b/Master/texmf-dist/doc/latex/newenviron/newenviron-examples.tex @@ -0,0 +1,74 @@ +\documentclass{article} +\usepackage{newenviron,xcolor} + +% \envbody will always work for 'unnested' environments: + +% \newenviron{assertion}{}{Assertion: \envbody} + +% But if you intend to nest the environment, it will be safer to use +% \assertionbody: + +\newenviron{assertion}{% + % Test <start-code>. Note the doubling of the hash characters: + \def\acmd##1{##1}% +}{% + \def\bcmd##1{##1}% + Assertion: \assertionbody +} + +\newenviron{outerassertion}{% + % Put any start code here. +}{% + \textcolor{blue}{Outer assertion:} % + \begin{assertion}\outerassertionbody\end{assertion}% +} + +\begin{document} + +% Just for testing: +\EveryEndOfEnvironment{\def\ccmd#1{#1}} + +\begin{assertion} + test +\end{assertion} +\endgraf\bigskip + +\begin{outerassertion} + test2 +\end{outerassertion} +\endgraf\bigskip + +% Another test. Note the use of \usename{env-1body} and \usename{env-2body}: +\newenviron{env-1}[2][blue]{% + \fboxrule=#2\relax + \cptdimdef\temp{.5\textwidth-0.1cm*\currentgrouplevel}% + \endgraf\noindent + \fcolorbox{#1}{gray!10}{\parbox{\temp}{\textcolor{#1}{\usename{env-1body}}}}% +}{} +\newenviron*{env-2}[1][black]{% + \noindent + \fcolorbox{#1}{gray!30}{% + \parbox{.7\textwidth}{% + \leftskip=1cm + \textcolor{#1}{\usename{env-2body}}% + }% + }% +}{% + \def\testcmd##1{##1}% +} + +\begin{env-2}[red] + Outer box\endgraf + \def\tempa#1{***#1***}\tempa{aa}% + \endgraf\vspace*{5mm}% + \begin{env-1}[blue]{1pt}% + Inner box\endgraf\vspace*{5mm}% + \def\tempa#1{+++#1+++}\tempa{bb}% + \end{env-1}% + \begin{env-1}[brown]{4pt}% + Inner box\endgraf\vspace*{5mm}% + \def\tempa#1{---#1---}\tempa{cc}% + \end{env-1}% +\end{env-2} + +\end{document} |