summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/vwcol
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-07-04 10:49:07 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-07-04 10:49:07 +0000
commitffb3d536f57670f1c85792d133bdaee30cf23a70 (patch)
tree07e7f21cf8d9b10aa5c03b20688738e7b9b6ee78 /Master/texmf-dist/tex/latex/vwcol
parent3808f9582452443de2e1a2a2b857a00ae7eb79aa (diff)
new vwcol package
git-svn-id: svn://tug.org/texlive/trunk@9225 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/vwcol')
-rw-r--r--Master/texmf-dist/tex/latex/vwcol/vwcol.sty414
1 files changed, 414 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/vwcol/vwcol.sty b/Master/texmf-dist/tex/latex/vwcol/vwcol.sty
new file mode 100644
index 00000000000..3e958054408
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/vwcol/vwcol.sty
@@ -0,0 +1,414 @@
+%%
+%% This is file `vwcol.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% vwcol.dtx (with options: `package')
+%%
+%% __________________________________
+%% Copyright (C) 2008 Will Robertson
+%%
+%% License information appended.
+%%
+\ProvidesPackage{vwcol}
+ [2008/06/24 v0.1 Variable-width multicolumn text]
+\RequirePackage{calc}
+\RequirePackage{environ}[2008/06/18]
+\RequirePackage{keyval}
+\RequirePackage{ragged2e}
+\newlength\vwcol@sep
+\newlength\vwcol@rule
+\newlength\vwcol@totalwidth
+\newlength\vwcol@averagewidth
+\newlength\vwcol@parindent
+\newcount\vwcol@last
+\newcount\vwcol@Ncols
+\newcount\vwcol@Nlines
+\newcount\vwcol@maxrecursion
+\newbox\vwcol@box
+\newbox\vwcol@plainbox
+\newbox\vwcol@outputbox
+\newif\if@vwcol@boxready
+\newif\if@vwcol@prerule
+\newif\if@vwcol@postrule
+\newif\if@vwcol@presep
+\newif\if@vwcol@postsep
+\newcommand\vwcol@PackageError[2]{%
+ \PackageError{vwcol}{^^J\space\space#1}{#2}}
+\newcommand\vwcol@PackageWarning[1]{%
+ \PackageWarning{vwcol}{%
+ ^^J\space\space#1^^JThis warning occurred}}
+\newcommand\vwcol@PackageInfo[1]{%
+ \PackageWarning{vwcol}{%
+ ^^J\space\space#1^^JThis warning occurred}}
+\DeclareOption{quiet}{%
+ \renewcommand\vwcol@PackageError[2]{%
+ \vwcol@PackageWarning{#1.}}%
+ \let\vwcol@PackageInfo\@gobble}
+\ProcessOptions
+\def\vwcol@test@length#1#2{%
+ \afterassignment\vwcol@test@@
+ \@tempdima=#1#2\@nil}
+\def\vwcol@test@@#1\@nil{%
+ \ifx\@nil#1\@nil
+ \@tempswatrue
+ \else
+ \@tempswafalse
+ \fi}
+\def\vwcolsetup{\setkeys{vwcol}}
+\define@key{vwcol}{widths}{\def\vwcol@widths{#1}}
+\define@key{vwcol}{maxrecursion}{\vwcol@maxrecursion=#1}
+\vwcolsetup{maxrecursion=5}
+\define@key{vwcol}{rule}{%
+ \def\@tempa{#1}%
+ \def\@tempb{none}%
+ \ifx\@tempa\@tempb
+ \vwcol@rule=0pt
+ \else
+ \vwcol@test@length{#1}{\linewidth}%
+ \vwcol@rule=\@tempdima
+ \fi}
+\vwcolsetup{rule=0.4pt}
+\define@key{vwcol}{lines}{%
+ \def\@tempa{#1}%
+ \def\@tempb{auto}%
+ \ifx\@tempa\@tempb
+ \vwcol@Nlines=0
+ \else
+ \vwcol@Nlines=#1
+ \fi}
+\vwcolsetup{lines=auto}
+\define@key{vwcol}{sep}{%
+ \def\@tempa{#1}%
+ \def\@tempb{fill}%
+ \ifx\@tempa\@tempb
+ \vwcol@sep=1sp
+ \else
+ \vwcol@test@length{#1}{\linewidth}%
+ \vwcol@sep=\@tempdima
+ \fi}
+\vwcolsetup{sep=0.05}
+\define@key{vwcol}{presep}[true]{%
+ \def\@tempa{#1}%
+ \def\@tempb{true}%
+ \ifx\@tempa\@tempb
+ \@vwcol@preseptrue
+ \else
+ \def\@tempb{false}%
+ \ifx\@tempa\@tempb
+ \@vwcol@presepfalse
+ \else
+ \vwcol@PackageWarning{%
+ '#1' not a valid option for option 'presep';
+ 'true' or 'false' only.}%
+ \fi
+ \fi}
+\vwcolsetup{presep=false}
+
+\define@key{vwcol}{postsep}[true]{%
+ \def\@tempa{#1}%
+ \def\@tempb{true}%
+ \ifx\@tempa\@tempb
+ \@vwcol@postseptrue
+ \else
+ \def\@tempb{false}%
+ \ifx\@tempa\@tempb
+ \@vwcol@postsepfalse
+ \else
+ \vwcol@PackageWarning{%
+ '#1' not a valid option for option 'postsep';
+ 'true' or 'false' only.}%
+ \fi
+ \fi}
+\vwcolsetup{postsep=false}
+\define@key{vwcol}{sidesep}[true]{%
+ \def\@tempa{#1}%
+ \def\@tempb{true}%
+ \ifx\@tempa\@tempb
+ \@vwcol@preseptrue
+ \@vwcol@postseptrue
+ \else
+ \def\@tempb{false}%
+ \ifx\@tempa\@tempb
+ \@vwcol@presepfalse
+ \@vwcol@postsepfalse
+ \else
+ \vwcol@PackageWarning{%
+ '#1' not a valid option for option 'sidesep';
+ 'true' or 'false' only.}%
+ \fi
+ \fi}
+\define@key{vwcol}{prerule}[true]{%
+ \def\@tempa{#1}%
+ \def\@tempb{true}%
+ \ifx\@tempa\@tempb
+ \@vwcol@preseptrue
+ \@vwcol@preruletrue
+ \else
+ \def\@tempb{false}%
+ \ifx\@tempa\@tempb
+ \@vwcol@prerulefalse
+ \else
+ \vwcol@PackageWarning{%
+ '#1' not a valid option for option 'prerule';
+ 'true' or 'false' only.}%
+ \fi
+ \fi}
+\vwcolsetup{prerule=false}
+\define@key{vwcol}{postrule}[true]{%
+ \def\@tempa{#1}%
+ \def\@tempb{true}%
+ \ifx\@tempa\@tempb
+ \@vwcol@postseptrue
+ \@vwcol@postruletrue
+ \else
+ \def\@tempb{false}%
+ \ifx\@tempa\@tempb
+ \@vwcol@postrulefalse
+ \else
+ \vwcol@PackageWarning{%
+ '#1' not a valid option for option 'postrule';
+ 'true' or 'false' only.}%
+ \fi
+ \fi}
+\vwcolsetup{postrule=false}
+\define@key{vwcol}{siderule}[true]{%
+ \def\@tempa{#1}%
+ \def\@tempb{true}%
+ \ifx\@tempa\@tempb
+ \@vwcol@preseptrue
+ \@vwcol@postseptrue
+ \@vwcol@preruletrue
+ \@vwcol@postruletrue
+ \else
+ \def\@tempb{false}%
+ \ifx\@tempa\@tempb
+ \@vwcol@prerulefalse
+ \@vwcol@postrulefalse
+ \else
+ \vwcol@PackageWarning{%
+ '#1' not a valid option for option 'siderule';
+ 'true' or 'false' only.}%
+ \fi
+ \fi}
+\define@key{vwcol}{justify}{%
+ \def\@tempa{#1}%
+ \def\@tempb{ragged}%
+ \ifx\@tempa\@tempb
+ \let\vwcol@justify\RaggedRight
+ \else
+ \def\@tempb{flush}%
+ \ifx\@tempa\@tempb
+ \let\vwcol@justify\justifying
+ \else
+ \def\@tempb{raggedleft}%
+ \ifx\@tempa\@tempb
+ \let\vwcol@justify\RaggedLeft
+ \else
+ \def\@tempb{center}%
+ \ifx\@tempa\@tempb
+ \let\vwcol@justify\Centering
+ \else
+ \vwcol@PackageWarning{%
+ '#1' not a valid option for option 'justify';
+ one of 'flush'/'ragged'/'raggedleft'/'center' only.}%
+ \fi
+ \fi
+ \fi
+ \fi}
+\vwcolsetup{justify=ragged}
+\define@key{vwcol}{indent}{\setlength\vwcol@parindent{#1}}
+\vwcolsetup{indent=1.5em}
+\NewEnviron{vwcol}[1][]{%
+ \par\noindent
+ \@vwcol@boxreadyfalse
+ \vwcolsetup{#1}%
+ \splittopskip=\ht\strutbox
+ \expandafter\vwcol@process@widths\expandafter{\vwcol@widths}%
+ \vwcol@para@setup
+ \ifdim\vwcol@sep=1sp
+ \vwcol@totalwidth=\linewidth
+ \else
+ \vwcol@totalwidth=\numexpr
+ \vwcol@totalwidth+(\vwcol@Ncols-1)*\vwcol@sep
+ \relax sp
+ \if@vwcol@presep
+ \advance\vwcol@totalwidth\dimexpr(\vwcol@sep-\vwcol@rule)/2\relax
+ \fi
+ \if@vwcol@postsep
+ \advance\vwcol@totalwidth\dimexpr(\vwcol@sep-\vwcol@rule)/2\relax
+ \fi
+ \if@vwcol@prerule \advance\vwcol@totalwidth \vwcol@rule\fi
+ \if@vwcol@postrule\advance\vwcol@totalwidth \vwcol@rule\fi
+ \fi
+ \ifdim\vwcol@totalwidth > \linewidth
+ \vwcol@PackageWarning{%
+ Total width of columns plus their separations
+ is greater than the linewidth^^J\space\space
+ (by \the\vwcol@totalwidth\space - \the\linewidth\space =
+ \the\dimexpr \vwcol@totalwidth-\linewidth\relax)}%
+ \fi
+ \ifnum\vwcol@Nlines=0%
+ \@tempcnta=\hbadness
+ \hbadness=\maxdimen
+ \setbox\vwcol@plainbox\hbox{%
+ \parbox{\vwcol@averagewidth}{\vwcol@justify\BODY}}%
+ \hbadness=\@tempcnta
+ \vwcol@Nlines=\numexpr
+ (\ht\vwcol@plainbox+\dp\vwcol@plainbox)/
+ (\baselineskip*\vwcol@Ncols)
+ \relax
+ \@tempcnta=1%
+ \loop\unless\if@vwcol@boxready
+ \savebox\vwcol@outputbox{%
+ \hbox to \vwcol@totalwidth{\vwcol@{\BODY}}}%
+ \unless\if@vwcol@boxready
+ \advance\@tempcnta 1%
+ \advance\vwcol@Nlines 1%
+ \ifnum\@tempcnta>\vwcol@maxrecursion
+ \@vwcol@boxreadytrue
+ \vwcol@PackageError{%
+ The estimated number of lines is greater than
+ \the\vwcol@maxrecursion\space lines too small,%
+ ^^J\space\space
+ so I gave up (last tried maximum value of
+ [lines=\the\vwcol@Nlines])%
+ }{%
+ Text will be truncated in the multicolumns;
+ please select the%
+ ^^J\space\space
+ number of lines explicitly or increase
+ [maxrecursion=\the\vwcol@maxrecursion].%
+ }%
+ \fi
+ \fi
+ \repeat
+ \usebox\vwcol@outputbox
+ \else
+ \hbox to \vwcol@totalwidth{\vwcol@{\BODY}}%
+ \unless\if@vwcol@boxready
+ \vwcol@PackageError{%
+ Not enough lines to fit the entire text;
+ some text has been truncated.^^J\space\space
+ Increase [lines=\the\vwcol@Nlines] to fit more%
+ }{%
+ Or remove [lines=\the\vwcol@Nlines] altogether
+ to have 'vwcol' estimate the value.}%
+ \fi
+ \fi\par}
+\def\vwcol@para@setup{%
+ \vwcol@justify
+ \@tempswafalse
+ \ifx\vwcol@justify\RaggedRight
+ \@tempswatrue
+ \else\ifx\vwcol@justify\justifying
+ \@tempswatrue
+ \fi\fi
+ \if@tempswa
+ \parindent=\vwcol@parindent
+ \else
+ \vwcol@PackageInfo{%
+ 'indent' ignored for [justify=raggedleft]
+ or [justify=center]}
+ \fi
+ \parskip=0pt}
+\def\vwcol@process@widths#1{%
+ \@for\@ii:=#1\do{\advance\vwcol@Ncols 1}%
+ \ifdim\vwcol@sep=1sp
+ \@tempdimb=\numexpr
+ \linewidth-(\vwcol@Ncols-1)*\vwcol@rule
+ \relax sp
+ \else
+ \ifdim\vwcol@rule > \vwcol@sep
+ \vwcol@sep=\vwcol@rule
+ \vwcol@PackageWarning{%
+ 'sep' must be greater than or equal to 'rule'}%
+ \fi
+ \@tempdimb=\numexpr
+ \linewidth-(\vwcol@Ncols-1)*\vwcol@sep
+ \relax sp
+ \if@vwcol@presep
+ \advance\@tempdimb\dimexpr(-\vwcol@sep+\vwcol@rule)/2\relax
+ \fi
+ \if@vwcol@postsep
+ \advance\@tempdimb\dimexpr(-\vwcol@sep+\vwcol@rule)/2\relax
+ \fi
+ \fi
+ \if@vwcol@prerule\advance\@tempdimb-\vwcol@rule\fi
+ \if@vwcol@postrule\advance\@tempdimb-\vwcol@rule\fi
+ \@for\@ii:=#1\do{%
+ \vwcol@test@length\@ii\@tempdimb
+ \advance\vwcol@totalwidth\@tempdima
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter\vwcol@setup@parlines
+ \expandafter\expandafter\expandafter{%
+ \expandafter\vwcol@setup@parlines
+ \expandafter\vwcol@addlines
+ \expandafter{\the\@tempdima}}}%
+ \vwcol@averagewidth=\dimexpr \vwcol@totalwidth/\vwcol@Ncols \relax}
+\def\vwcol@setup@parlines{\let\vwcol@parlines\@empty}
+\def\vwcol@addlines#1{%
+ \@tempcnta=0
+ \loop\ifnum\@tempcnta<\vwcol@Nlines
+ \advance\@tempcntb 1
+ \ifnum\@tempcntb>\vwcol@last
+ \xdef\vwcol@parlines{\vwcol@parlines 0cm #1 }%
+ \fi
+ \advance\@tempcnta 1
+ \repeat}
+\newcommand\vwcol@[1]{%
+ \setbox\vwcol@box\vbox{%
+ \def\par{\endgraf\advance\vwcol@last\the\prevgraf}%
+ \everypar{%
+ \@tempcntb=0
+ \vwcol@setup@parlines
+ \parshape=\numexpr \vwcol@Nlines*\vwcol@Ncols-\vwcol@last \relax
+ \vwcol@parlines}%
+ \noindent\strut#1}%
+ \if@vwcol@presep
+ \if@vwcol@prerule
+ \vrule width \vwcol@rule
+ \fi
+ \hskip\dimexpr (\vwcol@sep-\vwcol@rule)/2 \relax
+ \fi
+ \@tempcnta=0
+ \loop\ifnum\@tempcnta < \vwcol@Ncols
+ \advance\@tempcnta 1
+ \unless\ifnum\@tempcnta=1
+ \ifdim\vwcol@sep=1sp
+ \hfill\vrule width \vwcol@rule\hfill
+ \else
+ \@tempdima=\dimexpr (\vwcol@sep-\vwcol@rule)/2 \relax
+ \hskip\@tempdima\vrule width \vwcol@rule\hskip\@tempdima
+ \fi
+ \fi
+ \vsplit\vwcol@box to \numexpr
+ (\vwcol@Nlines-1)*\baselineskip+\ht\strutbox \relax sp
+ \repeat
+ \if@vwcol@postsep
+ \hskip\dimexpr (\vwcol@sep-\vwcol@rule)/2 \relax
+ \if@vwcol@postrule
+ \vrule width \vwcol@rule
+ \fi
+ \fi
+ \ifvoid\vwcol@box
+ \global\@vwcol@boxreadytrue
+ \fi}
+%%
+%% Copyright (C) 2008 by Will Robertson <wspr81@gmail.com>
+%%
+%% Distributable under the LaTeX Project Public License,
+%% version 1.3c or higher (your choice). The latest version of
+%% this license is at: http://www.latex-project.org/lppl.txt
+%%
+%% This work is "maintained" (as per LPPL maintenance status)
+%% by Will Robertson.
+%%
+%% This work consists of the file vwcol.dtx
+%% and the derived files vwcol.sty,
+%% vwcol.ins, and
+%% vwcol.pdf.
+%%
+%%
+%% End of file `vwcol.sty'.