diff options
Diffstat (limited to 'macros/latex/contrib/keycommand/keycommand-example.tex')
-rw-r--r-- | macros/latex/contrib/keycommand/keycommand-example.tex | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/macros/latex/contrib/keycommand/keycommand-example.tex b/macros/latex/contrib/keycommand/keycommand-example.tex new file mode 100644 index 0000000000..dec4d37c6e --- /dev/null +++ b/macros/latex/contrib/keycommand/keycommand-example.tex @@ -0,0 +1,115 @@ +%% +%% This is file `keycommand-example.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% keycommand.dtx (with options: `example') +%% +%% This is a generated file. +%% +%% keycommand : key-value interface for commands and environments in LaTeX [v3.1415 2010/04/27] +%% +%% 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 +%% +%% This work consists of the main source file keycommand.dtx +%% and the derived files +%% keycommand.sty, keycommand.pdf, keycommand.ins, +%% keycommand-example.tex +%% +%% keycommand : an easy way to define commands with optional keys +%% Copyright (C) 2009-2010 by Florent Chervet <florent.chervet@free.fr> +%% +\ProvidesFile{keycommand-example} +\documentclass[a4paper]{article} +\usepackage[T1]{fontenc} +\usepackage[latin1]{inputenc} +\usepackage[american]{babel} +\usepackage{keycommand,framed,fancyvrb} +\makeatletter +\parindent\z@ +\newkeycommand*\Rule[raise=.4ex,width=1em,thick=.4pt][1]{% + \rule[\commandkey{raise}]{\commandkey{width}}{\commandkey{thick}}% + #1% + \rule[\commandkey{raise}]{\commandkey{width}}{\commandkey{thick}}} + +\newkeycommand*\charleads[sep=1][2]{% + \ifhmode\else\leavevmode\fi\setbox\@tempboxa\hbox{#2}\@tempdima=1.584\wd\@tempboxa% + \cleaders\hb@xt@\commandkey{sep}\@tempdima{\hss\box\@tempboxa\hss}#1% + \setbox\@tempboxa\box\voidb@x} +\newcommand*\charfill[1][]{\charleads[{#1}]{\hfill\kern\z@}} +\newcommand*\charfil[1][]{\charleads[{#1}]{\hfil\kern\z@}} +\newkeyenvironment*{dblruled}[first=.4pt,second=.4pt,sep=1pt,left=\z@]{% + \def\FrameCommand{% + \vrule\@width\commandkey{first}% + \hskip\commandkey{sep} + \vrule\@width\commandkey{second}% + \hspace{\commandkey{left}}}% + \parindent\z@ + \MakeFramed {\advance\hsize-\width \FrameRestore}} + {\endMakeFramed} +\makeatother +\begin{document} +\title{This is {\tt keycommand-example.tex}} +\author{Florent Chervet} +\date{July 22, 2009} + +\maketitle + +{\Large Please refer to {\tt keycommand-example.tex} for definitions.} + +\section{Example of a keycommand : \texttt{\string\Rule}} + +\begin{tabular*}\textwidth{rl} +\verb+\Rule[width=2em]{hello}+:&\Rule[width=2em]{hello}\cr +\verb+\Rule[thick=1pt,width=2em]{hello}+:&\Rule[thick=1pt,width=2em]{hello}\cr +\verb+\Rule{hello}+:&\Rule{hello}\cr +\verb+\Rule[thick=1pt,raise=1ex]{hello}+:&\Rule[thick=1pt,raise=1ex]{hello} +\end{tabular*} + +\section{Example of a keycommand : \texttt{\string\charfill}} + +\begin{tabular*}\textwidth{rp{.4\textwidth}} +\verb+\charfill{$\star$}+: & \charfill{$\star$}\cr +\verb+\charfill[sep=2]{$\star$}+: & \charfill[sep=2]{$\star$} \\ +\verb+\charfill[sep=.7]{\textasteriskcentered}+: & \charfill[sep=.7]{\textasteriskcentered} +\end{tabular*} + +\section{Example of a keyenvironment : \texttt{dblruled}} + +Key environment \texttt{dblruled } uses \texttt{framed.sty} and therefore it can be used +even if a pagebreak occurs inside the environment: +\medskip + +\verb+\begin{dblruled}+\par +\verb+ test for dblruled key-environment\par+\par +\verb+ test for dblruled key-environment\par+\par +\verb+ test for dblruled key-environment+\par +\verb+\end{dblruled}+ + +\begin{dblruled} + test for dblruled key-environment\par + test for dblruled key-environment\par + test for dblruled key-environment +\end{dblruled} + +\verb+\begin{dblruled}[first=4pt,sep=2pt,second=.6pt,left=.2em]+\par +\verb+ test for dblruled key-environment\par+\par +\verb+ test for dblruled key-environment\par+\par +\verb+ test for dblruled key-environment+\par +\verb+\end{dblruled}+ + +\begin{dblruled}[first=4pt,sep=2pt,second=.6pt,left=.2em] + test for dblruled key-environment\par + test for dblruled key-environment\par + test for dblruled key-environment +\end{dblruled} + +\end{document} +\endinput +%% +%% End of file `keycommand-example.tex'. |