jlreq LaTeX Document Class

repository·master·Indexed 41 days ago

https://github.com/abenori/jlreq

A LaTeX document class and package that implements the 'Requirements for Japanese Text Layout'. It provides specialized tools for Japanese typesetting, including vertical writing, warichu, and character spacing, along with configuration options for layout, pagination, and structural elements via \jlreqsetup.

Tokens
13.8K
Snippets
49
Records
65
Agent score
48%

What's inside jlreq

  1. Understand JFM (Japanese Font Metric) naming in jlreq

    master

    The jlreq class uses specific JFM names. If you use other packages, ensure they do not override these settings if you want to maintain jlreq's typography.

    pLaTeX / upLaTeX

    The JFM name follows the pattern [u][b][z]jlreq[g][-v]. The flags are:

    • u: Used with upLaTeX.
    • b: Used when hanging_punctuation is specified in class options.
    • z: Used when open_bracket_pos=zenkakunibu_nibu is specified.
    • g: For Gothic fonts.
    • -v: For vertical writing. Example: A pLaTeX source with open_bracket_pos=zenkakunibu_nibu but without hanging punctuation uses zjlreq for horizontal Mincho.

    LuaLaTeX

    • Horizontal writing: jlreq
    • Vertical writing: jlreqv (also used for Gothic).
  2. Enable reverse pagination

    master

    The use_reverse_pagination class option enables reverse pagination functionality. This defines a read-only counter named jlreqreversepage. You can interact with it using standard LaTeX commands:

    • \thejlreqreversepage: Returns the counter value as an Arabic numeral.
    • \arabic{jlreqreversepage}: Standard counter access.
    • \value{jlreqreversepage}: Standard counter access.
    \documentclass[use_reverse_pagination]{jlreq}
  3. Configure jlreq using class options or \jlreqsetup

    master

    The jlreq class uses a keyval format for configuration. You can set parameters via document class options or the \jlreqsetup command.

    Note on Class Options: Due to LaTeX implementation constraints, some inputs might not be accepted directly as class options. A common workaround is to remove spaces from the option values.

    Syntax Conventions:

    • [A/B]: Selects option A or B (e.g., [A/B/C]).
    • <dimension>: Standard TeX dimensions. You can use expressions like 10pt+10pt.
      • Special values: Q and H are interpreted as 0.25mm.
      • Full-width units: Use \zw or \zh within \jlreqsetup to specify full-width dimensions.
    • <code ext>: Raw LaTeX code.
    • <font_setting_code ext>: Font commands like \Large or \bfseries.
    • <counter_name ext>: Name of a LaTeX counter.
  4. Understand JFM (Japanese Font Metric) behavior in jlreq

    master

    The jlreq class uses custom JFMs to ensure correct Japanese typesetting. Depending on your engine and class options, different JFM names are applied.

    pLaTeX / upLaTeX

    JFM names follow the pattern [u][b][z]jlreq[g][-v].

    • u: used with upLaTeX.
    • b: used if hanging_punctuation option is enabled.
    • z: used if open_bracket_pos=zenkakunibu_nibu is enabled.
    • g: used for gothic fonts.
    • -v: used for vertical writing.

    Example: Using pLaTeX with open_bracket_pos=zenkakunibu_nibu but without hanging punctuation results in the JFM zjlreq for horizontal mincho.

    LuaLaTeX

    • Horizontal writing: jlreq
    • Vertical writing: jlreqv
    • Gothic fonts use the same JFM as mincho.

    Note: If you use other packages that reset JFM settings, you may need to explicitly set package options to maintain the jlreq JFMs.

  5. Use the jlreq document class

    master

    The jlreq class implements the requirements for Japanese typesetting. It works with pLaTeX, upLaTeX, and LuaLaTeX engines.

    By default, \documentclass{jlreq} creates a horizontal-writing article-equivalent document.

    Engine Selection: While the engine is detected automatically, you can explicitly specify it via class options: platex, uplatex, or lualatex.

    Document Layout Options:

    • tate: Enables vertical writing.
    • report: Sets the class to report equivalent.
    • book: Sets the class to book equivalent.
    • Standard options like oneside, twoside, onecolumn, twocolumn, titlepage, notitlepage, draft, final, landscape, openright, openany, leqno, and fleqn are supported.
    • disablejfam: Prevents Japanese fonts from being registered for math mode.

    Examples:

    To create a vertical book:

    \documentclass[tate,book]{jlreq}
  6. Install the jlreq class and JFM files

    master

    To use jlreq, you must first generate the necessary Japanese Font Metric (JFM) files using make. Once generated, place the files in your TeX tree as follows:

    • *.tfm $\rightarrow$ $TEXMF/fonts/tfm/public/jlreq
    • *.vf $\rightarrow$ $TEXMF/fonts/vf/public/jlreq
    • jfm-jlreq.lua, jfm-jlreqv.lua, jfm-jlreq-jidori.lua, jfm-jlreqv-jidori.lua $\rightarrow$ $TEXMF/tex/luatex/jlreq
    • jlreq.cls, jlreq-helpers.sty $\rightarrow$ $TEXMF/tex/latex/jlreq

    You can automate this process by running make install, which will copy the files to $TEXMFHOME.

    make
    make install
  7. Install the jlreq package

    master

    You can install the jlreq package using one of two methods:

    Method 1: Automatic Installation

    Run the following command to install all files into your $TEXMFHOME directory:

    make install

    Method 2: Manual Installation

    1. Generate the JFM files by running:
      make
    2. Move the generated files to the following locations in your $TEXMF tree:
      • *.tfm $\rightarrow$ $TEXMF/fonts/tfm/public/jlreq
      • *.vf $\rightarrow$ $TEXMF/fonts/vf/public/jlreq
      • jfm-jlreq.lua, jfm-jlreqv.lua, jfm-jlreq-jidori.lua, jfm-jlreqv-jidori.lua $\rightarrow$ $TEXMF/tex/luatex/jlreq
      • jlreq.cls, jlreq-helpers.sty $\rightarrow$ $TEXMF/tex/latex/jlreq
  8. Use jlreq-trimmarks in LaTeX

    master

    Load the package using egin{document} with the \[\usepackage] command. You must specify the TeX engine and the DVI driver.

    Important: Do not use the tombow option in your document class when using this package.

    If you encounter conflicts with paper size settings, consider using a more powerful package like bxpapersize.

    \usepackage[dvipdfmx,platex]{jlreq-trimmarks}
  9. Configure Japanese fonts in LuaLaTeX

    master

    The jlreq class does not provide built-in functionality for setting fonts. When using LuaLaTeX, you should use the following packages (included in the LuaTeX-ja package):

    • luatexja-fontspec
    • luatexja-preset

    If you are using dvipdfmx, it is recommended to use the PXchfon package.

  10. Configure bracket positioning and hanging punctuation

    master

    Use these class options to control how punctuation and brackets behave at the start of lines.

    • open_bracket_pos=[zenkaku_tentsuki/zenkakunibu_nibu/nibu_tentsuki]: Controls indentation of opening brackets at the start of a paragraph:
      • zenkaku_tentsuki: Full-width characters are indented.
      • zenkakunibu_nibu: Full-width at start of paragraph, half-width at line breaks.
      • nibu_tentsuki: Half-width indentation at the start of a line.
    • hanging_punctuation: Enables hanging punctuation.
    \documentclass[open_bracket_pos=zenkakunibu_nibu, hanging_punctuation]{jlreq}
  11. Enable typesetting notifications with jlreq_notes

    master
    If you pass the class option jlreq_notes, the class will provide notifications when you make settings that contradict standard Japanese typesetting processing rules.