summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/impnattypo
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-09-15 23:33:07 +0000
committerKarl Berry <karl@freefriends.org>2011-09-15 23:33:07 +0000
commit5cf14d2ba51ffc6d0b16e42e6f459a603da20605 (patch)
treed74fea166b542c00039c17fb1f2769438560ebbc /Master/texmf-dist/tex/latex/impnattypo
parent899df8057d5769250db18b1f57dc1757fc2a0fe7 (diff)
impnattypo 0.3 (14sep11)
git-svn-id: svn://tug.org/texlive/trunk@23975 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/impnattypo')
-rw-r--r--Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty77
1 files changed, 76 insertions, 1 deletions
diff --git a/Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty b/Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty
index cedfd3d15cd..9185c353e9d 100644
--- a/Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty
+++ b/Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty
@@ -20,12 +20,19 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{impnattypo}
- [2011/09/11 0.1 Recommendations typographiques de l'Imprimerie Nationale Française]
+ [2011/09/13 0.3 Recommendations typographiques de l'Imprimerie Nationale Française]
\ProvidesPackage{impnattypo}
+\usepackage{ifluatex}
\newif\if@impnattypo@frenchchapters
\DeclareOption{frenchchapters}{\@impnattypo@frenchchapterstrue}
\newif\if@impnattypo@hyphenation
\DeclareOption{hyphenation}{\@impnattypo@hyphenationtrue}
+\newif\if@impnattypo@nosingleletter
+\DeclareOption{nosingleletter}{\@impnattypo@nosinglelettertrue}
+\newif\if@impnattypo@parindent
+\DeclareOption{parindent}{\@impnattypo@parindenttrue}
+\newif\if@impnattypo@lastparline
+\DeclareOption{lastparline}{\@impnattypo@lastparlinetrue}
\ProcessOptions
\if@impnattypo@hyphenation
\brokenpenalty=10000
@@ -41,6 +48,74 @@
\fi
}
\fi
+\if@impnattypo@nosingleletter
+ \ifluatex
+ \usepackage{luatexbase,luacode}
+ \begin{luacode}
+
+ local prevent_single_letter = function (head)
+ while head do
+ if head.id == 37 then -- glyph
+ if head.prev.id == 10 and head.next.id == 10 then -- only if we are at a one letter word
+
+ local p = node.new("penalty")
+ p.penalty = 10000
+
+ -- Uncomment the next lines to show the position of the ~'s
+ -- local p = node.new("rule")
+ -- p.width = 2* 2^16
+ -- p.height = 2^16
+ -- p.depth = 2^16
+
+ p.next = head.next
+ head.next.prev = p
+ head.next = p
+
+ end
+ end
+ head = head.next
+ end
+ return true
+ end
+
+ luatexbase.add_to_callback("pre_linebreak_filter",prevent_single_letter,"~")
+ \end{luacode}
+ \else
+ \PackageError{The nosingleletter option only works with LuaTeX}
+ \fi
+\fi
+\if@impnattypo@parindent
+\setlength{\parindent}{1em}
+\fi
+\if@impnattypo@lastparline
+ \ifluatex
+ \usepackage{luatexbase,luacode}
+ \begin{luacode}
+ last_line_twice_parindent = function (head)
+ while head do
+ local _w,_h,_d = node.dimensions(head)
+ if head.id == 10 and head.subtype ~= 15 and (_w < 2 * tex.parindent) then
+
+ -- we are at a glue and have less then 2*\parindent to go
+ local p = node.new("penalty")
+ p.penalty = 10000
+ p.next = head
+ head.prev.next = p
+ p.prev = head.prev
+ head.prev = p
+ end
+
+ head = head.next
+ end
+ return true
+ end
+
+ luatexbase.add_to_callback("pre_linebreak_filter",last_line_twice_parindent,"lastparline")
+ \end{luacode}
+ \else
+ \setlength{\parfillskip}{0pt plus\dimexpr\textwidth-2\parindent}
+ \fi
+\fi
\endinput
%%
%% End of file `impnattypo.sty'.