OSDN Git Service

fix #39463; added dummy disablejfam option in classes
[luatex-ja/luatexja.git] / src / ltjclasses.dtx
index af796a1..ccecd0d 100644 (file)
@@ -5,10 +5,10 @@
 %
 %  Copyright 1995-2001 ASCII Corporation.
 %  Copyright (c) 2010 ASCII MEDIA WORKS
-%  Copyright (c) 2016-2017 Japanese TeX Development Community
+%  Copyright (c) 2016-2018 Japanese TeX Development Community
 %
-%  This file is part of the pLaTeX2e system.
-%  -----------------------------------------
+%  This file is part of the pLaTeX2e system (community edition).
+%  -------------------------------------------------------------
 %
 % \fi
 %
 % \changes{v1.7e}{2017/03/05}{トンボに表示するジョブ情報の書式を変更}
 % \changes{v1.7e}{2017/03/05}{\cs{frontmatter}と\cs{mainmatter}を
 %   奇数ページに送るように変更}
-% \changes{v1.7e-ltj-15}{2017/08/28}{本ドキュメントのタイプセットで,小塚フォントが存在するときには
-%   それを用いるように変更(PDFサイズ削減のため).クラスファイル本体の変更はなし,}
+% \changes{v1.7e-ltj-15}{2017/08/31}{本ドキュメントのタイプセットで,小塚フォントが存在するときには
+%   それを用いるように変更(PDFサイズ削減のため).}
+% \changes{v1.7f}{2017/08/31}{和文書体の基準を全角空白から「漢」に変更}
+% \changes{v1.7g}{2017/09/19}{内部処理で使ったボックス0を空にした}
+% \changes{v1.7h}{2018/02/04}{和文スケール値\cs{Cjascale}を定義}
+% \changes{v1.8}{2018/07/03}{\cs{today}のデフォルトを和暦から西暦に変更}
+% \changes{v1.8-ltj-16}{2018/10/08}{Lua\TeX-jaが|disablejfam|オプションをサポートしたことによる変更}
+% \changes{v1.8a}{2018/10/25}{ファイル書き出し時の行末文字対策
+%    (sync with ltsect.dtx 2018/09/26 v1.1c)}
+% \changes{v1.8b}{2019/04/02}{新元号対応}
+% \changes{v1.8b-ltj-17}{2019/08/12}{disablejfamの``Unused global option(s)''警告を出さないようにした}
+
 % \fi
 %
 % \iffalse
 %<11pt&bk>\ProvidesFile{ltjtbk11.clo}
 %<12pt&bk>\ProvidesFile{ltjtbk12.clo}
 %</tate>
-  [2017/08/28 v1.7e-ltj-15
+  [2019/04/06 v1.8b-ltj-16
 %<article|report|book> Standard LuaLaTeX-ja class]
 %<10pt|11pt|12pt>  Standard LuaLaTeX-ja file (size option)]
 %<*driver>
 \else
   \usepackage[kozuka-pr6n,nfssonly]{luatexja-preset}
 \fi
+\def\pLaTeX{p\kern-.05em\LaTeX}
 \usepackage[unicode]{hyperref}
 \title{Lua\LaTeX-ja用\texttt{jclasses}互換クラス}
 \author{Lua\TeX-jaプロジェクト}
 %
 % \section{はじめに}
 % このファイルは、Lua\LaTeX-ja用の|jclasses|互換クラスファイルです。
-% v1.6をベースに作成しています。
+% コミュニティ版をベースに作成しています。
 % \dst{}プログラムによって、横組用のクラスファイルと縦組用のクラスファイル
 % を作成することができます。
 %
 % 全ての変更点を知りたい場合は、|jclasses.dtx|と|ltjclasses.dtx|で|diff|を
 % とって下さい。
 % \begin{itemize}
-% \item |disablejfam|オプションを無効化。もし
+% \item もし
 % \begin{quotation}
 %   |! LaTeX Error: Too many math alphabets used in version ****.|
 % \end{quotation}
 % |mathrmmc|オプションは、
 % |\mathrm|と|\mathbf|を和欧文両対応にするためのクラスオプションです。
 % \changes{v1.1d}{1992/02/04}{disablejfamの判断を間違えてたのを修正}
