Created
June 14, 2018 00:49
-
-
Save zr-tex8r/80e763a756fc43fd88e3f4d9c887ef8a to your computer and use it in GitHub Desktop.
LaTeX: (u)pLaTeX/LuaTeX-jaの総称シリーズ設定について和文を別にするやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% | |
%% This is file 'bxjaseries.sty'. | |
%% | |
%% Copyright (c) 2018 Takayuki YATO (aka. "ZR") | |
%% GitHub: https://github.com/zr-tex8r | |
%% Twitter: @zr_tex8r | |
%% | |
%% This package is distributed under the MIT License. | |
%% | |
%% package declaration | |
\NeedsTeXFormat{LaTeX2e} | |
\ProvidesPackage{bxjaseries}[2018/06/08 v0.2] | |
\def\bxjb@pkgname{bxjaseries} | |
\providecommand\bxDebug[1]{} | |
%--------------------------------------- main | |
%% \bxjb@fix@one@series{<label>}{<series>} | |
\@onlypreamble\bxjb@fix@one@series | |
\def\bxjb@fix@one@series#1#2{% | |
\begingroup | |
\expandafter\bxjb@fix@one@series@a\csname | |
\expandafter\ifx\csname #1series \endcsname\relax | |
#1series\else #1series \fi | |
\expandafter\endcsname\csname | |
#1series% | |
\expandafter\endcsname\csname | |
\expandafter\ifx\csname math#1\endcsname\relax | |
relax\else math#1\fi | |
\expandafter\endcsname\csname | |
#1default% | |
\expandafter\endcsname\csname | |
kanji#1default% | |
\endcsname{#1}{#2}% | |
\endgroup} | |
\@onlypreamble\bxjb@fix@one@series@a | |
\def\bxjb@fix@one@series@a#1#2#3#4#5#6#7{% | |
%\[XXseries ]\mathXX\XXseries\XXdefault\kanjiXXdefault{XX}{<ser>} | |
% patch to \XXseries | |
\ifx#1\relax | |
\bxDebug{'\string#1' is undefined.}% | |
\else | |
\long\def\bxjb@tmpa{% standard one | |
\not@math@alphabet#2#3\fontseries#4\selectfont}% | |
\ifx#1\bxjb@tmpa | |
\bxDebug{'\string#1' is standard.}% | |
\long\gdef#1{% | |
\not@math@alphabet#2#3\romanseries#4\kanjiseries#5\selectfont}% | |
\else | |
\bxDebug{'\string#1' is non-standard.}% | |
\g@addto@macro#1{\kanjiseries#5\selectfont} | |
\fi | |
\fi | |
% change \kanjiseriesdefault | |
\long\def\bxjb@tmpa{#4}% | |
\ifx\kanjiseriesdefault\bxjb@tmpa | |
\long\gdef\kanjiseriesdefault{#5}% | |
\bxDebug{\string\kanjiseriesdefault: \string#4 -> \string#5.} | |
\fi | |
% resolve \kanjiXXdefault | |
\long\def\bxjb@tmpa{#4\@empty}% | |
\ifx#5\bxjb@tmpa % is untouched | |
\ifx#1\relax | |
\global\let#5\@undefined % annihilate | |
\else | |
\expandafter\ifx\csname % ja-family is lack of XXdefault series | |
\kanjiencodingdefault/\kanjifamilydefault/#4/n% | |
\endcsname\relax | |
\gdef#5{#7}% change to the safe series | |
\else | |
\xdef#5{#4}% settle the series | |
\fi | |
\bxDebug{\string#5 = #5}% | |
\fi | |
\fi} | |
%% \bxjb@prepare@one@series{<series>} | |
\@onlypreamble\bxjb@prepare@one@series | |
\def\bxjb@prepare@one@series#1{% | |
\edef\bxjb@tmpa{% | |
\noexpand\newcommand | |
\expandafter\noexpand\csname kanji#1default\endcsname{% | |
\expandafter\noexpand\csname#1default\endcsname | |
\noexpand\@empty}% | |
}\bxjb@tmpa} | |
%%<+> \bxjaseriesApplyPatch | |
\@onlypreamble\bxjaseriesApplyPatch | |
\newcommand*\bxjaseriesApplyPatch{% | |
\global\let\bxjaseriesApplyPatch\relax} | |
\AtBeginDocument{% | |
\bxjaseriesApplyPatch} | |
%% target series | |
\def\do#1#2{% | |
\g@addto@macro\bxjaseriesApplyPatch{% | |
\bxjb@fix@one@series{#1}{#2}}% | |
\bxjb@prepare@one@series{#1}} | |
\do{md}{m} | |
\do{bf}{bx} | |
\do{lt}{l} | |
\do{eb}{eb} | |
%--------------------------------------- done | |
\endinput | |
%% EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
文書開始時点(または
\bxjaseriesApplyPatch
実行時)に以下の処理を行う。\bfseries
について、和文は\bfdefault
ではなく\kanjibfdefault
を使うようにする。\kanjibfdefault
の初期値は\bfdefault
と同じにする。ただし、既定和文ファミリ(\kanjifamilydefault
)にそのシリーズ(のn
シェープ)が存在しない場合は、代わりにbx
とする。\kanjiseriesdefault
の値が\bfdefault
と同じであったなら\kanjibfdefault
と同じ値に変更する。