| 1 |
%% |
| 2 |
%% This is file `keycommand-example.tex', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% keycommand.dtx (with options: `example') |
| 8 |
%% |
| 9 |
%% This is a generated file. |
| 10 |
%% |
| 11 |
%% keycommand : key-value interface for commands and environments in LaTeX [v3.1415 2010/04/27] |
| 12 |
%% |
| 13 |
%% This work may be distributed and/or modified under the |
| 14 |
%% conditions of the LaTeX Project Public License, either |
| 15 |
%% version 1.3 of this license or (at your option) any later |
| 16 |
%% version. The latest version of this license is in |
| 17 |
%% http://www.latex-project.org/lppl.txt |
| 18 |
%% |
| 19 |
%% This work consists of the main source file keycommand.dtx |
| 20 |
%% and the derived files |
| 21 |
%% keycommand.sty, keycommand.pdf, keycommand.ins, |
| 22 |
%% keycommand-example.tex |
| 23 |
%% |
| 24 |
%% keycommand : an easy way to define commands with optional keys |
| 25 |
%% Copyright (C) 2009-2010 by Florent Chervet <[email protected]> |
| 26 |
%% |
| 27 |
\ProvidesFile{keycommand-example} |
| 28 |
\documentclass[a4paper]{article} |
| 29 |
\usepackage[T1]{fontenc} |
| 30 |
\usepackage[latin1]{inputenc} |
| 31 |
\usepackage[american]{babel} |
| 32 |
\usepackage{keycommand,framed,fancyvrb} |
| 33 |
\makeatletter |
| 34 |
\parindent\z@ |
| 35 |
\newkeycommand*\Rule[raise=.4ex,width=1em,thick=.4pt][1]{% |
| 36 |
\rule[\commandkey{raise}]{\commandkey{width}}{\commandkey{thick}}% |
| 37 |
#1% |
| 38 |
\rule[\commandkey{raise}]{\commandkey{width}}{\commandkey{thick}}} |
| 39 |
|
| 40 |
\newkeycommand*\charleads[sep=1][2]{% |
| 41 |
\ifhmode\else\leavevmode\fi\setbox\@tempboxa\hbox{#2}\@tempdima=1.584\wd\@tempboxa% |
| 42 |
\cleaders\hb@xt@\commandkey{sep}\@tempdima{\hss\box\@tempboxa\hss}#1% |
| 43 |
\setbox\@tempboxa\box\voidb@x} |
| 44 |
\newcommand*\charfill[1][]{\charleads[{#1}]{\hfill\kern\z@}} |
| 45 |
\newcommand*\charfil[1][]{\charleads[{#1}]{\hfil\kern\z@}} |
| 46 |
\newkeyenvironment*{dblruled}[first=.4pt,second=.4pt,sep=1pt,left=\z@]{% |
| 47 |
\def\FrameCommand{% |
| 48 |
\vrule\@width\commandkey{first}% |
| 49 |
\hskip\commandkey{sep} |
| 50 |
\vrule\@width\commandkey{second}% |
| 51 |
\hspace{\commandkey{left}}}% |
| 52 |
\parindent\z@ |
| 53 |
\MakeFramed {\advance\hsize-\width \FrameRestore}} |
| 54 |
{\endMakeFramed} |
| 55 |
\makeatother |
| 56 |
\begin{document} |
| 57 |
\title{This is {\tt keycommand-example.tex}} |
| 58 |
\author{Florent Chervet} |
| 59 |
\date{July 22, 2009} |
| 60 |
|
| 61 |
\maketitle |
| 62 |
|
| 63 |
{\Large Please refer to {\tt keycommand-example.tex} for definitions.} |
| 64 |
|
| 65 |
\section{Example of a keycommand : \texttt{\string\Rule}} |
| 66 |
|
| 67 |
\begin{tabular*}\textwidth{rl} |
| 68 |
\verb+\Rule[width=2em]{hello}+:&\Rule[width=2em]{hello}\cr |
| 69 |
\verb+\Rule[thick=1pt,width=2em]{hello}+:&\Rule[thick=1pt,width=2em]{hello}\cr |
| 70 |
\verb+\Rule{hello}+:&\Rule{hello}\cr |
| 71 |
\verb+\Rule[thick=1pt,raise=1ex]{hello}+:&\Rule[thick=1pt,raise=1ex]{hello} |
| 72 |
\end{tabular*} |
| 73 |
|
| 74 |
\section{Example of a keycommand : \texttt{\string\charfill}} |
| 75 |
|
| 76 |
\begin{tabular*}\textwidth{rp{.4\textwidth}} |
| 77 |
\verb+\charfill{$\star$}+: & \charfill{$\star$}\cr |
| 78 |
\verb+\charfill[sep=2]{$\star$}+: & \charfill[sep=2]{$\star$} \\ |
| 79 |
\verb+\charfill[sep=.7]{\textasteriskcentered}+: & \charfill[sep=.7]{\textasteriskcentered} |
| 80 |
\end{tabular*} |
| 81 |
|
| 82 |
\section{Example of a keyenvironment : \texttt{dblruled}} |
| 83 |
|
| 84 |
Key environment \texttt{dblruled } uses \texttt{framed.sty} and therefore it can be used |
| 85 |
even if a pagebreak occurs inside the environment: |
| 86 |
\medskip |
| 87 |
|
| 88 |
\verb+\begin{dblruled}+\par |
| 89 |
\verb+ test for dblruled key-environment\par+\par |
| 90 |
\verb+ test for dblruled key-environment\par+\par |
| 91 |
\verb+ test for dblruled key-environment+\par |
| 92 |
\verb+\end{dblruled}+ |
| 93 |
|
| 94 |
\begin{dblruled} |
| 95 |
test for dblruled key-environment\par |
| 96 |
test for dblruled key-environment\par |
| 97 |
test for dblruled key-environment |
| 98 |
\end{dblruled} |
| 99 |
|
| 100 |
\verb+\begin{dblruled}[first=4pt,sep=2pt,second=.6pt,left=.2em]+\par |
| 101 |
\verb+ test for dblruled key-environment\par+\par |
| 102 |
\verb+ test for dblruled key-environment\par+\par |
| 103 |
\verb+ test for dblruled key-environment+\par |
| 104 |
\verb+\end{dblruled}+ |
| 105 |
|
| 106 |
\begin{dblruled}[first=4pt,sep=2pt,second=.6pt,left=.2em] |
| 107 |
test for dblruled key-environment\par |
| 108 |
test for dblruled key-environment\par |
| 109 |
test for dblruled key-environment |
| 110 |
\end{dblruled} |
| 111 |
|
| 112 |
\end{document} |
| 113 |
\endinput |
| 114 |
%% |
| 115 |
%% End of file `keycommand-example.tex'. |