-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_width_nowrap.template
More file actions
55 lines (45 loc) · 1.42 KB
/
get_width_nowrap.template
File metadata and controls
55 lines (45 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
%%% Based on the script by Paolo Brasolin:
%%% \url{http://tex.stackexchange.com/a/285774}
%%% See V. Eijkhout, TeX by Topic, A TeXnician's Reference, 5.9.6;
%%% V. Eijkhout, ``Unusual paragraph shapes,'' TUGboat 11: 51--53.
\documentclass{tufte-book}
\usepackage{fontspec}
\usepackage[Latin,Greek,Mathematics,Symbols]{ucharclasses}
% Greek fonts
\newfontfamily\greekfont[ItalicFont={Latin Modern Roman 10 Italic},
ItalicFeatures={FakeSlant=0},
FakeSlant=0.15,
Ligatures=TeX]{Latin Modern Math}
\setTransitionsForGreek{\greekfont}{}
% Math fonts
\newfontfamily\mathsfont[ItalicFont={Latin Modern Roman 10 Italic}, Ligatures=TeX]{Latin Modern Math}
\setTransitionsForSymbols{\mathsfont}{}
\setTransitionsForMathematics{\mathsfont}{}
\newbox\linebox
\newbox\tempbox
\newif\ifoutput
\newdimen\lwCUR
\newdimen\lwCURMAX
\def\measure#1\par{
\lwCURMAX=0pt
\setbox\tempbox\vbox{#1\par\eat}
\ifoutput\box\tempbox\fi
}
\def\eat{{
\setbox\linebox\lastbox
\settowidth{\lwCUR}{\unhcopy\linebox}
\ifdim\lwCUR>\lwCURMAX\global\lwCURMAX=\lwCUR\fi
\ifvoid\linebox\else
\unskip\unpenalty\unskip\unpenalty\unskip\unpenalty\unskip\eat
\ifoutput
\noindent\box\linebox\rlap{~\,~\,~\,~\the\lwCUR}
\fi
\fi
}}
\begin{document}
\outputfalse
\setlength{\parindent}{0pt}
\measure $tex_to_measure \par
\showthe\dimexpr\lwCURMAX
\showthe\dimexpr1em
\end{document}