summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/newenviron/newenviron-examples.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/newenviron/newenviron-examples.tex')
-rw-r--r--Master/texmf-dist/doc/latex/newenviron/newenviron-examples.tex74
1 files changed, 74 insertions, 0 deletions
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}