VOOZH about

URL: https://qiita.com/munepi/items/004d19a657d3bf2d4ded

⇱ pLaTeX縦書きでhyperrefパッケージを使うときの変更点 #LaTeX - Qiita


👁 Image
13

Go to list of users who liked

12

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@munepi(Munehiro Yamamoto)

pLaTeX縦書きでhyperrefパッケージを使うときの変更点

13
Last updated at Posted at 2014-05-27

pLaTeX縦書きでhyperrefパッケージを使うと、いくつか期待しない結果が生じてしまいます。その理由をおおざっぱに言うと、hyperref.styが文章論理構成をつかさどる各種マクロに対して、hookのようにひっかけて、PDFにおけるhyperlink textの機能を提供しているからです。

今回は、pLaTeX縦書きでhyperrefパッケージを使ったとき、目次において各種見出しに対するページ頁番号が横向きにひっくり返ってしまうことに対処する変更点を記します。

目次における各種見出しに対する頁番号の出力

汎用縦書きクラスファイルの目次において、各種見出しに対する頁番号が横向きにひっくり返らないようにするために、plext.styが提供する連数字コマンド\rensujiをページ番号出力\thepageにかぶせています。

tarticle.cls
\def\addcontentsline#1#2#3{%
 \protected@write\@auxout
 {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble
 \@temptokena{\rensuji{\thepage}}}%
 {\string\@writefile{#1}%
 {\protect\contentsline{#2}{#3}{\the\@temptokena}}}%
}

ところがhyperrefパッケージを読みこむと、この\contentslineコマンドを書き換えてしまいます。

hyperrefに対する\contentslineの再定義

以下のような\contentslineコマンドの再定義をして、\thepage相当に\rensujiをかぶせることで、期待した結果を得られます。

\RequirePackage[dvipdfmx, % draft,
 bookmarks=true,
 bookmarksnumbered=true,
 % colorlinks=true,
 setpagesize=false,
]{hyperref}[2012/11/06 v6.83m]
%% override \contentsline against hyperref.sty 2012/11/06 v6.83m
\def\contentsline#1#2#3#4{%
 \begingroup
 \Hy@safe@activestrue
 \edef\x{\endgroup
 \def\noexpand\Hy@tocdestname{#4}%
 }\x
 \ifx\Hy@tocdestname\ltx@empty
 \csname l@#1\endcsname{#2}{\rensuji{#3}}%
 \else
 \ifcase\Hy@linktoc % none
 \csname l@#1\endcsname{#2}{\rensuji{#3}}%
 \or % section
 \csname l@#1\endcsname{%
 \hyper@linkstart{link}{\Hy@tocdestname}{#2}\hyper@linkend
 }{\rensuji{#3}}%
 \or % page
 \def\Hy@temp{#3}%
 \ifx\Hy@temp\ltx@empty
 \csname l@#1\endcsname{#2}{#3}%
 \else
 \csname l@#1\endcsname{{#2}}{%
 \hyper@linkstart{link}{\Hy@tocdestname}{#3}\hyper@linkend
 }%
 \fi
 \else % all
 \def\Hy@temp{#3}%
 \ifx\Hy@temp\ltx@empty
 \csname l@#1\endcsname{%
 \hyper@linkstart{link}{\Hy@tocdestname}{#2}\hyper@linkend
 }{}%
 \else
 \csname l@#1\endcsname{%
 \hyper@linkstart{link}{\Hy@tocdestname}{#2}\hyper@linkend
 }{%
 \hyper@linkstart{link}{\Hy@tocdestname}{#3}\hyper@linkend
 }%
 \fi
 \fi
 \fi
}
\RequirePackage[dvipdfmx]{pxjahyper}[2012/05/27 v0.2]

以上です。

何かしらpLaTeXの縦書きクラスファイルを作成するときに、ご参考いただければ幸いです。

13

Go to list of users who liked

12
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13

Go to list of users who liked

12