diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/uspace |
Initial commit
Diffstat (limited to 'macros/latex/contrib/uspace')
-rw-r--r-- | macros/latex/contrib/uspace/LICENSE | 21 | ||||
-rw-r--r-- | macros/latex/contrib/uspace/README.md | 11 | ||||
-rwxr-xr-x | macros/latex/contrib/uspace/uspace-ctanify.sh | 67 | ||||
-rw-r--r-- | macros/latex/contrib/uspace/uspace-test-lualatex.pdf | bin | 0 -> 146331 bytes | |||
-rw-r--r-- | macros/latex/contrib/uspace/uspace-test-pdflatex.pdf | bin | 0 -> 146770 bytes | |||
-rw-r--r-- | macros/latex/contrib/uspace/uspace-test-xelatex.pdf | bin | 0 -> 27383 bytes | |||
-rw-r--r-- | macros/latex/contrib/uspace/uspace-test.tex | 187 | ||||
-rw-r--r-- | macros/latex/contrib/uspace/uspace.pdf | bin | 0 -> 82555 bytes | |||
-rw-r--r-- | macros/latex/contrib/uspace/uspace.sty | 84 | ||||
-rw-r--r-- | macros/latex/contrib/uspace/uspace.tex | 139 |
10 files changed, 509 insertions, 0 deletions
diff --git a/macros/latex/contrib/uspace/LICENSE b/macros/latex/contrib/uspace/LICENSE new file mode 100644 index 0000000000..872ab4f9e1 --- /dev/null +++ b/macros/latex/contrib/uspace/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Václav Haisman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/macros/latex/contrib/uspace/README.md b/macros/latex/contrib/uspace/README.md new file mode 100644 index 0000000000..c0c07ac8af --- /dev/null +++ b/macros/latex/contrib/uspace/README.md @@ -0,0 +1,11 @@ +# project-uspace + +LaTeX package that gives meaning to various Unicode space characters. + +- License is MIT license. See `LICENSE` file. + +- Author is [Václav Haisman](mailto:vhaisman+uspace@gmail.com?subject=[uspace]) + +- Source code on GitHub + in [`wilx/project-uspace`](https://github.com/wilx/project-uspace) + repository. diff --git a/macros/latex/contrib/uspace/uspace-ctanify.sh b/macros/latex/contrib/uspace/uspace-ctanify.sh new file mode 100755 index 0000000000..8dec20e2d5 --- /dev/null +++ b/macros/latex/contrib/uspace/uspace-ctanify.sh @@ -0,0 +1,67 @@ +#!/bin/bash +set -x +set -e + +rm -f uspace.pdf || true +rm -f uspace-test.pdf || true + +latexmk -gg -pdf -jobname=uspace-test-pdflatex -interaction=nonstopmode uspace-test.tex >uspace-test-pdflatex.tex.output 2>&1 </dev/null & +latexmk -gg -xelatex -jobname=uspace-test-xelatex -interaction=nonstopmode uspace-test.tex >uspace-test-xelatex.tex.output 2>&1 </dev/null & +latexmk -gg -lualatex -jobname=uspace-test-lualatex -interaction=nonstopmode uspace-test.tex >uspace-test-lualatex.tex.output 2>&1 </dev/null & + +latexmk -gg -lualatex -interaction=nonstopmode uspace.tex >uspace.tex.output 2>&1 </dev/null & + +echo waiting for jobs to finish +wait + +echo "uspace-test-pdflatex.tex.output:" +cat uspace-test-pdflatex.tex.output + +echo "uspace-test-pdflatex.tex.output:" +cat uspace-test-xelatex.tex.output + +echo "uspace-test-pdflatex.tex.output:" +cat uspace-test-lualatex.tex.output + +echo "uspace.tex.output:" +cat uspace.tex.output + +DOCDIR=doc/latex/uspace +LATEXDIR=tex/latex/uspace + +TEMP_DIR=`mktemp -d -p "$PWD"` +read -d '' CTANIFY_MAP <<EOF || true + uspace.sty=$LATEXDIR + README.md=$DOCDIR + LICENSE=$DOCDIR + uspace-test.tex=$DOCDIR + uspace-test-pdflatex.pdf=$DOCDIR + uspace-test-xelatex.pdf=$DOCDIR + uspace-test-lualatex.pdf=$DOCDIR + uspace.tex=$DOCDIR + uspace.pdf=$DOCDIR + uspace-ctanify.sh=$DOCDIR +EOF + +echo "map:" $CTANIFY_MAP + +for entry in $CTANIFY_MAP ; do + file=${entry%=*} + #target_dir=${entry#*=} + cp -v "$file" "$TEMP_DIR" +done + +ROOT_DIR="$PWD" +( + cd "$TEMP_DIR" + setfacl -b * + chmod +rw-x * + chmod +x uspace-ctanify.sh + #ctanify --pkgname=uspace $CTANIFY_MAP + #mv -vf uspace.tar.gz "$ROOT_DIR" + tar cvvzf "$ROOT_DIR/uspace.tar.gz" . +) + +tar tvvzf uspace.tar.gz + +rm -rf "$TEMP_DIR" diff --git a/macros/latex/contrib/uspace/uspace-test-lualatex.pdf b/macros/latex/contrib/uspace/uspace-test-lualatex.pdf Binary files differnew file mode 100644 index 0000000000..3edef468b9 --- /dev/null +++ b/macros/latex/contrib/uspace/uspace-test-lualatex.pdf diff --git a/macros/latex/contrib/uspace/uspace-test-pdflatex.pdf b/macros/latex/contrib/uspace/uspace-test-pdflatex.pdf Binary files differnew file mode 100644 index 0000000000..9be669cbb4 --- /dev/null +++ b/macros/latex/contrib/uspace/uspace-test-pdflatex.pdf diff --git a/macros/latex/contrib/uspace/uspace-test-xelatex.pdf b/macros/latex/contrib/uspace/uspace-test-xelatex.pdf Binary files differnew file mode 100644 index 0000000000..f3bdc0cc1b --- /dev/null +++ b/macros/latex/contrib/uspace/uspace-test-xelatex.pdf diff --git a/macros/latex/contrib/uspace/uspace-test.tex b/macros/latex/contrib/uspace/uspace-test.tex new file mode 100644 index 0000000000..7f1af57425 --- /dev/null +++ b/macros/latex/contrib/uspace/uspace-test.tex @@ -0,0 +1,187 @@ +\documentclass{article} +\usepackage{lmodern} +\usepackage{ifluatex} +\ifnum 0\ifluatex 1\fi=1 % if LuaLaTeX +\usepackage{luatex85} +\fi +\usepackage[a6paper]{geometry} +\usepackage{parskip} +\usepackage[para,online,flushleft]{threeparttable} +\usepackage{array} +\PassOptionsToPackage{unicode}{hyperref} +\usepackage{bookmark} +\hypersetup{ + hidelinks, + breaklinks} +\urlstyle{same} % don't use monospace font for urls +\usepackage{float} +\usepackage{uspace} + + +%\setlength{\emergencystretch}{3em} % prevent overfull lines +\DeclareRobustCommand{\expl}[1]{\textsf{#1}} +\newcommand{\zwsp}{\textsc{zero width space}} +\newcommand{\nnbsp}{\textsc{narrow no-break space}} +\newcommand{\nbsp}{\textsc{non-breaking space}} +\newcommand{\shy}{\textsc{soft hyphen}} +\newcommand{\enquad}{\textsc{en quad}} +\newcommand{\enspaceC}{\textsc{en space}} +\newcommand{\emquad}{\textsc{em quad}} +\newcommand{\emspaceC}{\textsc{em space}} +\newcommand{\threePerEm}{\textsc{three-per-em space}} +\newcommand{\fourPerEm}{\textsc{four-per-em space}} +\newcommand{\sixPerEm}{\textsc{six-per-em space}} +\newcommand{\figuresp}{\textsc{figure space}} +\newcommand{\punctsp}{\textsc{punctuation space}} +\newcommand{\thinsp}{\textsc{thin space}} +\newcommand{\hairsp}{\textsc{hair space}} + +\overfullrule=0.5em + +\begin{document} + +\section{\zwsp{}} + +\expl{\LaTeX{} does not hyphenate word after solidus (forward slash) in + compounds like `input/output'. Inserting \zwsp{} after the solidus in such + compound forces \LaTeX{} to consider the compound to be two words and thus + it will use the usual line breaking algorithm for the second word of the + compound. The following few lines are testing behaviour \emph{without} + \zwsp{} inserted:} + +Here, we are---testing line breaking of `input/output' compound. + +Here, we are--testing line breaking of `input/output' compound. + +\expl{Notice how both lines cause hbox overflow because \LaTeX{} cannot find + good line break.} + +\expl{And now \emph{with} \zwsp{} inserted:} + +Here, we are---testing line breaking of `input/output' compound. + +Here, we are--testing line breaking of `input/output' compound. + +\pagebreak +\section{\nnbsp{}} + +\expl{\nnbsp{} is used, e.g., in German and Czech typography to separate + multi-part abbreviations. Here is an example with `s. r. o.', which is an + equivalent of LLC or GmbH in Czech. It should be typeset with narrow space + between letters and no line break should occur between the letters:} + +\begin{tabular}{l | p{0.75\textwidth}} + s.r.o. & \expl{without any spaces} \tabularnewline + s.~r.~o. & \expl{with usual \nbsp{} (\textasciitilde{})} \tabularnewline + s. r. o. & \expl{with \nnbsp{}} \tabularnewline +\end{tabular} + +\expl{The following sentence is showing line breaking when ordinary space is + used:} + +He invested all of his savings into Pyramid s. r. o. and lost all of it. + +\expl{And here we use \nnbsp{} for much nicer result:} + +He invested all of his savings into Pyramid s. r. o. and lost all of it. + +\pagebreak + +\section{\nbsp{}} + +\expl{Here, we are testing the use of Unicode character \nbsp{}:} + +Telephone number example for Czechia: +420 123 456 789 + +Telephone number example for Czechia: +420 123 456 789 + +\expl{The line above overflows hbox because line break cannot be inserted + between digits groups due to use of \nbsp{}.} + +\pagebreak + +\section{\shy{}} +\expl{Sometimes, text might come with words pre-hyphenated using \shy{} + character. Let's use the name `Kurremkarmerruk', name of Master Namer from + Earthsea novels by Ursula K.\ Le~Guin, as an example here. Without manually + inserted \shy{}, it will be hyphenated but it will overflow hbox slightly:} + +The name of the Master Namer is `Kurremkarmerruk'. + +\expl{Here is the same with with \shy{} inserted as follows: + Kur-rem-kar-mer-ruk.} + +The name of the Master Namer is `Kurremkarmerruk'. + +\expl{Note: I claim no correctness of the above hyphenation of the name. This + is purely just an example.} + +\pagebreak + +\section{\figuresp{} and \punctsp{}} + +\expl{\figuresp{} and \punctsp{} can be used to align numbers in tables. The + below table (partial table of Earth athmosphere constituents) does not use + either. The numbers are centered in their column.} + +\begin{figure}[H] +\centering +\begin{tabular}{l | c} + Element & ppmv \tabularnewline + \hline + Nitrogen & 780,840\tabularnewline + Oxygen & 209,460\tabularnewline + Argon & 9,340\tabularnewline + Carbon dioxide & 400 \tabularnewline + Neon & 18.18 +\end{tabular} +\end{figure} + +\expl{Below is the same table as above but with addition of \figuresp{} and + \punctsp{} to pad the numbers so that they all seem the same width to + \LaTeX{}:} + +\begin{figure}[H] +\centering +\begin{tabular}{l | c} + Element & ppmv \tabularnewline + \hline + Nitrogen & 780,840 \tabularnewline + Oxygen & 209,460 \tabularnewline + Argon & 9,340 \tabularnewline + Carbon dioxide & 400 \tabularnewline + Neon & 18.18 +\end{tabular} +\end{figure} + +\pagebreak + +\section{en, em and other spaces} + +\expl{Unicode contains several more space characters, some of which are shown in +the following table:} + +\begin{center} +\begin{threeparttable} +\begin{tabular}[c]{l | >{\raggedright}p{0.666\textwidth}} + a b c & \expl{\emspaceC{}}\tabularnewline + a b c & \expl{\emquad{} is canonically equivalent{\tnote{i} } to \emspaceC{}}\tabularnewline + a b c & \expl{\enspaceC{}}\tabularnewline + a b c & \expl{\enquad{} is canonically equivalent{\tnote{i} } to \enspaceC{}}\tabularnewline + a b c & \expl{\threePerEm{}}\tabularnewline + a b c & \expl{\fourPerEm{}}\tabularnewline + a b c & \expl{\sixPerEm{}}\tabularnewline + a b c & \expl{\figuresp{}}\tabularnewline + a b c & \expl{\punctsp{}}\tabularnewline + a b c & \expl{\thinsp{}}\tabularnewline + a b c & \expl{\hairsp{}}\tabularnewline + abc & \expl{no spaces, for comparison}\tabularnewline +\end{tabular} +\begin{tablenotes} +\item[\expl{i}] \expl{\footnotesize See \url{http://unicode.org/notes/tn5/} + for explanation of the term.} +\end{tablenotes} +\end{threeparttable} +\end{center} + +\end{document} diff --git a/macros/latex/contrib/uspace/uspace.pdf b/macros/latex/contrib/uspace/uspace.pdf Binary files differnew file mode 100644 index 0000000000..f2306c6ca0 --- /dev/null +++ b/macros/latex/contrib/uspace/uspace.pdf diff --git a/macros/latex/contrib/uspace/uspace.sty b/macros/latex/contrib/uspace/uspace.sty new file mode 100644 index 0000000000..29672d2df4 --- /dev/null +++ b/macros/latex/contrib/uspace/uspace.sty @@ -0,0 +1,84 @@ +% LaTeX package that defines meanings to several different Unicode space +% characters. +% +% © 2016 Václav Haisman +% +%% This program can be redistributed and/or modified under the terms of the +%% MIT license. See LICENSE file. +% + +\NeedsTeXFormat{LaTeX2e}[1994/06/01] + +\ProvidesPackage{uspace} +[2016/11/06 v0.04 LaTeX package that defines meanings to several different +Unicode space characters.] + +\RequirePackage{ifxetex,ifluatex} +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex +\RequirePackage[utf8]{inputenc} +\fi + +\RequirePackage{newunicodechar} + +% zero width space +\newunicodechar{}{\hspace{0pt}} + +% narrow no-break space +\newunicodechar{ }{\leavevmode\,} + +% non-breaking space +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex +\relax +\else % if !pdftex +\newunicodechar{ }{~} +\fi + +% soft hyphen +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex +\relax +\else % if !pdftex +\newunicodechar{}{\-} +\fi + +% en quad and en space +\newunicodechar{ }{\enskip} +\newunicodechar{ }{\enskip} + +% em quad and em space +\newunicodechar{ }{\quad} +\newunicodechar{ }{\quad} + +% three-per-em space +\newunicodechar{ }{\hspace{0.33333em}} + +% four-per-em space +\newunicodechar{ }{\hspace{0.25em}} + +% six-per-em space +\newunicodechar{ }{\hspace{0.16667em}} + +% figure space +\newunicodechar{ }{\leavevmode\hphantom{0}} + +% punctuation space +\newunicodechar{ }{\hspace{\fontcharwd \font `\,}} + +% thin space +\newunicodechar{ }{\leavevmode\allowbreak\,} + +% hair space +\newunicodechar{ }{\hspace{0.08333em}} + +% line separator +\newunicodechar{
}{\newline} + +% next line (NEL) +\newunicodechar{
}{\newline} + +% paragraph separator +\newunicodechar{
}{\csname par\endcsname} + +\endinput + +%% +%% End of file `uspace.sty'. diff --git a/macros/latex/contrib/uspace/uspace.tex b/macros/latex/contrib/uspace/uspace.tex new file mode 100644 index 0000000000..b46a4f7b01 --- /dev/null +++ b/macros/latex/contrib/uspace/uspace.tex @@ -0,0 +1,139 @@ +\documentclass[paper=B5,DIV=calc,parskip=half]{scrartcl} +\usepackage{ifluatex} +\ifluatex +\usepackage{luatex85} +\fi + +\usepackage{fontspec} +%\defaultfontfeatures{Ligatures={TeX,Common},Scale=MatchLowercase} +\setmainfont[]{Charis SIL} +\setsansfont[Ligatures={TeX,Common}, Scale=MatchLowercase]{TeX Gyre Heros} +\setmonofont[Ligatures=,Scale=MatchLowercase]{DejaVu Sans Mono} + +\usepackage{listings} +\usepackage{enumitem} +%\usepackage{enumitem-zref} +\usepackage{polyglossia} +\setmainlanguage[]{english} + +\usepackage{uspace} +\usepackage[autostyle]{csquotes} + +\author{Václav Haisman\texorpdfstring{% + \\{\small\href{mailto:vhaisman+uspace@gmail.com?subject=[uspace]}{vhaisman@gmail.com}}}{}} +\date{\today} +\title{\texttt{uspace} user manual} +\subtitle{v0.04} + +\usepackage{xcolor} +\usepackage{multicol} +\usepackage{microtype} +\usepackage{metalogo} +\usepackage{hologo} + +\PassOptionsToPackage{unicode}{hyperref} +\usepackage{bookmark} +\hypersetup{ + colorlinks, + linkcolor={red!50!black}, + citecolor={blue!50!black}, + urlcolor={blue!80!black}, + breaklinks=true} +\urlstyle{same} % don't use monospace font for urls + +\setlength{\emergencystretch}{3em} % prevent overfull lines + +\lstdefinestyle{myLatexStyle}{ + language=[LaTeX]{Tex}, + basicstyle=\ttfamily +} + +\lstset{style=myLatexStyle} + +\newcommand{\zwsp}{\textsc{zero width space}} +\newcommand{\nnbsp}{\textsc{narrow no-break space}} +\newcommand{\nbsp}{\textsc{non-breaking space}} +\newcommand{\shy}{\textsc{soft hyphen}} +\newcommand{\enquad}{\textsc{en quad}} +\newcommand{\enspaceC}{\textsc{en space}} +\newcommand{\emquad}{\textsc{em quad}} +\newcommand{\emspaceC}{\textsc{em space}} +\newcommand{\threePerEm}{\textsc{three-per-em space}} +\newcommand{\fourPerEm}{\textsc{four-per-em space}} +\newcommand{\sixPerEm}{\textsc{six-per-em space}} +\newcommand{\figuresp}{\textsc{figure space}} +\newcommand{\punctsp}{\textsc{punctuation space}} +\newcommand{\thinsp}{\textsc{thin space}} +\newcommand{\hairsp}{\textsc{hair space}} +\newcommand{\linesep}{\textsc{line separator}} +\newcommand{\nel}{\textsc{next line (nel)}} +\newcommand{\parasep}{\textsc{paragraph separator}} + +\begin{document} +\begin{titlepage} + \maketitle +\end{titlepage} + +\tableofcontents + +\section{Introduction}% +% +This \LaTeX{} package gives useful meaning to various Unicode space +characters so that they fulfill their intended function when used in \LaTeX{} +source. It uses \lstinline|\newunicodechar| macro to do it. Its source is +hosted on GitHub in +\texttt{\href{https://github.com/wilx/project-uspace}{wilx/project-uspace}} +repository. + +Here is a list of the implemented characters +and their implementations:\nobreak% +\begin{labeling}[\quad]{\nnbsp{} (\texttt{U+202F})} +\item[\zwsp{} (\texttt{U+200B})] \lstinline|\hspace{0pt}| +\item[\nnbsp{} (\texttt{U+202F})] \lstinline|\leavevmode\,| +\item[\nbsp{\footnotemark[1]} (\texttt{U+00A0})] \lstinline|~| +\item[\shy{\footnotemark[1]} (\texttt{U+00AD})] \lstinline|\-| +\item[\emquad{\footnotemark[2]} (\texttt{U+2001})] \lstinline|\quad| +\item[\emspaceC{\footnotemark[2]} (\texttt{U+2001})] \lstinline|\quad| +\item[\enquad{\footnotemark[3]} (\texttt{U+2000})] \lstinline|\enskip| +\item[\enspaceC{\footnotemark[3]} (\texttt{U+2000})] \lstinline|\enskip| +\item[\threePerEm{} (\texttt{U+2004})] \lstinline|\hspace{0.33333em}| +\item[\fourPerEm{} (\texttt{U+2005})] \lstinline|\hspace{0.25em}| +\item[\sixPerEm{} (\texttt{U+2006})] \lstinline|\hspace{0.16667em}| +\item[\figuresp{} (\texttt{U+2007})] \lstinline|\leavevmode\hphantom{0}| +\item[\punctsp{} (\texttt{U+2008})] \lstinline|\hspace{\fontcharwd \font `\,}| +\item[\thinsp{} (\texttt{U+2009})] \lstinline|\leavevmode\allowbreak\,| +\item[\hairsp{} (\texttt{U+200A})] \lstinline|\hspace{0.08333em}| +\item[\linesep{} (\texttt{U+2028})] \lstinline|\newline| +\item[\nel{} (\texttt{U+0085})] \lstinline|\newline| +\item[\parasep{} (\texttt{U+2029})] \lstinline|\csname par\endcsname| +\end{labeling} +\footnotetext[1]{This already defined for \hologo{pdfLaTeX} because we use + \lstinline|inputenc| with \lstinline|utf8| option when compiling with + \hologo{pdfLaTeX}, therefore this is only defined for \LuaLaTeX{} and + \XeLaTeX{}.} +\footnotetext[2]{According to Unicode, these two are canonically + equivalent. See \url{http://unicode.org/notes/tn5/} + for explanation of the term.} +\footnotetext[3]{These two are also canonically equivalent. See previous + footnote.} + + +\section{History}% +% +This package would not be what it is without help and comments from people of +\href{http://chat.stackexchange.com/rooms/41/tex-latex-and-friends}{\TeX{}, + \LaTeX{} and Friends} StackExchange chat room and the +\href{http://tex.stackexchange.com/}{\TeX.SE} site itself. + +\begin{description}[style=nextline, labelwidth=4.5em, leftmargin=!, + labelindent=0em] + \item[\texttt{v0.04}] Add implementation for \linesep{}, \nel{} + and \parasep{}. + \item[\texttt{v0.03}] Change implementation for \punctsp{} and \thinsp{} to + fix issues with line wrapping when using these characters. + \item[\texttt{v0.02}] Round lengths to five digits after decimal + point. List also Unicode code point values beside character names. + \item[\texttt{v0.01}] First published version of this package. +\end{description} + +\end{document} |