summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/tcolorbox/tcolorbox.doc.listings.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-07-15 22:46:30 +0000
committerKarl Berry <karl@freefriends.org>2013-07-15 22:46:30 +0000
commitb927b3c4405faf2fc0c1a8b34e07cc7c5dd5b5e8 (patch)
tree3f0b50cbbf4621a283f566948a7f04fe91237876 /Master/texmf-dist/doc/latex/tcolorbox/tcolorbox.doc.listings.tex
parentbaf92cd2b6a50c9aaf590f0c88a71532f72667dd (diff)
tcolorbox (15jul13)
git-svn-id: svn://tug.org/texlive/trunk@31204 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/tcolorbox/tcolorbox.doc.listings.tex')
-rw-r--r--Master/texmf-dist/doc/latex/tcolorbox/tcolorbox.doc.listings.tex136
1 files changed, 95 insertions, 41 deletions
diff --git a/Master/texmf-dist/doc/latex/tcolorbox/tcolorbox.doc.listings.tex b/Master/texmf-dist/doc/latex/tcolorbox/tcolorbox.doc.listings.tex
index 317ad7e5166..6bbac3e8cb5 100644
--- a/Master/texmf-dist/doc/latex/tcolorbox/tcolorbox.doc.listings.tex
+++ b/Master/texmf-dist/doc/latex/tcolorbox/tcolorbox.doc.listings.tex
@@ -98,7 +98,7 @@ This \textbf{text} is written to a standardized file for later usage.
\clearpage
-\begin{docCommand}{newtcblisting}{\marg{name}\oarg{number}\oarg{default}\marg{options}}
+\begin{docCommand}{newtcblisting}{\oarg{init options}\marg{name}\oarg{number}\oarg{default}\marg{options}}
Creates a new environment \meta{name} based on \refEnv{tcblisting}.
Basically, |\newtcblisting| operates like |\newenvironment|. This means,
the new environment \meta{name} optionally takes \meta{number} arguments, where
@@ -106,6 +106,8 @@ This \textbf{text} is written to a standardized file for later usage.
The \meta{options} are given to the underlying |tcblisting|.
Note that \refKey{/tcb/savedelimiter} is set to the given \meta{name}
automatically.
+ The \meta{init options} allow to set up automatic numbering,
+ see Section \ref{sec:initkeys} from page \pageref{sec:initkeys}.
\begin{dispExample*}{sbs,lefthand ratio=0.5}
\newtcblisting{mybox}{%
colback=red!5!white,
@@ -146,13 +148,76 @@ This is my \LaTeX\ box.
This is my
\LaTeX\ box.
\end{mybox}
+\end{dispExample*}
+
+\inputpreamblelisting{C}
+\begin{dispExample*}{sbs,lefthand ratio=0.5}
+\begin{mycbox}{Listing Box}
+This is my \LaTeX\ box.
+\end{mycbox}
\end{dispExample*}
+
\end{docCommand}
\clearpage
+\begin{docCommand}{newtcbinputlisting}{\oarg{init options}\marg{\texttt{\textbackslash}name}\oarg{number}\oarg{default}\marg{options}}
+ Creates a new macro \meta{\texttt{\textbackslash}name} based on \refCom{tcbinputlisting}.
+ Basically, |\newtcbinputlisting| operates like |\newcommand|.
+ The new macro \meta{\texttt{\textbackslash}name} optionally takes \meta{number}$+1$ arguments, where
+ \meta{default} is the default value for the optional first argument.
+ The \meta{options} are given to the underlying |tcbinputlisting|.
+ The \meta{init options} allow to set up automatic numbering,
+ see Section \ref{sec:initkeys} from page \pageref{sec:initkeys}.
+
+\begin{dispExample}
+\newtcbinputlisting[use counter from=mycbox]{\mylisting}[2][]{%
+ listing file={#2},
+ title=Listing (\thetcbcounter) of \texttt{#2},
+ colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,
+ listing only,breakable,#1}
+
+\mylisting[before upper=\textit{This is the included file content:}]
+ {\jobname.tcbtemp}
+\end{dispExample}
+
+% \begin{dispExample*}{sbs,lefthand ratio=0.6}
+% \newtcbinputlisting{\mybox}{colback=red!5!white,
+ % colframe=red!75!black}
+%
+% \mybox{This is my own box.}
+% \end{dispExample*}
+%
+% \begin{dispExample*}{sbs,lefthand ratio=0.6}
+% \newtcbinputlisting{\mybox}[1]{colback=red!5!white,
+ % colframe=red!75!black,fonttitle=\bfseries,
+ % title=#1}
+%
+% \mybox{Hello there}{This is my own box.}
+% \end{dispExample*}
+%
+% \begin{dispExample*}{sbs,lefthand ratio=0.6}
+% \newtcbinputlisting{\mybox}[2][]{colback=red!5!white,
+ % colframe=red!75!black,fonttitle=\bfseries,
+ % title=#2,#1}
+%
+% \mybox[colback=yellow]{Hello there}%
+ % {This is my own box.}
+% \end{dispExample*}
+%
+% \inputpreamblelisting{B}
+%
+% \begin{dispExample*}{sbs,lefthand ratio=0.6}
+% \pbbox[colback=yellow]{Hello there}%
+ % {This is my own box.}
+% \end{dispExample*}
+
+\end{docCommand}
+
+
+\clearpage
\subsection{Option Keys of the Library}
For the \meta{options} in \refEnv{tcblisting} respectively \refCom{tcbinputlisting}
the following |pgf| keys can be applied. The key tree path |/tcb/| is not to
@@ -360,23 +425,17 @@ The following source code gives a guideline for the creation of \LaTeX\ tutorial
In the next section, a framework for \LaTeX\ exercises is described.
All examples shall be numbered optionally.
-Firstly, some additional |tcb| keys are defined for the appearance and automatic
-numbering.
+Firstly, some additional |tcb| keys are defined for the appearance.
+For the examples, three environments |texexp|, |texexptitled|,
+and |texexptitledspec| are defined with automatic numbering.
-\begin{dispListing}
-%\newcounter{texexp} % preamble
-
-\tcbset{
- texexp/.style={colframe=red!50!yellow!50!black, colback=red!50!yellow!5!white,
- coltitle=red!50!yellow!3!white,
- fonttitle=\small\sffamily\bfseries, fontupper=\small, fontlower=\small},
- example/.style 2 args={texexp,
- step and label={texexp}{#2},
- title={Example \thetexexp: #1}},
-}
-\end{dispListing}
-\tcbusetemp
+\begin{itemize}
+\item |texexp| is used for untitled examles,
+\item |texexptitled| is used for titled examles,
+\item |texexptitledspec| is used for titled examles with special treatment.
+\end{itemize}
+\inputpreamblelisting{D}
\begin{dispExample}
\begin{tcblisting}{texexp}
@@ -387,27 +446,11 @@ and in compiled form.
\begin{dispExample}
-\begin{tcblisting}{example={Direct application of \texttt{example}}{firstExample}}
+\begin{texexptitled}{First example with a title line}{firstExample}
Here, we use Example \ref{firstExample} with a title line.
-\end{tcblisting}
+\end{texexptitled}
\end{dispExample}
-For the next examples, two environments
-|texexp| and |texexptitled|
-are defined for abbreviation.
-
-\begin{dispListing}
-\newtcblisting{texexp}[1]{texexp,#1}
-
-\newtcblisting{texexptitled}[3][]{example={#2}{#3},#1}
-\end{dispListing}
-\tcbusetemp
-
-For special cases, |tcolorbox| with the key
-|texexp| can be used instead of these two environments.
-
-Now, we have a flexible box for \LaTeX\ examples which is demonstrated in
-the following.
\begin{dispExample}
\begin{texexp}{}
@@ -472,15 +515,15 @@ on page \pageref{heading3}.
\begin{dispExample}
-\begin{tcolorbox}[example={Direct application of the style |texexp|}{texexpbox1}]
+\begin{texexptitledspec}{Special application}{texexpbox1}
\begin{lstlisting}[style=tcblatex]
Some \LaTeX\ source code.
\end{lstlisting}
\tcblower
-For special cases, the environment |tcolorbox| with style
+For special cases, the environment |texexptitledspec| with style
|example| can be used directly. As one can see, the upper and the lower
part of the box can be used uncoupled also.
-\end{tcolorbox}
+\end{texexptitledspec}
\end{dispExample}
@@ -584,7 +627,7 @@ processing. The solution contents themselves are saved to a subdirectory named
\newwrite\solout
\def\openoutsol{\immediate\openout\solout\jobname.sol}
\def\solfile#1{solutions/texercise#1.tex}
-\def\writesol#1{\immediate\write\solout{\noexpand\processsol{\thetexercise}{#1}}}%
+\def\writesol#1{\immediate\write\solout{\noexpand\processsol{\thetcbcounter}{#1}}}%
\def\closeoutsol{\immediate\closeout\solout}
\def\inputsol{\IfFileExists{\jobname.sol}{\input{\jobname.sol}}{}}
\end{dispListing}
@@ -622,6 +665,8 @@ and the label |sol:|\meta{marker} is used to mark the solution.
With these preparations, the kernel environment |texercise| for our
exercises is created quickly:
+\inputpreamblelisting{E}
+
\begin{dispListing}
\newtcolorbox{texercise}[2][]{texercisestyle,
listing file={\solfile\thetexercise},
@@ -629,7 +674,7 @@ exercises is created quickly:
title={Exercise \arabic{texercise}%
\hfill\mdseries Solution on page \pageref{sol:#2}},#1}
\end{dispListing}
-\tcbusetemp
+%\tcbusetemp
The following examples demonstrate the application.
\openoutsol
@@ -727,10 +772,19 @@ total line width.\par\smallskip
\tcbusetemplisting\par\smallskip\tcbusetemp%
\end{texercise}
\end{dispExample}
+\closeoutsol
+\bigskip
+Now, we give a list of all exercises with:
-\closeoutsol
+\begin{dispListing}
+\tcblistof[\subsection]{exam}{List of Exercises%
+ \label{listofexercises}}
+\end{dispListing}
+\tcbusetemp
+
+\clearpage
\subsection{Solutions for the given \LaTeX\ Exercises}
For all solutions, a macro |\processsol| was written to the file |\jobname.sol|.
@@ -742,7 +796,7 @@ Now, we need a definition for this macro to use the solutions.
\tcbinputlisting{texercisestyle,listing only,
phantom={\phantomsection\label{sol:#2}},%
title={Solution for Exercise \ref{exe:#2} on page \pageref{exe:#2}},
- listing file={\solfile#1}}}
+ listing file={\solfile{#1}}}}
\end{dispListing}
\tcbusetemp