From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/truncate/miscdoc.sty | 115 +++++++++++++++++++++ macros/latex/contrib/truncate/truncate.pdf | Bin 0 -> 161089 bytes macros/latex/contrib/truncate/truncate.sty | 158 +++++++++++++++++++++++++++++ macros/latex/contrib/truncate/truncate.tex | 57 +++++++++++ 4 files changed, 330 insertions(+) create mode 100644 macros/latex/contrib/truncate/miscdoc.sty create mode 100644 macros/latex/contrib/truncate/truncate.pdf create mode 100644 macros/latex/contrib/truncate/truncate.sty create mode 100644 macros/latex/contrib/truncate/truncate.tex (limited to 'macros/latex/contrib/truncate') diff --git a/macros/latex/contrib/truncate/miscdoc.sty b/macros/latex/contrib/truncate/miscdoc.sty new file mode 100644 index 0000000000..da1f2a5fdb --- /dev/null +++ b/macros/latex/contrib/truncate/miscdoc.sty @@ -0,0 +1,115 @@ +\ProvidesPackage{miscdoc}[2010/01/20 v1.2 documentation macros misc latex pkgs] + +% miscdoc.sty +% Copyright 2010 Robin Fairbairns +% +% 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 +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Robin Fairbairns. +% +% This work consists of the file miscdoc.sty (only) + +\setcounter{errorcontextlines}{1274} + +% The package arose from a small exercise to document packages whose +% previous documentation consisted solely of comments in the package files. +% The macros here defined are lifted from the author's faq.sty +% (written for the UK TeX FAQ, CTAN:help/uk-tex-faq) or are inspired +% by others' work (credited where the author is known) ... except +% where they came as a flash of inspiration while actually writing the +% documentation. + +% this option suggested by Heiko Oberdiek, 2010-01-29 +\DeclareOption{hyper}{% + \AtEndOfPackage{% + \RequirePackage[pdfusetitle]{hyperref} + \RequirePackage{bookmark} + \bookmarksetup{numbered,open,openlevel=1} + } +} +\ProcessOptions\relax + +% note: T1 encoding assumed +\usepackage{lmodern} +\usepackage[T1]{fontenc} +\usepackage{booktabs} + +% from faq.sty +\newcommand\cs[1]{\texttt{\char`\\#1}} +\let\csx\cs +\def\bsbs{\cs{\char`\\}} + +% \cmdinvoke\cs +% \cs typeset as above +% may consist of optional or mandatory arguments; +% +% the `arguments' are simply typesett \texttt, as yet -- if something +% fancier is needed, there's a bunch of code needs rewriting here... +\DeclareRobustCommand\cmdinvoke{\@ifstar + {\let\@tempa\emph\@scmdinvoke}% + {\let\@tempa\relax\@scmdinvoke}% +} +\def\@scmdinvoke#1{\texttt{\symbol{92}#1}% + \futurelet\@let@token\@cmdinvoke +} +\def\@cmdinvoke{\ifx\@let@token\bgroup + \let\@tempb\@cmdinvoke@lbrace + \else + \ifx\@let@token[% ] + \let\@tempb\@cmdinvoke@lbrack + \else + \ifx\@let@token(% ) + \let\@tempb\@cmdinvoke@lparen + \else + \let\@tempb\@empty + \fi + \fi + \fi + \@tempb +} +\def\@cmdinvoke@lbrace#1{\penalty0\hskip0pt\relax + \texttt{\symbol{123}\@tempa{#1}\symbol{125}}% + \futurelet\@let@token\@cmdinvoke +} +\def\@cmdinvoke@lbrack[#1]{\penalty-150\hskip0pt\relax + \texttt{[\@tempa{#1}]}% + \futurelet\@let@token\@cmdinvoke +} +\def\@cmdinvoke@lparen(#1){\penalty-150\hskip0pt\relax + \texttt{(\@tempa{#1})}% + \futurelet\@let@token\@cmdinvoke +} +% and extension -- versions that take a single extra (delimiter) +% argument, such as \delcmdinvoke{lscrunge}( ... awful syntax, but... +\DeclareRobustCommand\delcmdinvoke{\@ifstar + {\let\@tempa\emph\@sdelcmdinvoke}% + {\let\@tempa\relax\@sdelcmdinvoke}% +} +\def\@sdelcmdinvoke#1#2{\texttt{\symbol{92}#1#2}% + \futurelet\@let@token\@cmdinvoke +} + +% sui generis +\newcommand\newitem{\par\addvspace{1ex}\noindent} + +% inspired by doc.sty in latex distribution +\newcommand\meta[1]{\ensuremath{\langle}\emph{#1}\ensuremath{\rangle}} + +% meaningful names, as in faq.sty +\newcommand\environment[1]{\texttt{#1}} +\newcommand\pkgoption[1]{\texttt{#1}} +\newcommand\extension[1]{\texttt{.#1}} +\newcommand\Package[1]{\textsf{#1}} +\def\option{\@ifnextchar[\@optionb\@option}% ] +\def\@optionb[#1]{{\normalfont\ttfamily[#1]}} +\def\@option#1{\texttt{#1}} + +\let\FontName\textsf \ No newline at end of file diff --git a/macros/latex/contrib/truncate/truncate.pdf b/macros/latex/contrib/truncate/truncate.pdf new file mode 100644 index 0000000000..f27ecf8690 Binary files /dev/null and b/macros/latex/contrib/truncate/truncate.pdf differ diff --git a/macros/latex/contrib/truncate/truncate.sty b/macros/latex/contrib/truncate/truncate.sty new file mode 100644 index 0000000000..a4f0ed840c --- /dev/null +++ b/macros/latex/contrib/truncate/truncate.sty @@ -0,0 +1,158 @@ +% truncate.sty ver 3.6 20-Aug-2001 Donald Arseneau +% This LaTeX program is released to the public domain. +% +% Truncate text to a specified width: \truncate [marker]{width}{text} +% +% If the text is too wide to fit in the specified width, then it is +% truncated, and a continuation marker is shown at the end. The default +% marker, used when the optional "[marker]" parameter is omitted, is +% "\,\dots". You can change this default by redefining "\TruncateMarker" +% ("\renewcommand{\TruncateMarker}{}"). +% +% Normally, the text (whether truncated or not) is printed flush-left +% in a box with exactly the width specified. The package option "[fit]" +% ("\usepackage[fit]{truncate}") causes the output text to have its +% natural width, up to a maximum of the specified width. +% +% The text will not normally be truncated in the middle of a word, +% nor at a space specified by the tie "~". For example: +% +% "\truncate{122pt}{This text has been~truncated}" +% gives +% "This text has... " +% +% You can give one of the package options "[hyphenate]", "[breakwords]", +% or "[breakall]" to allow breaking in the middle of words. The first +% two only truncate at hyphenation points; with the difference being that +% "breakwords" suppresses the hyphen character. On the other hand, +% "breakall" allows truncation at any character. For example: +% +% "\truncate{122pt}{This text has been~truncated}" +% gives +% "This text has been trun-..." (hyphenate) +% "This text has been trun... " (breakwords) +% "This text has been trunc..." (breakall) +% +% (All of these options work through TeX's hyphenation mechanism.) +% +\ProvidesPackage{truncate}[2001/08/20 \space ver 3.6] +% +% [breakwords] allows hyphenation but with invisible hyphen characters +\DeclareOption{breakwords}{% + \let\@Trunc@DoSelect\relax + \expandafter\chardef\csname \string\@TruncHyph T1\endcsname 23 + \expandafter\chardef\csname \string\@TruncHyph OT1\endcsname 223 + \expandafter\chardef\csname \string\@TruncHyph LY1\endcsname 0 + \def\@Trunc@Post{\hyphenpenalty\tw@ \exhyphenpenalty\tw@ + \doublehyphendemerits\z@ \finalhyphendemerits\z@ + \the\@Trunc@RestHyph % set invisible hyphenchars for all fonts used + }} +% +% [breakall] is like breakwords, but all characters are treated like +% the letter "c"; the default language 0 patterns allow hyphenation +% c-c-c-c-c-c-c-c-c. This means we don't need special patterns! +\DeclareOption{breakall}{\ExecuteOptions{breakwords}% + \expandafter\def\expandafter\@Trunc@Post\expandafter{\@Trunc@Post + \@tempcnta\z@ \chardef\c`\c % in knuth patterns, c allows hyphens + \loop \lccode\@tempcnta\c \advance\@tempcnta\@ne + \ifnum\@tempcnta<\@cclvi \repeat}% + \def\@Trunc@Pre{% force US english + \lefthyphenmin\@ne \righthyphenmin\@ne + \doublehyphendemerits\language + \language\z@ % default English language + \let\language\doublehyphendemerits + \uchyph\@ne + }} +% +% [hyphenate] ordinary hyphenation for breakpoints +\DeclareOption{hyphenate}{% takes precedence over breakwords + \def\@Trunc@Post{\hyphenpenalty\sixt@@n}\let\@Trunc@Pre\relax} +% +% [fit] use true size of truncated text, not requested size. +\DeclareOption{fit}{\def\@Trunc@Rebox{% + \setbox\z@\hbox{\unhbox\z@\unskip\unskip\@tempa}% + \ifdim\wd\z@>\hsize \hbox to\hsize{\unhbox\z@}\else \box\z@ \fi}} +% +% Defaults: +\let\@Trunc@Pre\@empty +\def\@Trunc@Post{\hyphenpenalty\@M} +\def\@Trunc@Rebox{\hbox to\hsize{\unhbox\z@\unskip\unskip\@tempa\hfil}} +\let\@Trunc@DoSelect\@empty + +\ProcessOptions\relax + +\providecommand{\TruncateMarker}{\,\dots} + +\newcommand{\truncate}[3][\TruncateMarker]{% #1=marker #2=width #3=text + \parbox[b]{#2}{\tolerance9999 \emergencystretch .216\hsize + \vbadness\maxdimen \vfuzz\vsize % no overfull warnings + \hbadness\maxdimen \hfuzz\vsize + % set up hyphenchar switching for all fonts used. + \edef\@tempb{\the\@Trunc@RestHyph}% save whole stack + \global\@Trunc@RestHyph{}% + \ifx\@Trunc@DoSelect\relax + \let\@Trunc@DoSelect\selectfont + \def\selectfont{\@Trunc@DoSelect\@Trunc@SaveHChar}% + \fi + \@Trunc@SaveHChar % do it for current font + \setbox\z@\vbox\bgroup + % First set text in a hbox to see if it fits. + \setbox\z@\@@line{\ignorespaces #3\unskip\hfil}% + \ifnum\badness>\@M % text does not fit + \settowidth\rightskip{#1}% + \advance\rightskip \z@\@plus\p@ + \parfillskip-\@ne\rightskip \@plus\@ne fil + \parshape \tw@ \z@\hsize \z@\maxdimen \linepenalty60 + \tracinglostchars\z@ + %% \let\par\relax -- don't do this because \vskip causes infinite loop + \@Trunc@Pre % must set language before paragraph + \noindent \vadjust{\penalty-\@MM}% for splitting off first line + \nobreak\hskip\z@skip % allow first word hyphenation + \ignorespaces #3% the text + \pretolerance\hyphenpenalty \@Trunc@Post % set up `hyphenation' + \@@par + \ifnum\prevgraf>\@ne + \egroup \def\@tempa{#1}% use truncation marker + \else + \egroup \let\@tempa\@empty% no linebreak, so all text fits; no marker + \fi + \else + \box\z@ \egroup \let\@tempa\@empty + \fi + \setbox\@tempboxa\vsplit\z@ to\z@ \unvbox\@tempboxa + \unskip\unpenalty\unpenalty + \setbox\z@\lastbox + \nointerlineskip + \hfuzz\p@ + \@Trunc@Rebox + \let\@Trunc@HC\@firstofone \the\@Trunc@RestHyph % restore hyphenchars + \global\@Trunc@RestHyph\expandafter{\@tempb}% restore the stack itself + }} +% (Note that the text may be proessed twice. I could avoid that +% if there are problems with global counters etc.) + +% we save (implicit global) hyphenchar settings for each font on a +% manual stack -- the token register \@Trunc@RestHyph -- before changing +% them. We execute \@Trunc@RestHyph to set them to the invisible +% characters and then again to restore them. (I can't imagine this +% will ever be required.) +\newtoks\@Trunc@RestHyph +\global\@Trunc@RestHyph{} +% +\def\@Trunc@SaveHChar{\begingroup + \edef\@tempa{% + \hyphenchar\the\font=\noexpand\@Trunc@HC{\the\hyphenchar\font}\relax + \the\@Trunc@RestHyph}% + \global\@Trunc@RestHyph\expandafter{\@tempa}% +% \hyphenchar\font\z@ + \endgroup} +% +% select an invisible character for hyphenation. Use \textcompwordmark, if +% any; use selected numbers for certain encodings (OT1 uses a *missing* +% character); use a space otherwise. +\def\@Trunc@HC#1{% + \@ifundefined{\f@encoding\string\textcompwordmark}{% + \@ifundefined{\string\@TruncHyph\f@encoding}% + {32}% If no appropriate character, guess space character may be blank + {\csname \string\@TruncHyph\f@encoding\endcsname}% + }{\csname\f@encoding\string\textcompwordmark\endcsname}}% diff --git a/macros/latex/contrib/truncate/truncate.tex b/macros/latex/contrib/truncate/truncate.tex new file mode 100644 index 0000000000..412d183553 --- /dev/null +++ b/macros/latex/contrib/truncate/truncate.tex @@ -0,0 +1,57 @@ +\documentclass[a4paper]{article} +\usepackage[a4paper]{geometry} +\usepackage{miscdoc} +\usepackage[scaled=0.85]{luximono} +\begin{document} +\title{The \Package{truncate} package} +\author{Donald Arseneau\thanks{Documentation file assembled by Robin + Fairbairns}} +\date{August 2001, version 3.6} +\maketitle + +\section*{Truncating text to a given width} + +The package defines a command +\cmdinvoke{truncate}[\meta{marker}]{\meta{width}}{\meta{text}} + +If the text is too wide to fit in the specified width, then it is +truncated, and a continuation marker is shown at the end. The default +marker, used when the optional \texttt{[marker]} parameter is omitted, +is \cs{,}\cs{dots}. You can change this default by redefining +\cs{TruncateMarker} +(\cmdinvoke{renewcommand}{\cs{TruncateMarker}}{\dots}). + +Normally, the text (whether truncated or not) is printed flush-left +in a box with exactly the width specified. The package option +\option[fit] causes the output text to have its natural width, up to a +maximum of the specified width. + +The text will not normally be truncated in the middle of a word, +nor at a space specified by the tie (\verb|~|). For example: +\begin{quote} + \cmdinvoke{truncate}{122pt}{This text has been\string~truncated} +\end{quote} +gives +\begin{quote} + ``This text has\dots~~~~~~'' +\end{quote} + +You can give one of the package options \option[hyphenate], +\option[breakwords], or \option[breakall] to allow breaking in the +middle of words. The first two only truncate at hyphenation points; +with the difference being that \option[breakwords] suppresses the +hyphen character. On the other hand, \option{breakall} allows +truncation at any character. For example: +\begin{quote} + \cmdinvoke{truncate}{122pt}{This text has been\string~truncated} +\end{quote} +gives +\begin{quote} + \begin{tabular}{l@{\quad}l} + ``This text has been trun-...'' & (option hyphenate) \\ + ``This text has been trun...~'' & (option breakwords) \\ + ``This text has been trunc...'' & (option breakall) + \end{tabular} +\end{quote} +(All of these options work through \TeX{}'s hyphenation mechanism.) +\end{document} -- cgit v1.2.3