+% \changes{v1.8-ltj-16}{2018/10/08}{Lua\TeX-ja本体が,主にメモリ消費を抑える目的で
+%   |disablejfam|オプションをサポートしました。そのため以前出していた警告は削除します。}
 %    \begin{macrocode}
 \if@compatibility
   \@mathrmmctrue
 \else
-  \DeclareOption{disablejfam}{%
-    \ClassWarningNoLine{\@currname}{The class option 'disablejfam' is obsolete}}
   \DeclareOption{mathrmmc}{\@mathrmmctrue}
 \fi
 %    \end{macrocode}
 %
 % \changes{v1.6-ltj-9}{2015/01/01}{サイズクラスのロード前にメトリックの変更を行わないと,
 % \cs{Cht}等の値が反映されないのでこの場所に移動させました.}
-% 
+%
 %    \begin{macrocode}
 %<*article|report|book>
 \directlua{luatexbase.add_to_callback('luatexja.load_jfm',
 %</article|report|book>
 %    \end{macrocode}
 %
+% \subsection{disablejfamオプション}
+% \changes{v1.8b-ltj-17}{2019/08/12}{disablejfamの``Unused global option(s)''警告を出さないようにした}
+% disablejfamオプションは\LuaTeX-ja本体で処理しますが,
+% もう\LuaTeX-jaは読み込んでいるため,このままでは``Unused global option(s): [disablejfam]''警告が
+% 出てしまいます.そのため,「何もしない」disablejfamオプションをクラス内で定義しておきます.
+%
+%    \begin{macrocode}
+%<*article|report|book>
+\DeclareOption{disablejfam}{}
+%</article|report|book>
+%    \end{macrocode}
+%
 % \subsection{オプションの実行}
 % オプションの実行、およびサイズクラスのロードを行ないます。
 %    \begin{macrocode}
 % \begin{macro}{\Cvs}
 % \begin{macro}{\Chs}
 % 基準となる長さの設定をします。これらのパラメータは\file{lltjfont.sty}で定義
-% されています。
+% されています。基準とする文字を「全角空白」(EUCコード\texttt{0xA1A1})から
+% 「漢」(JISコード\texttt{0x3441})へ変更しました。
+% \changes{v1.7f}{2017/08/31}{和文書体の基準を全角空白から「漢」に変更}
+% \changes{v1.7g}{2017/09/19}{内部処理で使ったボックス0を空にした}
 %    \begin{macrocode}
-\setbox0\hbox{\char"3000}% 全角スペース
+\setbox0\hbox{漢}
 \setlength\Cht{\ht0}
 \setlength\Cdp{\dp0}
 \setlength\Cwd{\wd0}
 \setlength\Cvs{\baselineskip}
 \setlength\Chs{\wd0}
+\setbox0=\box\voidb@x
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
 % \end{macro}
 % \end{macro}
 %
+% \begin{macro}{\Cjascale}
+% このクラスファイルが意図する和文スケール値
+% ($1\,\mathrm{zw} \div \textmc{要求サイズ}$)を
+% 表す実数値マクロ|\Cjascale|を定義します。
+% この\texttt{jclasses}互換クラスでは、Lua\TeX-ja読み込み時の和文スケール値がそのまま
+% 使用され、その値は0.962216です。
+% \changes{v1.7h}{2018/02/04}{和文スケール値\cs{Cjascale}を定義}
+%    \begin{macrocode}
+%<*article|report|book>
+\def\Cjascale{0.962216}
+%</article|report|book>
+%    \end{macrocode}
+% \end{macro}
+%
 %
 %
 % \section{レイアウト}
 % |\marginparwidth|を計算します。
 % ここで、|\@tempdima|の値は、\linebreak
 % |\paperwidth| $-$ |\textwidth|です。
-% \changes{v1.1d}{1995/11/24}{typo: \cs{marginmarwidth} to \cs{marginparwidth}}
+% \changes{v1.1d}{1995/11/24}{\break typo: \cs{marginmarwidth} to \cs{marginparwidth}}
 %    \begin{macrocode}
 %<*yoko>
   \if@twoside
 %
 % \pstyle{jpl@in}スタイルは、クラスファイル内部で使用するものです。
 % \LaTeX{}では、bookクラスを\pstyle{headings}としています。
-% しかし、\cs{tableofcontnts}コマンドの内部では\pstyle{plain}として
+% しかし、\cs{tableofcontents}コマンドの内部では\pstyle{plain}として
 % 設定されるため、一つの文書でのページ番号の位置が上下に出力される
 % ことになります。
 %
 %<*report|book>
   \def\chaptermark##1{\markboth{%
      \ifnum \c@secnumdepth >\m@ne
-%<book>         \if@mainmatter
+%<book>       \if@mainmatter
          \@chapapp\thechapter\@chappos\hskip1\zw
-%<book>         \fi
+%<book>       \fi
      \fi
      ##1}{}}%
   \def\sectionmark##1{\markright{%
 %<*report|book>
 \def\chaptermark##1{\markright{%
    \ifnum \c@secnumdepth >\m@ne
-%<book>         \if@mainmatter
+%<book>     \if@mainmatter
        \@chapapp\thechapter\@chappos\hskip1\zw
-%<book>         \fi
+%<book>     \fi
    \fi
    ##1}}%
 %</report|book>
 %<*report|book>
 \def\chaptermark##1{\markboth{%
      \ifnum \c@secnumdepth >\m@ne
-%<book>         \if@mainmatter
+%<book>       \if@mainmatter
          \@chapapp\thechapter\@chappos\hskip1\zw
-%<book>         \fi
+%<book>       \fi
      \fi
      ##1}{}}%
   \def\sectionmark##1{\markright{%
 %<*report|book>
   \def\chaptermark##1{\markright{%
      \ifnum \c@secnumdepth >\m@ne
-%<book>         \if@mainmatter
+%<book>       \if@mainmatter
          \@chapapp\thechapter\@chappos\hskip1\zw
-%<book>         \fi
+%<book>       \fi
      \fi
      ##1}}%
 %</report|book>
 \if@compatibility
 \newenvironment{titlepage}
     {%
-%<book>      \cleardoublepage
+%<book>     \cleardoublepage
      \if@twocolumn\@restonecoltrue\onecolumn
      \else\@restonecolfalse\newpage\fi
      \thispagestyle{empty}%
 %\newcommand*{\sectionmark}[1]{}
 %\newcommand*{\subsectionmark}[1]{}
 %\newcommand*{\subsubsectionmark}[1]{}
-%\newcommand*{\paragraph}[1]{}
-%\newcommand*{\subparagraph}[1]{}
+%\newcommand*{\paragraphmark}[1]{}
+%\newcommand*{\subparagraphmark}[1]{}
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
 % |\alph{|\Lcount{COUNTER}|}|は、\Lcount{COUNTER}の値を
 % $1=$~a, $2=$~b のようにして出力します。
 %
-% |\Roman{|\Lcount{COUNTER}|}|は、\Lcount{COUNTER}の値を
+% |\Alph{|\Lcount{COUNTER}|}|は、\Lcount{COUNTER}の値を
 % $1=$~A, $2=$~B のようにして出力します。
 %
-% |\kansuji{|\Lcount{COUNTER}|}|は、\Lcount{COUNTER}の値を
+% |\Kanji{|\Lcount{COUNTER}|}|は、\Lcount{COUNTER}の値を
 % 漢数字で出力します。
 %
 % |\rensuji{|\meta{obj}|}|は、\meta{obj}を横に並べて出力します。
 % \end{description}
 %
 % |\secdef|は次のようにして使うことができます。
-% \begin{verbatim}
+%\begin{verbatim}
 %    \def\chapter {... \secdef \CMDA \CMDB }
 %    \def\CMDA    [#1]#2{....} % \chapter[...]{...} の定義
 %    \def\CMDB    #1{....}     % \chapter*{...} の定義
-% \end{verbatim}
+%\end{verbatim}
 %
 %
 % \subsubsection{partレベル}
 %    \LaTeX{} 2.09
 %    compatibility mode では和文数式フォントfamが2重定義されていた
 %    ので、その部分を変更しました。
+%
+% \changes{v1.8-ltj-14}{2018/10/08}{Lua\TeX-ja本体が|disablejfam|オプションをサポートしました。
+%    クラス読み込み時に|disablejfam|オプションを指定した場合は、それがLua\TeX-jaに渡されて
+%       数式中に日本語を記述することができなくなります(|\mathmc|, |\mathgt|も定義されません)。}
 %    \begin{macrocode}
+\unless\ifltj@disablejfam
 \if@compatibility\else
   \DeclareSymbolFont{mincho}{JY3}{mc}{m}{n}
   \DeclareSymbolFontAlphabet{\mathmc}{mincho}
   \reDeclareMathAlphabet{\mathbf}{\mathbf}{\mathgt}
 }%
 \fi
+\fi
 %    \end{macrocode}
 %
 % ここでは\LaTeX~2.09で一般的に使われていたコマンドを定義しています。
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@tocmarg}
+% \begin{macro}{\@tocrmarg}
 % 複数行にわたる場合の右マージンです。
 %    \begin{macrocode}
 \newcommand{\@tocrmarg}{2.55em}
 % |\@tempdima|にしていますが、この変数はいろいろな箇所で使われますので、
 % 期待した値が入らない場合があります。
 %
-% たとえば、|lltjfont.sty|での|\selectfont|は、和欧文のベースラインを調整する
-% ために|\@tempdima|変数を用いています。そのため、|\l@...|マクロの中で
-% フォントを切替えると、|\numberline|マクロのボックス
-% の幅が、ベースラインを調整するときに計算した値になってしまいます。
+% ^^A たとえば、|lltjfont.sty|での|\selectfont|は、和欧文のベースラインを調整する
+% ^^A ために|\@tempdima|変数を用いています。そのため、|\l@...|マクロの中で
+% ^^A フォントを切替えると、|\numberline|マクロのボックス
+% ^^A の幅が、ベースラインを調整するときに計算した値になってしまいます。
+% ^^A →修正(texjporg):最近の|\adjustbaseline|では|\adjust@dimen|が使われて
+% ^^A いるため、記述をコメントアウトしました。
 %
 % フォント選択コマンドの後、あるいは|\numberline|マクロの中でフォントを
 % 切替えてもよいのですが、一時変数を意識したくないので、
 % \end{macro}
 %
 % \begin{macro}{\addcontentsline}
-% ページ番号を|\rensuji|で囲むように変更します。
-% 横組のときにも`|\rensuji|'コマンドが出力されますが、
-% このコマンドによる影響はありません。
+% 縦組の場合にページ番号を|\rensuji|で囲むように変更します。
+% ^^A 横組のときにも`|\rensuji|'コマンドが出力されますが、
+% ^^A このコマンドによる影響はありません。
 %
 % このマクロは\file{ltsect.dtx}で定義されています。
+% \changes{v1.8a}{2018/10/25}{ファイル書き出し時の行末文字対策
+%    (sync with ltsect.dtx 2018/09/26 v1.1c)}
 %    \begin{macrocode}
+\providecommand*\protected@file@percent{}
 \def\addcontentsline#1#2#3{%
   \protected@write\@auxout
     {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble
-%<tate>\@temptokena{\rensuji{\thepage}}}%
-%<yoko>\@temptokena{\thepage}}%
+%<tate>     \@temptokena{\rensuji{\thepage}}}%
+%<yoko>     \@temptokena{\thepage}}%
     {\string\@writefile{#1}%
-       {\protect\contentsline{#2}{#3}{\the\@temptokena}}}%
+       {\protect\contentsline{#2}{#3}{\the\@temptokena}%
+               \protected@file@percent}}%
 }
 %    \end{macrocode}
 % \end{macro}
          \renewcommand\theenumiv{\@arabic\c@enumiv}}%
    \sloppy
 %    \end{macrocode}
-% \changes{v1.1a}{1997/01/23}{\LaTeX\ \texttt{!<1996/12/01!>}に合わせて修正}
+% \changes{v1.1a}{1997/01/23}{\break\LaTeX\ \texttt{!<1996/12/01!>}に合わせて修正}
 %    \begin{macrocode}
    \clubpenalty4000
    \@clubpenalty\clubpenalty
 % \changes{v1.0h}{1996/12/17}{Typo:和歴 to 和暦}
 % |\today|コマンドの`年'を、
 % 西暦か和暦のどちらで出力するかを指定するコマンドです。
+% 2018年7月以降の日本語\TeX{}開発コミュニティ版(v1.8)では、
+% デフォルトを和暦ではなく西暦に設定しています。
+% \changes{v1.8}{2018/07/03}{\cs{today}のデフォルトを和暦から西暦に変更}
 %    \begin{macrocode}
-\newif\if西暦 \西暦false
+\newif\if西暦 \西暦true
 \def\西暦{\西暦true}
 \def\和暦{\西暦false}
 %    \end{macrocode}
 %
 % \begin{macro}{\heisei}
 % \changes{v1.1m}{1998/04/07}{\cs{today}の計算手順を変更}
+% \changes{v1.8b}{2019/04/02}{\cs{heisei}の値は$\mbox{西暦}-1988$で固定}
 % |\today|コマンドを|\rightmark|で指定したとき、|\rightmark|を出力する部分
 % で和暦のための計算ができないので、クラスファイルを読み込む時点で計算して
 % おきます。
 % \end{macro}
 %
 % \begin{macro}{\today}
+% \begin{macro}{\pltx@today@year}
 % 縦組の場合は、漢数字で出力します。
+% \pLaTeX\ 2018-12-01以前では縦数式ディレクション時でも漢数字で出力していましたが、
+% \pLaTeX\ 2019-04-06以降からはそうしなくなりました。
 %
 % \changes{v1.6-ltj-9}{2015/01/01}{縦組では,この漢数字による日付出力でエラーになりました.
 % Lua\TeX-ja では,\cs{kansuji}の後に\cs{number}を続けることは出来ないので\cs{number}を削除しました.}
+% \changes{v1.8b}{2019/04/02}{\cs{today}の計算・出力方法を変更。}
 %    \begin{macrocode}
-\def\today{{%
-  \ifnum\ltjgetparameter{direction}=3
-    \if西暦
-      \kansuji\year 年
-      \kansuji\month 月
-      \kansuji\day 日
+\def\pltx@today@year@#1{%
+  \ifnum\numexpr\year-#1=1 元\else
+    \ifnum\ltjgetparameter{direction}=3
+      \kansuji\numexpr\year-#1\relax
     \else
-      平成\ifnum\heisei=1 元年\else\kansuji\heisei 年\fi
-      \kansuji\month 月
-      \kansuji\day 日
+      \number\numexpr\year-#1\relax\nobreak
     \fi
+  \fi 年
+}
+\def\pltx@today@year{%
+  \ifnum\numexpr\year*10000+\month*100+\day<19890108
+    昭和\pltx@today@year@{1925}%
+  \else\ifnum\numexpr\year*10000+\month*100+\day<20190501
+    平成\pltx@today@year@{1988}%
+  \else 
+    令和\pltx@today@year@{2018}%
+  \fi\fi}
+\def\today{{%
+  \if西暦
+    \ifnum\ltjgetparameter{direction}=3 \kansuji\year
+    \else\number\year\nobreak\fi 年
   \else
-    \if西暦
-      \number\year~年
-      \number\month~月
-      \number\day~日
-    \else
-      平成\ifnum\heisei=1 元年\else\number\heisei~年\fi
-      \number\month~月
-      \number\day~日
-    \fi
+    \pltx@today@year
+  \fi
+  \ifnum\ltjgetparameter{direction}=3
+    \kansuji\month 月
+    \kansuji\day 日
+  \else
+    \number\month\nobreak 月
+    \number\day\nobreak 日
   \fi}}
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
 %
 %