diff options
Diffstat (limited to 'macros/luatex/latex/lualatex-truncate')
-rw-r--r-- | macros/luatex/latex/lualatex-truncate/README.md | 36 | ||||
-rw-r--r-- | macros/luatex/latex/lualatex-truncate/lualatex-truncate-doc.dtx | 262 | ||||
-rw-r--r-- | macros/luatex/latex/lualatex-truncate/lualatex-truncate-doc.pdf | bin | 0 -> 63410 bytes | |||
-rw-r--r-- | macros/luatex/latex/lualatex-truncate/lualatex-truncate.dtx | 166 | ||||
-rw-r--r-- | macros/luatex/latex/lualatex-truncate/lualatex-truncate.ins | 41 |
5 files changed, 505 insertions, 0 deletions
diff --git a/macros/luatex/latex/lualatex-truncate/README.md b/macros/luatex/latex/lualatex-truncate/README.md new file mode 100644 index 0000000000..53de8f0486 --- /dev/null +++ b/macros/luatex/latex/lualatex-truncate/README.md @@ -0,0 +1,36 @@ +# lualatex-truncate +This package provides a wrapper for the [`truncate` package](https://ctan.org/pkg/truncate) package, +which fixes issues related to LuaTeX's hyphenation algorithm. + + +### Dependencies +`lualatex-truncate` depends on these packages: +`iftex`, `letltxmacro` and `truncate` + + +### Installation +Extract the *package* file first: + + 1. Run LaTeX over the file `lualatex-truncate.ins` + 2. Move the resulting `.sty` file to `TEXMF/tex/lualatex/lualatex-truncate/` + +Then, you can compile the *documentation* yourself by executing + + lualatex lualatex-truncate-doc.dtx + makeindex -s gind.ist lualatex-truncate-doc.idx + makeindex -s gglo.ist -o lualatex-truncate-doc.gls lualatex-truncate-doc.glo + lualatex lualatex-truncate-doc.dtx + lualatex lualatex-truncate-doc.dtx + + +or just use the precompiled documentation shipped with the source files. +In both cases, copy the files `lualatex-truncate-doc.pdf` and `README.md` to `TEXMF/doc/lualatex/lualatex-truncate/`. + + + +### License +LPPL 1.3c or any later version (available at [http://www.latex-project.org/lppl.txt](http://www.latex-project.org/lppl.txt "Show the current version of the LPPL")) + +This package is *maintained*. Current maintainer is [Sebastian Friedl](mailto:sfr682k@t-online.de). + + diff --git a/macros/luatex/latex/lualatex-truncate/lualatex-truncate-doc.dtx b/macros/luatex/latex/lualatex-truncate/lualatex-truncate-doc.dtx new file mode 100644 index 0000000000..38fb37afa4 --- /dev/null +++ b/macros/luatex/latex/lualatex-truncate/lualatex-truncate-doc.dtx @@ -0,0 +1,262 @@ +%\iffalse +%% Doc-Source file to use with LaTeX2e +%% Copyright (C) 2018 Sebastian Friedl +%% +%% This work is subject to the LaTeX Project Public License, Version 1.3c or -- at +%% your option -- any later version of this license. +%% The work consists of the files lualatex-truncate.dtx, lualatex-truncate.ins, +%% lualatex-truncate-doc.dtx and the derived file lualatex-truncate.sty +%% +%% This work has the LPPL maintenance status ‘maintained’. +%% Current maintainer of the work is Sebastian Friedl. +%% +%% ------------------------------------------------------------------------------------------- +%% +%% A LuaLaTeX wrapper for the truncate package +%% +%% ------------------------------------------------------------------------------------------- +%% +%% Please report bugs and other problems as well as suggestions for improvements +%% to my email address (sfr682k@t-online.de). +%% +%% ------------------------------------------------------------------------------------------- +%\fi + +% !TeX spellcheck=en_US + +\documentclass[11pt]{ltxdoc} + +\usepackage{iftex} +\RequireLuaTeX + +\usepackage[no-math]{fontspec} +\usepackage{polyglossia} +\setdefaultlanguage{english} +\usepackage[english]{selnolig} + +\usepackage{array} +\usepackage{csquotes} +\usepackage{hologo} +\usepackage{multicol} +\usepackage{xcolor} + + +\parindent0pt + +\usepackage[erewhon]{newtxmath} +\setmainfont{erewhon} +\setsansfont[Scale=MatchLowercase]{Source Sans Pro} +\setmonofont[Scale=MatchLowercase]{Hack} + +\usepackage[a4paper,left=4.50cm,right=2.75cm,top=3.25cm,bottom=2.75cm,nohead]{geometry} + + +\hyphenation{mo-dify-ing} + +\def\Lua{\textsf{Lua}\ignorespaces} + +\usepackage[unicode, pdfborder={0 0 0}, linktoc=all, hyperindex=false]{hyperref} +\usepackage{bookmark}% fix PDF bookmark issues caused by hyperref + + + +\MakeShortVerb{"} +\CheckSum{55} + +\renewcommand*{\usage}[1]{\hyperpage{#1}} +\renewcommand*{\main}[1]{\hyperpage{#1}} + +\newcommand*{\sty}[1]{\textsf{#1}} +\newcommand*{\opt}[1]{\texttt{#1}\index{#1=\texttt{#1}~~option|main}} + +\def\param#1{\textit{\rmfamily\ensuremath{\langle}#1\ensuremath{\rangle}}} +\def\DescribeOption#1{\marginpar{\raggedleft\PrintDescribeMacro{#1}}} + + +\PageIndex +\RecordChanges + + + + +\title{The \sty{lualatex-truncate} package \\ {\large\url{https://gitlab.com/SFr682k/lualatex-truncate}}} +\author{Sebastian Friedl \\ \href{mailto:sfr682k@t-online.de}{\ttfamily sfr682k@t-online.de}} +\date{2018/08/22 (v1.1)} + +\hypersetup{pdftitle={The lualatex-truncate package},pdfauthor={Sebastian Friedl}} + +\begin{document} + \maketitle + \thispagestyle{empty} + + + + + \medskip + \begin{abstract}\centering + \hspace{-1.5em}% + This package provides a wrapper for using the \sty{truncate} package\footnote{available at \url{https://ctan.org/pkg/truncate}}, + thus fixing issues related to \hologo{LuaTeX}'s hyphenation mechanism. + \end{abstract} + + + + \tableofcontents + + + + + \clearpage + + + \subsection*{Dependencies and other requirements} + \addcontentsline{toc}{subsection}{Dependencies and other requirements} + \sty{lualatex-truncate} requires \LaTeXe\ and depends on the following packages: + \begin{multicols}{3}\sffamily\centering + if\kern0pt tex \\ letltxmacro \\ truncate + \end{multicols} + + + \subsection*{Installation} + \addcontentsline{toc}{subsection}{Installation} + Extract the \textit{package} file first: + \begin{enumerate} + \item Run \LaTeX\ over the file "lualatex-truncate.ins" + \item Move the resulting ".sty" file to "TEXMF/tex/lualatex/lualatex-truncate/" + \end{enumerate} + + Then, you can compile the \textit{documentation} yourself by executing \\[\smallskipamount] + "lualatex lualatex-truncate-doc.dtx" \\ + "makeindex -s gind.ist lualatex-truncate-doc.idx" \\ + "makeindex -s gglo.ist -o lualatex-truncate-doc.gls lualatex-truncate-doc.glo" \\ + "lualatex lualatex-truncate-doc.dtx" \\ + "lualatex lualatex-truncate-doc.dtx" + + \smallskip + or just use the precompiled documentation shipped with the source files. \\ + In both cases, copy the files "lualatex-truncate-doc.pdf" and "README.md" to \\ + "TEXMF/doc/lualatex/lualatex-truncate/" + + + \subsection*{License} + \addcontentsline{toc}{subsection}{License} + \textcopyright\ 2018 Sebastian Friedl + + \smallskip + This work may be distributed and/or modified under the conditions of the \LaTeX\ Project Public License, either version 1.3c of this license or (at your option) any later version. + + \smallskip + The latest version of this license is available at \url{http://www.latex-project.org/lppl.txt} and version 1.3c or later is part of all distributions of \LaTeX\ version 2008-05-04 or later. + + \smallskip + This work has the LPPL maintenace status \enquote*{maintained}. \\ + Current maintainer of this work is Sebastian Friedl. + + \medskip + This work consists of the following files: + \begin{itemize} \itemsep 0pt + \item "lualatex-truncate.sty", + \item "lualatex-truncate.ins", + \item "lualatex-truncate-doc.dtx" and + \item the derived file "lualatex-truncate.sty" + \end{itemize} + + + + + + % DOCUMENTATION PART ---------------------------------------------------------------------- + \clearpage + \part{The documentation} + \begin{center} + \colorbox{red!75!black}{\colorbox{white}{\begin{minipage}{.95\textwidth} + \textbf{\color{red!75!black}\large Don't load the \sty{truncate} package in your preamble!!} + + \medskip + This task is already done for you by \sty{lualatex-truncate}! + + \smallskip + Also, all package options stated in this documentation are meant to be passed to \sty{lualatex-truncate}; otherwise they can't be processed by the wrapper mechanism. + \end{minipage}}} + \end{center} + + + \subsection*{Truncating text to a given width% + \footnote{This section has been adapted from \sty{truncate}'s documentation: \\ + \indent\indent\url{http://mirrors.ctan.org/macros/latex/contrib/truncate/truncate.pdf}}} + \addcontentsline{toc}{subsection}{Truncating text to a given width} + + \leavevmode% + \DescribeOption{\truncate}% + The package defines a command "\truncate["\param{marker}"]{"\param{width}"}{"\param{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{[\param{marker}]} parameter is omitted, is "\,\dots". You can change this default by redefining \DescribeMacro{\TruncateMarker}"\TruncateMarker" (e.g.~"\renewcommand\TruncateMarker{\dots}"). + + \medskip + Normally, the text (no matter whether truncated or not) is printed flushed-left in a box with exactly the width specified. The package option \DescribeOption{fit}\opt{fit} causes the output text to have its natural width, up to a maximum of the specified width. + + \medskip + Normally, the text won't be truncated in the middle of a word, nor at a space specified with a tie ("~"). For example: + \begin{quote} + "\truncate{122pt}{This text has been~truncated}" + \end{quote} + gives + \begin{quote} + \enquote{\hbox to 122pt {This text has\,\dots\hfill}} + \end{quote} + + \medskip + You can use one of the package options \DescribeOption{hyphenate}\opt{hyphenate}, \DescribeOption{breakwords}\opt{breakwords} or \DescribeOption{breakall}\opt{breakall} to allow truncating in the middle of words. The first two only truncate at hyphenation points; with the only difference that \opt{breakwords} suppresses the hyphen character. + On the other hand, \opt{breakall} allows truncation at any character. For example: + \begin{quote} + "\truncate{122pt}{This text has been~truncated}" + \end{quote} + gives + \begin{quote} + \begin{tabular}{l@{\quad}l} + \enquote{\hbox to 122pt {This text has been trun-\,\dots\hfill}} & (package option \texttt{hyphenate}) \\ + \enquote{\hbox to 122pt {This text has been trun\,\dots~\hfill}} & (package option \texttt{breakwords}) \\ + \enquote{\hbox to 122pt {This text has been trunc\,\dots\hfill}} & (package option \texttt{breakall}) + \end{tabular} + \end{quote} + + [All of these options work through (Lua)\TeX's hyphenation mechanism.] + + + \subsection*{Known limitations} + \addcontentsline{toc}{subsection}{Known limitations} + \begin{itemize} + \item + \sty{lualatex-truncate} provides a \textit{wrapper} fixing \hologo{LuaTeX}-related \enquote{glitches} in the \sty{truncate} package. + It doesn't (and won't) fix any bugs or \enquote{undocumented features} introduced by the \sty{truncate} package itself. + \end{itemize} + + + + + + + + + % Start determining the checksum from here + \StopEventually{% + \clearpage + \phantomsection + \addcontentsline{toc}{part}{Index}% + \PrintChanges + \setcounter{IndexColumns}{2} + \IndexPrologue{\section*{Index}} + \PrintIndex} + + + + \vspace{3\bigskipamount} + \part{The package code} + \CodelineNumbered + \DocInput{lualatex-truncate.dtx} + + + \Finale +\end{document} + diff --git a/macros/luatex/latex/lualatex-truncate/lualatex-truncate-doc.pdf b/macros/luatex/latex/lualatex-truncate/lualatex-truncate-doc.pdf Binary files differnew file mode 100644 index 0000000000..67dd999e19 --- /dev/null +++ b/macros/luatex/latex/lualatex-truncate/lualatex-truncate-doc.pdf diff --git a/macros/luatex/latex/lualatex-truncate/lualatex-truncate.dtx b/macros/luatex/latex/lualatex-truncate/lualatex-truncate.dtx new file mode 100644 index 0000000000..06d035702a --- /dev/null +++ b/macros/luatex/latex/lualatex-truncate/lualatex-truncate.dtx @@ -0,0 +1,166 @@ +%\iffalse +%<*package> +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +%</package> +%\fi +%\iffalse +% Doc-Source file to use with LaTeX2e +% Copyright (C) 2018 Sebastian Friedl +% +% This work is subject to the LaTeX Project Public License, Version 1.3c or -- at +% your option -- any later version of this license. +% The work consists of the files lualatex-truncate.dtx, lualatex-truncate.ins, +% lualatex-truncate-doc.dtx and the derived file lualatex-truncate.sty +% +% This work has the LPPL maintenance status 'maintained'. +% Current maintainer of the work is Sebastian Friedl. +%\fi +% +% +% +% \changes{1.0}{2018/06/03}{Initial release} +% \changes{1.1}{2018/08/22}{\textsc{\bfseries Bugfix:} visible hyphen char with \texttt{breakall} option and non-english language} +% +% \subsubsection*{Initialization} +% Identify the package and require \LaTeXe: +% \begin{macrocode} +\ProvidesPackage{lualatex-truncate}% + [2018/08/22 v1.1 LuaLaTeX wrapper for the truncate package] +\NeedsTeXFormat{LaTeX2e} +% \end{macrocode} +% +% +% +% \subsubsection*{Internal variables} +% This variable is used to remember whether messing with the hyphen char is required: +% \begin{macrocode} +\newif\if@lualtxtruncate@hackhyphen +\@lualtxtruncate@hackhyphenfalse +% \end{macrocode} +% +% Also, enable remembering whether the \opt{breakall} option has been used: +% \begin{macrocode} +\newif\if@lualtxtruncate@breakall +\@lualtxtruncate@breakallfalse +% \end{macrocode} +% +% +% +% +% \subsubsection*{Package options} +% The \opt{breakwords} and \opt{breakall} options require the hyphanation character to be hidden. +% Therefore, we remember to \enquote{hack} the hyphen character before passing these options +% to the \enquote{original} \sty{truncate} package: +% \begin{macrocode} +\DeclareOption{breakwords}{% + \@lualtxtruncate@hackhyphentrue% + \PassOptionsToPackage{breakwords}{truncate}} +% \end{macrocode} +% +% In case of the \opt{breakall} option, we also need to remember the option's usage: +% \begin{macrocode} +\DeclareOption{breakall}{% + \@lualtxtruncate@breakalltrue% + \@lualtxtruncate@hackhyphentrue% + \PassOptionsToPackage{breakall}{truncate}} +% \end{macrocode} +% +% \smallskip +% Pass all other options (i.e. \opt{hyphenate} and \opt{fit}) directly to the \sty{truncate} package: +% \begin{macrocode} +\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{truncate}} +% \end{macrocode} +% +% \smallskip +% Process all options passed to \sty{lualatex-truncate}: +% \begin{macrocode} +\ProcessOptions +% \end{macrocode} +% +% +% +% \subsubsection*{Load the \sty{truncate} package} +% Require the \sty{truncate} package. All package options have already been passed on. \\ +% If \sty{truncate} has been loaded already, a error message is printed to the log. +% \begin{macrocode} +\@ifpackageloaded{truncate}{% + \PackageError{lualatex-truncate}% + {Don't load the truncate package when using lualatex-truncate!}% + {Don't load the truncate package and pass all package options + to lualatex-truncate! Otherwise, the wrapper mechanism won't + be able to understand what you want.}% +}{\RequirePackage{truncate}} +% \end{macrocode} +% +% +% +% \subsubsection*{If the document is not compiled via \hologo{LuaLaTeX}\dots} +% Don't wrap anything if the document isn't compiled by \hologo{LuaLaTeX}: +% \begin{macrocode} +\RequirePackage{iftex} +\ifLuaTeX\else% + \PackageWarningNoLine{lualatex-truncate}% + {Whoops! You don't want to use LuaLaTeX?}% + \endinput% +\fi% +% \end{macrocode} +% +% +% +% \subsubsection*{Constructing the wrapper} +% \begin{macro}{\lualtxtruncate@truncate} +% Remember the original "\truncate" command's definition. +% Since "\truncate" provides an optional argument, "\LetLtxMacro" has to be used +% instead of the primitive "\let" command: +% \begin{macrocode} +\RequirePackage{letltxmacro} +\LetLtxMacro\lualtxtruncate@truncate\truncate +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\truncate} +% \changes{1.1}{2018/08/22}{Remember previous hyphenation character} +% Construct the wrapper by redefining the "\truncate" command +% and -- if necessary -- modifying "\prehyphenchar". \\ +% "\prehyphenchar"'s value is stored inside the counter +% "\lualtxtruncate@tmp". Also, the current language must be set to US english, +% if the \opt{breakall} option has been used. +% \begin{macrocode} +\renewcommand{\truncate}[3][\TruncateMarker]{{% two braces -> scope changes + \if@lualtxtruncate@breakall% + \language\z@% force US english + \fi% + \newcount\lualtxtruncate@tmp% + \lualtxtruncate@tmp=\the\prehyphenchar% remember current hyphen char + \if@lualtxtruncate@hackhyphen% + \prehyphenchar=0% invisible hyphen + \fi% + \lualtxtruncate@truncate[#1]{#2}{#3}% run the original \truncate macro + \if@lualtxtruncate@hackhyphen% + \prehyphenchar=\the\lualtxtruncate@tmp% restore hyphen + \fi% +}} +% \end{macrocode} +% \end{macro} +% +% +% +% \subsubsection*{Famous last words} +% Enough code for this package. "\endinput". +% \begin{macrocode} +\endinput +% \end{macrocode} diff --git a/macros/luatex/latex/lualatex-truncate/lualatex-truncate.ins b/macros/luatex/latex/lualatex-truncate/lualatex-truncate.ins new file mode 100644 index 0000000000..696eeca771 --- /dev/null +++ b/macros/luatex/latex/lualatex-truncate/lualatex-truncate.ins @@ -0,0 +1,41 @@ +\input docstrip + +\preamble + lualatex-truncate.dtx + Copyright 2018 Sebastian Friedl + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either version 1.3c + of this license of (at your option) any later version. + The latest version of this license is in + http://www.latex-project.org/lppl.txt + and version 1.3c or later is part of all distributions of LaTeX + version 2008/05/04 or later. + + This work has the LPPL maintenance status 'maintained'. + Current maintainer of the work is Sebastian Friedl + + This work consists of the files lualatex-truncate.dtx, lualatex-truncate.ins, + lualatex-truncate-doc.dtx and the derived file lualatex-truncate.sty + +\endpreamble + +\askforoverwritefalse + + + + +\generate +{% + \file + {lualatex-truncate.sty}% + {% + \usepreamble\defaultpreamble + \usepostamble\defaultpostamble + \from{lualatex-truncate.dtx}{lualatex-truncate.sty,package}% + }% +} + + +\endbatchfile + |