%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjp-geometry}[2014/11/23 Patch to geometry for LuaTeX-ja with vertical writing mode]
+\ProvidesPackage{lltjp-geometry}[2016/10/06 Patch to geometry for LuaTeX-ja with vertical writing mode]
\RequirePackage{ifluatex}
+\ifdefined\if@ltj@@geometry@tate\expandafter\endinput\fi
\newif\if@ltj@@geometry@tate
\@ltj@@geometry@tatefalse
\ifluatex\else % pTeX
\fi
\RequirePackage{filehook}
+\RequirePackage{etoolbox}
+\newif\ifGm@ltj@layoutswitch
+\let\orig@PackageWarningNoLine=\PackageWarningNoLine
+% define ifGm@swap@papersize if it is undefined
+\expandafter\newif\csname ifGm@swap@papersize\endcsname
\AtBeginOfPackageFile{geometry}{%
\edef\Gm@ltj@topskip{\the\topskip}
\edef\Gm@ltj@headsep{\the\headsep}
\edef\Gm@ltj@footskip{\the\footskip}
-}
-\AtEndOfPackageFile{geometry}{%
\ifluatex
\ifnum\ltjgetparameter{direction}=3 \@ltj@@geometry@tatetrue\fi
\fi
\if@ltj@@geometry@tate
+ \let\PackageWarningNoLine\@gobbletwo% 警告抑止
+\fi
+}
+\AtEndOfPackageFile{geometry}{%
+\let\PackageWarningNoLine=\orig@PackageWarningNoLine
+\if@ltj@@geometry@tate
+ \let\PackageWarningNoLine=\orig@PackageWarningNoLine
+%%% ここからパッチ開始
+% TODO:
+% * pTeX, LuaTeX ともに truedimen が正しく動作しない
+% * pTeX resetpaper が正しく動作しない
+%
% `h', `v' は「水平」「垂直」を意味するが:
% ユーザー側では「紙の物理的な水平方向」「物理的な垂直方向」を,
% しかしパッケージ内部処理では「字送り方向」「行送り方向」を表す.
% そのため,key-value interface 内で h, v の交換を行う必要がある.
-\define@key{Gm}{vdivide}{\Gm@parse@divide{#1}{tmargin}{width}{bmargin}}%
+% twoside 指定時は,lmargin は小口側,rmargin はノド側の余白を指す.
+% また,bindingoffset 偶数ページを右に,奇数ページを左にずらす.
\define@key{Gm}{hdivide}{\Gm@parse@divide{#1}{lmargin}{height}{rmargin}}%
+
+\define@key{Gm}{vscale}{\Gm@hbodytrue\edef\Gm@hscale{#1}}%
+\define@key{Gm}{hscale}{\Gm@vbodytrue\edef\Gm@vscale{#1}}%
+\define@key{Gm}{vdivide}{\Gm@parse@divide{#1}{tmargin}{width}{bmargin}}%
\define@key{Gm}{divide}{\Gm@parse@divide{#1}{tmargin}{width}{bmargin}%
\Gm@parse@divide{#1}{lmargin}{height}{rmargin}}%
\define@key{Gm}{vmargin}{\Gm@branch{#1}{tmargin}{bmargin}}%
\Gm@branch{#1}{bmargin}{rmargin}}%
\define@key{Gm}{headsep}{\Gm@defbylen{ltj@headsep}{#1}}%
\define@key{Gm}{footskip}{\Gm@defbylen{ltj@footskip}{#1}}%
+\let\KV@Gm@foot\KV@Gm@footskip
\define@key{Gm}{vmarginratio}{\edef\Gm@hmarginratio{#1}}%
\define@key{Gm}{hmarginratio}{\edef\Gm@vmarginratio{#1}}%
+\define@key{Gm}{nohead}[true]{\Gm@doifelse{nohead}{#1}%
+ {\Gm@setlength\headheight\z@\Gm@defbylen{ltj@headsep}\z@}{}}%
+\define@key{Gm}{nofoot}[true]{\Gm@doifelse{nofoot}{#1}%
+ {\Gm@defbylen{ltj@footskip}\z@}{}}%
+\define@key{Gm}{noheadfoot}[true]{\Gm@doifelse{noheadfoot}{#1}%
+ {\Gm@setlength\headheight\z@\Gm@defbylen{ltj@headsep}\z@
+ \Gm@defbylen{ltj@footskip}\z@}{}}%
+\define@key{Gm}{layoutwidth}{\Gm@layouttrue\Gm@setlength\Gm@layoutheight{#1}}%
+\define@key{Gm}{layoutheight}{\Gm@layouttrue\Gm@setlength\Gm@layoutwidth{#1}}%
+\define@key{Gm}{layoutsize}{\Gm@branch{#1}{layoutwidth}{layoutheight}}%
+\define@key{Gm}{layout}{\Gm@layouttrue\@nameuse{Gm@#1}{Gm@layout}%
+ \Gm@setlength\@tempdima{\Gm@layoutheight}%
+ \Gm@setlength\Gm@layoutheight{\Gm@layoutwidth}%
+ \Gm@setlength\Gm@layoutwidth{\@tempdima}%
+}%
% \@mparswitch は傍注の出力位置を左右ページで変えるスイッチだが,
% geometry.sty はこれを左右ページのレイアウトを変えるか否かの判定にも使っている.
% 縦組クラスの場合は \@mparswitch は常に偽でないとおかしなことになるので
% \@mparswitch -> \Gm@ltj@layoutswitch と名称変更する.
-\newif\ifGm@ltj@layoutswitch
\let\Gm@ltj@layoutswitch\@mparswitch
\@mparswitchfalse
\define@key{Gm}{twoside}[true]{\Gm@doifelse{twoside}{#1}%
\define@key{Gm}{asymmetric}[true]{\Gm@doifelse{asymmetric}{#1}%
{\@twosidetrue\Gm@ltj@layoutswitchfalse}{}}%
- \def\Gm@Dhratio{2:3}% = top:bottom default
- \def\Gm@Dvratio{1:1}% = left:right default for oneside
- \def\Gm@Dvratiotwo{2:3}% = inner:outer default for twoside.
+% includemp 指定時は,\headsep (if reversemp || twocolumn) や,
+% \footskip (if !reversemp || twocolumn) を傍注幅だけ増加させる.
+
+% h <-> v
+\def\Gm@Dhratio{2:3}% = top:bottom default
+\def\Gm@Dvratio{1:1}% = left:right default for oneside
+\def\Gm@Dvratiotwo{3:2}% = inner:outer default for twoside.
+\ifGm@swap@papersize
+ % geometry.sty ロード時に landscape オプションが指定されていた場合,
+ % それによって用紙サイズの縦横が入れ替わってしまっているので補正する.
+ \setlength\@tempdima{\paperwidth}%
+ \setlength\paperwidth{\paperheight}%
+ \setlength\paperheight{\@tempdima}%
+\fi
% save length
\def\Gm@save{%
\ifGm@showcrop
\vb@xt@\z@{\vskip-1\Gm@truedimen in\vskip\Gm@layoutvoffset%
\hb@xt@\z@{\hskip-1\Gm@truedimen in\hskip\Gm@layouthoffset%
- \vb@xt@\Gm@layoutheight{%
+ \vb@xt@\Gm@layoutwidth{%
\let\protect\relax
- \hb@xt@\Gm@layoutwidth{\Gm@cropmark(-1,1,-3,3)\hfil\Gm@cropmark(1,1,3,3)}%
+ \hb@xt@\Gm@layoutheight{\Gm@cropmark(-1,1,-3,3)\hfil\Gm@cropmark(1,1,3,3)}%
\vfil
- \hb@xt@\Gm@layoutwidth{\Gm@cropmark(-1,-1,-3,-3)\hfil\Gm@cropmark(1,-1,3,-3)}}%
+ \hb@xt@\Gm@layoutheight{\Gm@cropmark(-1,-1,-3,-3)\hfil\Gm@cropmark(1,-1,3,-3)}}%
\hss}%
\vss}%
\fi%
\vb@xt@\z@{\vss\Gm@hruled}%
\unless\if@reversemargin\vb@xt@\z@{%
\vskip\marginparsep\vb@xt@\z@{\vss\Gm@hrule}%
- \vskip\marginparwidth\vb@xt@\z@{\vss\Gm@hruled}%
+ \vskip\marginparwidth\vb@xt@\z@{\vss\Gm@hruled}\vss%
}\fi%
\vskip\footskip\vb@xt@\z@{\vss\Gm@hruled}%
\vss}%
\@tempcnta\z@
\if#1h
\let\Gm@mratio\Gm@hmarginratio
- \edef\Gm@Dmratio{\if@twoside\Gm@Dhratiotwo\else\Gm@Dhratio\fi}%
+ \edef\Gm@Dmratio{\Gm@Dhratio}%
\else
\let\Gm@mratio\Gm@vmarginratio
- \edef\Gm@Dmratio{\Gm@Dvratio}%
+ \edef\Gm@Dmratio{\if@twoside\Gm@Dvratiotwo\else\Gm@Dvratio\fi}%
\fi
\if#1h
\ifx\Gm@tmargin\@undefined\else\advance\@tempcnta4\relax\fi
\ifx\Gm@bmargin\@undefined\else\advance\@tempcnta1\relax\fi
\Gm@cnth\@tempcnta
\else
- \ifx\Gm@rmargin\@undefined\else\advance\@tempcnta4\relax\fi
+ \ifx\Gm@lmargin\@undefined\else\advance\@tempcnta4\relax\fi
\ifGm@vbody\advance\@tempcnta2\relax\fi
- \ifx\Gm@lmargin\@undefined\else\advance\@tempcnta1\relax\fi
+ \ifx\Gm@rmargin\@undefined\else\advance\@tempcnta1\relax\fi
\Gm@cntv\@tempcnta
\fi
\ifcase\@tempcnta
\def\Gm@clean{%
\ifnum\Gm@cnth<4\let\Gm@tmargin\@undefined\fi
\ifodd\Gm@cnth\else\let\Gm@bmargin\@undefined\fi
- \ifnum\Gm@cntv<4\let\Gm@rmargin\@undefined\fi
- \ifodd\Gm@cntv\else\let\Gm@lmargin\@undefined\fi
+ \ifnum\Gm@cntv<4\let\Gm@lmargin\@undefined\fi
+ \ifodd\Gm@cntv\else\let\Gm@rmargin\@undefined\fi
\ifGm@hbody\else
\let\Gm@hscale\@undefined
\let\Gm@width\@undefined
\fi
\setlength\topskip\Gm@ltj@topskip
\ifx\Gm@lines\@undefined\else
- \setlength\maxdepth{1\Cht}%
+ \@tempdima=\f@size\p@ \@tempdima=.5\@tempdima
+ \ifluatex
+ \advance\@tempdima\ltjgetparameter{talbaselineshift}%
+ \else
+ \advance\@tempdima\tbaselineshift
+ \fi
+ \ifdim\maxdepth<\@tempdima
+ \PackageWarningNoLine{lltjp-geometry}%
+ {\noexpand\maxdepth was changed from \the\maxdepth\space
+ to \the\@tempdima}
+ \maxdepth\@tempdima
+ \fi
\setbox\z@=\hbox{\tate% next \ifdim must be executed in tate dir.
\ifdim\topskip<\ht\tstrutbox
\@tempdima\topskip
\global\topskip\ht\tstrutbox
\PackageWarningNoLine{lltjp-geometry}%
- {do not worry about `\noexpand\topskip was changed ...'\MessageBreak
- warning above}
- \PackageWarningNoLine{lltjp-geometry}%
{\noexpand\topskip was changed from \the\@tempdima\space
to \the\topskip}
\fi}%
\fi
\fi}%
-\def\Gm@adjustmp{%%%% TODO %%%%%%%
+\def\Gm@adjustmp{%
\ifGm@includemp
\@tempdimb\marginparwidth
\advance\@tempdimb\marginparsep
\Gm@wd@mp\@tempdimb
- \Gm@odd@mp\z@
- \Gm@even@mp\z@
\if@twocolumn
\Gm@wd@mp2\@tempdimb
- \Gm@odd@mp\@tempdimb
- \Gm@even@mp\@tempdimb
- \else
- \if@reversemargin
- \Gm@odd@mp\@tempdimb
- \if@mparswitch\else
- \Gm@even@mp\@tempdimb
- \fi
- \else
- \if@mparswitch
- \Gm@even@mp\@tempdimb
- \fi
- \fi
\fi
\fi}%
\def\Gm@@process{%
\Gm@expandlengths
\Gm@adjustpaper
- \addtolength\Gm@layoutwidth{-\Gm@bindingoffset}%
+ \addtolength\Gm@layoutheight{-\Gm@bindingoffset}%
\Gm@adjustmp
\Gm@adjustbody
\Gm@detall{h}{width}{tmargin}{bmargin}%
\else
\evensidemargin\oddsidemargin
\fi
- \advance\oddsidemargin\Gm@bindingoffset
+ \advance\evensidemargin\Gm@bindingoffset
\addtolength\topmargin{-1\Gm@truedimen in}%
\ifGm@includehead
\addtolength\textwidth{-\headheight}%
\fi
\ifGm@includemp
\advance\textwidth-\Gm@wd@mp
- \if@reversemargin
+ \if@twocolumn
+ \advance\headsep.5\Gm@wd@mp
+ \advance\footskip.5\Gm@wd@mp
+ \else\if@reversemargin
\advance\headsep\Gm@wd@mp
\else
\advance\footskip\Gm@wd@mp
- \fi
+ \fi\fi
\fi
\ifGm@heightrounded
\setlength\@tempdima{\textheight}%
\addtolength\@tempdimb{\topskip}%
\textheight\@tempdimb
\fi
- \advance\oddsidemargin\Gm@layoutvoffset%
- \advance\evensidemargin\Gm@layoutvoffset%
- \advance\topmargin\Gm@layouthoffset%
+ \advance\oddsidemargin\Gm@layouthoffset%
+ \advance\evensidemargin\Gm@layouthoffset%
+ \advance\topmargin\Gm@layoutvoffset%
\addtolength\Gm@layoutheight{\Gm@bindingoffset}%
}% end of \Gm@@process
-
% log
\def\Gm@logcontent#1{%
*geometry* verbose mode - [ #1 ] result:^^J%
\Gm@setdefaultpaper
\ProcessOptionsKV[p]{Gm}%
\Gm@process
+
+%%% 終了
\fi}
\endinput