summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/keycommand/keycommand-example.tex
blob: dec4d37c6e7391c93ec8453ddce4cb75ec8c3315 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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'.