summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/interfaces/interfaces-truncate.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/interfaces/interfaces-truncate.sty')
-rw-r--r--Master/texmf-dist/tex/latex/interfaces/interfaces-truncate.sty143
1 files changed, 143 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/interfaces/interfaces-truncate.sty b/Master/texmf-dist/tex/latex/interfaces/interfaces-truncate.sty
new file mode 100644
index 00000000000..fd8ad7ea9b8
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/interfaces/interfaces-truncate.sty
@@ -0,0 +1,143 @@
+%%
+%% This is file `interfaces-truncate.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% interfaces.dtx (with options: `truncate')
+%%
+%% This is a generated file.
+%%
+%% interfaces : 2010/10/20 v1.0 - interfaces : interfaces with keys for other packages (FC)
+%%
+%% 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 interfaces.dtx
+%% and the derived files
+%% interfaces.sty, interfaces.pdf, interfaces.ins,
+%% interfaces-base.sty,
+%% interfaces-LaTeX.sty,
+%% interfaces-tikz.sty,
+%% interfaces-titlesec.sty,
+%% interfaces-hyperref.sty,
+%% interfaces-bookmark.sty,
+%% interfaces-hypbmsec.sty,interfaces-hypbmsec.code.tex,
+%% interfaces-fancyhdr.sty,
+%% interfaces-marks.sty,
+%% interfaces-tocloft.sty,
+%% interfaces-makecell.sty,
+%% interfaces-enumitem.sty,
+%% interfaces-truncate.sty,
+%% interfaces-appendix.sty,
+%% interfaces-embedfile.sty,
+%% interfaces-environ.sty,
+%% interfaces-umrand.sty,
+%% interfaces-scrlfile.sty,
+%% interfaces-pgfkeys.sty,
+%% interfaces-etoolbox.sty,
+%% interfaces-fancyvrb.sty
+%%
+%% interfaces: interfaces with keys for other packages (FC)
+%% Copyright (C) 2010 by Florent Chervet <florent.chervet@free.fr>
+%%
+\ProvidesPackage{interfaces-truncate}
+\newrobustcmd\trunctext[3][\TruncateMarker]{% do nothing if width of #3 is less than #2
+ \begingroup
+ \hbadness\maxdimen\hfuzz\vsize
+ \setbox\z@=\hbox to\dimexpr#2\relax{\ignorespaces#3\unskip}%
+ \ifnum\badness>\@M
+ \def\next{\truncate[{#1}]{#2}{#3}}%
+ \else \def\next{#3}%
+ \fi
+ \expandafter\endgroup\next
+}% \trunctext
+\newrobustcmd\htruncadjust[1]{\@testopt
+ {\itf@htruncadjust{#1}}{}%
+}% \htruncadjust
+\long\def\itf@htruncadjust#1[#2]#3{% #1=total width, #2=[x_1,...,x_n], #3=text_1,...,text_n
+ \begingroup
+ \let\itf@trunc@width\@empty
+ \let\itf@istruncated\@gobble % to remove the first comma
+ \let\the@dimen\relax
+ \count@\z@ \dimen@\z@
+ \ifblank{#2}% no optional [x_1,...,x_n] parameters
+ {%
+ \@for\x:=#3\do{%
+ \advance \count@ \@ne
+ \setbox\z@=\hbox{\ignorespaces\x\unskip}%
+ \dimen\count@ = \wd\z@
+ \toks\count@\expandafter{\the\dimen\count@}%
+ \advance\dimen@ \dimen\count@}%
+ }
+ {%
+ \@for\x:=#2\do{%
+ \advance \count@ \@ne
+ \toks\count@\expandafter{\x\p@}%
+ \advance\dimen@ \x\p@
+ \dimen\count@ -\@ne\p@}%
+ }%
+ \advance\count@\@ne \dimendef\itf@freespace=\count@
+ \advance\count@\@ne \dimendef\itf@tempdim=\count@
+ \advance\count@\@ne \dimendef\itf@sum=\count@
+ \count@\z@ %%dimen0=\the\dimen@\quad\number\dimen@\par
+ \itf@freespace\z@ % free space left when w_i < x_i/sum(x_i) * total
+ \@for\x:=#3\do{%
+ \advance \count@ \@ne
+ \ifdim \dimen\count@<\z@ % not measured before
+ \setbox\z@=\hbox{\ignorespaces\x\unskip}%
+ \dimen\count@ = \wd\z@
+ \fi
+ \itf@tempdim = \itf@scaledimen{#1}*\the\toks\count@/\dimen@\relax
+ \ifdim \dimen\count@ > \itf@tempdim
+ \dimen\count@ = \itf@tempdim
+ \edef\itf@istruncated{\itf@istruncated,\the\count@}%
+ \advance\itf@sum by\the\toks\count@
+ \else
+ \advance\itf@freespace \itf@tempdim
+ \advance\itf@freespace -\dimen\count@
+ \fi
+ \edef\itf@trunc@width{\itf@trunc@width\the\count@{\the@dimen\the\count@}}%
+ }%
+%% Free space=\the\itf@freespace\par
+ \ifdim\itf@freespace > \z@ % reinsert free space proportionally
+ \ifx\itf@istruncated\@gobble\else
+ \@for\x:=\itf@istruncated\do{%
+ \advance\dimen\x by\itf@scaledimen\itf@freespace*\the\toks\x/\itf@sum\relax
+ }%
+ \fi\fi
+ \def\the@dimen{\the\dimen}%
+ \edef\itf@trunc@width{\itf@trunc@width}%
+ \expandafter\endgroup
+ \expandafter\def
+ \expandafter\itf@trunc@width
+ \expandafter{\itf@trunc@width}%
+%% total=\the\dimexpr#1\relax
+}% \itf@htruncadjust
+\def\itf@scalefactor#1#2{\strip@pt\dimexpr#1*65536/\number#2\relax}
+\def\itf@scaledimen#1*#2/#3\relax{%
+ \dimexpr\itf@scalefactor{#2}{#3}\dimexpr#1\relax\relax
+}% \itf@scaledimen
+\newcommand*\htruncwidth[1]{% purely expandable
+ \expandafter\itf@htruncwidth\itf@trunc@width\relax\relax\@nnil{#1}%
+}% \htruncwidth
+\def\itf@htruncwidth#1#2#3\@nnil#4{%
+ \ifx\relax#1\itf@trunc@nosuchwidth{#4}%
+ \else\ifnum#1=#4
+ #2%
+ \else
+ \itf@htruncwidth#3\@nnil{#4}%
+ \fi\fi
+}% \itf@htruncwidth
+\def\itf@trunc@nosuchwidth#1{%
+ \PackageError{interfaces-truncate}
+ {You requested the width for text nr#1
+ \MessageBreak but there is no such text
+ \MessageBreak Therefore no such width!}\@ehd
+}% \itf@trunc@nosuchwidth
+\endinput
+%%
+%% End of file `interfaces-truncate.sty'.