# jlreq ## What is this? This package provides the class file and JFM (Japanese font metric) files for LuaTeX-ja / pLaTeX / upLaTeX. This aims to implement [Requirements for Japanese Text Layout](https://www.w3.org/TR/jlreq/?lang=en). ## Installation Run `make` to generate JFM files. Move the files as follows: * *.tfm -> $TEXMF/fonts/tfm/public/jlreq * *.vf -> $TEXMF/fonts/vf/public/jlreq * jfm-jlreq.lua, jfm-jlreqv.lua, jfm-jlreq-jidori.lua jfm-jlreqv-jidori.lua -> $TEXMF/tex/luatex/jlreq * jlreq.cls, jlreq-helpers.sty -> $TEXMF/tex/latex/jlreq The other way to install is just to run `make install`. It will install all files in `$TEXMFHOME`. ## Usage To use, simply write ```latex \documentclass{jlreq} ``` This will set up a document class equivalent to an article in horizontal writing. The engine is automatically determined, but if you want to specify it, pass one of `platex/uplatex/lualatex` as a class option. To switch to vertical writing, pass the `tate` option. Additionally, to make the document class equivalent to report or book, pass the `report` or `book` option respectively. For example, to create a vertical book, write `\documentclass[tate,book]{jlreq}`. Other common options accepted are `oneside/twoside/onecolumn/twocolumn/titlepage/notitlepage/draft/final/landscape/openright/openany/leqno/fleqn`. Also, passing the `disablejfam` option will not register Japanese fonts for use in mathematics. You can write the content as you would in a standard document class, but the following commands have been added or extended. Note that this document uses terms from [Requirements for Japanese Text Layout](https://www.w3.org/TR/jlreq/?lang=en) without explanation. ### `\jlreqsetup` This is a command for settings. It can only be used in the preamble. Settings for the document are made either as class options or through `\jlreqsetup`, depending on the setting item. ### `\section` The `\section` command is extended to accept subtitles in addition to the usual format, as in `\section*[running head]{Heading}[Subtitle]`. Other commands such as `\part` (only in article), `\chapter` (only in book/report), `\subsection`, and `\subsubsection` also accept subtitles. ### `abstract` environment You can place it in the preamble, and it will be output with `\maketitle`. In the case of two columns, it allows you to output the abstract without columnization. However, this method is now deprecated. By specifying `abstract_with_maketitle=true` in `\jlreqsetup` and writing it before `\maketitle`, you can achieve the same effect. ### `\sidenote` This command is only defined when the width of the sidenote is positive. In the default basic layout, this width is set to 0. Therefore, `\sidenote` is not defined. Please refer to the later basic layout settings. `\sidenote` outputs a sidenote (or footnote in vertical writing). Internally, it uses `\marginpar`. By default, it has the same format as `\footnote`, but if `sidenote_type=symbol` is specified in `\jlreqsetup`, the format becomes `\sidenote{relevant item}{note}`. For example, you would write: ```latex capable of publishing \sidenote{manuscript}{by methods such as printing…} ``` Please refer to the later explanation as well. ### `\endnote` Specifies an endnote. It has the same format as `\footnote`. By default, the note itself is output just before the heading. This behavior can be controlled by passing `endnote_position` to `\jlreqsetup`. For more details, please see the later explanation of notes. Also, executing `\theendnotes` will output it on the spot. ### `\warichu` Outputs a warichu (split annotation). The line division positions are calculated automatically (multiple compilations are required). With `\warichu*`, you can manually specify these positions. The format is `\warichu*{(before first line) & (after first line)\\ (before second line) & (after second line)...}`. If `&` is omitted, it will be adjusted automatically. ### `\tatechuyoko` Outputs horizontal-in-vertical text. You use it as `\tatechuyoko{}`. `\tatechuyoko` will result in an error if used in a non-vertical writing place, but `\tatechuyoko*` will be output as is in a non-vertical writing place. ### `\jidori` By using `\jidori{}{}`, you can output the content justified to the length of the dimension. ### `\akigumi` By using `\akigumi{}{}`, you can output the result of spacing the characters of the content by the length of the dimension. However, the correct output result is not obtained except when using LuaLaTeX. ### `\jafontsize` Specifies the Japanese font size, similar to `\fontsize`. If `jafontscale=0.9` is specified as a class option, specifying `\fontsize{9pt}{15pt}` will result in a Japanese font size of 8.1pt, but `\jafontsize{9pt}{15pt}` will result in 9pt (with the European font size being 10pt). The second argument is exactly the same as the second argument of `\fontsize`. ### `\ ` A macro consisting of a single full-width space (U+3000). It inserts a Japanese character space. In LuaLaTeX, you can also input a Japanese character space with ` ` alone. ### Others * Ruby and encircled points are not provided. It is recommended to use [PXrubrica](https://github.com/zr-tex8r/PXrubrica) or `luatexja-ruby` (for LuaLaTeX, included in the LuaTeX-ja package). * When using pLaTeX / upLaTeX, macros `\zw` and `\zh` that expand to `zw` and `zh`, respectively, are defined. In LuaLaTeX, macros of the same name are defined within LuaTeX-ja. * Requirements for Japanese Text Layout 2.3.2.d state that it is desirable to align the number of lines in each column on the last page of horizontal two-column typesetting, but this process is not performed. You can perform this process by using the `nidanfloat` package and specifying ````latex \usepackage[balance]{nidanfloat} ```` However, `\newpage` and `\clearpage` on the last page will not work correctly. For more details, please see the manual of the `nidanfloat` package. * The functionality to set fonts is not provided. Japanese fonts can be set using `luatexja-fontspec` or `luatexja-preset` (both included in the LuaTeX-ja package) when using LuaLaTeX. If using dvipdfmx, you can set it with [PXchfon](https://github.com/zr-tex8r/PXchfon). * The space between Japanese characters (stored in `\kanjiskip` in (u)pTeX and in the `kanjiskip` parameter in LuateX-ja) by default allows for up to a quarter-character width of space, in accordance with the Requirements for Japanese Text Layout. However, due to limitations of TeX’s functionality, this may not always produce appropriate results. If you want to change this value, please redefine `\jlreqkanjiskip`. For example: ```latex \documentclass{jlreq} \renewcommand{\jlreqkanjiskip}{0pt plus .1\zw minus .01\zw} \begin{document} (Main text) \end{document} ```` The space between Japanese and European characters (stored in `\xkanjiskip` in (u)pTeX and in the `xkanjiskip` parameter in LuateX-ja) can also be changed by redefining `\jlreqxkanjiskip`. * When specifying `book`, even if you specify `openany` as a class option, a blank page may be inserted after `\mainmatter`. This is to match the behavior of the standard class file. By specifying `\jlreqsetup{mainmatter_pagebreak=clearpage}`, you can prevent the insertion of a blank page, but by default, `\mainmatter` resets the page number, so there may be inconsistencies in the parity of page numbers. Please consider changing to a continuous pagination by specifying something like `\jlreqsetup{frontmatter_pagination={arabic,continuous}}`. For more details, please refer to the following “Front Matter, etc.” section. ## Design options The design is specified in keyval format via class options or `\jlreqsetup`. However, due to LaTeX’s implementation, cases where input that should be possible is not accepted may occur with class options. In many cases, this can be resolved by removing spaces. In the following, the following usage will be used: * `[A/B]`: Either A or B. `[A/B/C]`, etc., are the same. * ``: A dimension recognized by TeX. You can also use simple expressions (like `10pt+10pt`). In class options, you may be able to use special values as follows (these are available in pLaTeX / upLaTeX by default, but are processed to be available in LuaLaTeX as well): In places like `\jlreqsetup`, you can always describe the full-width width with `\zw` or `\zh`. Below, for example, if `Q` and `H` are available, it will be described as ``. - `Q`, `H`: Interpreted as 0.25mm. - `zw`, `zh`: Interpreted as full-width width. * ``: LaTeX code. * ``: Commands for font settings, such as `\Large` or `\bfseries`. Multiple specifications like `\Large\bfseries` are also possible. ### Kihon-hanmen Class option. * `paper=[/{,}]`: Specifies the paper size. You can specify from `a0paper` to `a10paper`, `b0paper` to `b10paper` (ISO B series), or `b0j` to `b10j` for JIS B series. Also available are `letterpaper`, `legalpaper`, and `executivepaper`. Alternatively, you can directly specify dimensions with `{,}`. * `fontsize=`: Specifies the font size for Latin script. The default is 10pt. * `jafontsize=`: Specifies the font size for Japanese script. * `jafontscale=`: The ratio of Japanese font size to Latin font size (Japanese / Latin). Ignored if both `fontsize` and `jafontsize` are specified. The default is 1. * `line_length=`: The length of a line. By default, it's 0.75 times the paper width in the direction of character progression. The actual value is adjusted to be a multiple of the length of one character. * `number_of_lines=`: The number of lines per page. By default, it's a value that makes it 0.75 times the paper height in the direction of line progression. * `gutter=`: The size of the gutter margin. - Without `tate`option: It's the margin on the left for odd pages and on the right for even pages. * With `tate` option: It's the opposite. * If `twoside` is not specified in the class options, the margin is always set as for odd pages. * `fore-edge=`: The size of the fore-edge margin (the side opposite the gutter). It's implemented for convenience, although it's not used when margins are specified according to "Requirements for Japanese Text Layout". * `head_space=`: The amount of space at the top (head). The default value centers the text block vertically. * `foot_space=`: The amount of space at the bottom (foot). The default value centers the text block vertically. * `baselineskip=`: The line feed. By default, it's 1.7 times the `jafontsize`. * `linegap=`: The line gap. * `headfoot_sidemargin=`: The left and right margin for headers and footers. * `column_gap=`: The gap between columns (only for `twocolumn`). * `sidenote_length=`: Specifies the width of the sidenote. ### class option * `open_bracket_pos=[zenkaku_tentsuki/zenkakunibu_nibu/nibu_tentsuki]`: Specifies the positioning of opening brackets at the start of a line. Options are: - `zenkaku_tentsuki`: Full-width characters are indented at the start of a paragraph. - `zenkakunibu_nibu`: Full-width at the start of a paragraph, half-width at a line break. - `nibu_tentsuki`: Half-width indentation at the start of a line. * `hanging_punctuation`: Enables hanging punctuation. ### Reverse pagination class option. * `use_reverse_pagination`: Enables reverse pagination functionality. Defines a ‘read-only counter’ named `jlreqreversepage`. Commands like `\arabic` and `\value` can be applied to it, and `\thejlreqreversepage` is defined as `\arabic{jlreqreversepage}`. ### Note related Specified by `\jlreqsetup`. * `reference_mark=[inline/interlinear]`: Specifies the placement of reference marks. Options are `inline` (in the line after the relevant item) or `interlinear` (above the line for horizontal writing, or to the right for vertical writing). * `footnote_second_indent=`: Sets the indent for the second and subsequent lines of footnotes (horizontal writing) or sidenotes (vertical writing). * `sidenote_type=[number/symbol]`: Determines the correspondence between the sidenote and the text. Options are `number` (default, with a serial number indicating the note) or `symbol` (with a specific symbol and the word with the note emphasized). * `sidenote_symbol=`: When `sidenote_type=symbol` is specified, this sets the symbol to be used at the note's location. THe default is * * `sidenote_keyword_font=`: Specifies the font for the word with the sidenote when `sidenote_type=symbol` is used. * `endnote_second_indent=`: Sets the indent for the second and subsequent lines of endnotes. ` endnote_position=[headings/paragraph/{_,_,...}]`: The output location of the endnote can be specified. `headings` will output the note before each heading (default), `paragraph` will output it when a new paragraph starts, and specifying `endnote_position={_chapter,_section}` will output it before `\chapter` and `\section`. To specify `<_heading name>`, the target heading must be created using the functionality of this class file. * `warichu_opening=`, `warichu_closing=`: These are inserted before and after the warichu (split annotation). The default is parentheses (). ### Caption You can change the captions for figures and tables using `\jlreqsetup`. All settings allow for environment-specific customization. For example, `caption_font=\normalsize,table=\Large` means that within the table environment, `\Large` will be applied, while `\normalsize` will be applied in other environments. Other settings follow the same pattern. * `caption_font=`: Specifies the font for the caption itself. * `caption_label_font=`: Specifies the font for the caption label. * `caption_after_label_space=`: Specifies the space between the label and the caption text. * `caption_label_format=`: Specifies the format of the label. For example, `caption_label_format={#1:}` where `#1` is replaced with something like “Figure 1”. * `caption_align=[left/right/center/bottom/top]`: Specifies the position of the caption. For instance, `{center,*left}` means it’s usually centered, but aligned left when the caption is large. ### Quotation * `quote_indent=`: Specifies the indentation for quotes. The default is `2\zw`. The length of a line is adjusted to be an integer multiple of the character size. * `quote_end_indent=`: Specifies the indentation for the end of quotes. The default is `0\zw`. * `quote_beforeafter_space=`: Specifies the space before and after quotes. Setting `quote_beforeafter_space=1\baselineskip` will result in a one-line space. * `quote_fontsize=[normalsize/small/footnotesize/scriptsize/tiny]`: Specifies the font size for quotes. ### Itemization * `itemization_beforeafter_space=`: Specifies the space before and after the itemization. For example, `itemization_beforeafter_space={i=}` sets the space for the top level only. `itemization_beforeafter_space={0pt,i=10pt,ii=5pt}` sets 10pt for level 1 itemization, 5pt for level 2, and 0pt for others. Levels are indicated by lowercase Roman numerals. * `itemization_itemsep=`: Specifies the space between items. ### Front matter etc. You can specify the behavior of `\frontmatter` / `\mainmatter` / `\backmatter` / `\appendix` with `\jlreqsetup`. * `frontmatter_pagebreak=[cleardoublepage/clearpage]`: Specifies the command name to execute the page break at `\frontmatter`. If it is empty, nothing is done. * `frontmatter_counter={={value=, the=, restore=[true/false]},…}`: Specifies the operation of the counter at `\frontmatter`. For example, `chapter={value=0,the={[\arabic{chapter]}}` sets the value of the chapter counter to 0 and `\thechapter` to `[\arabic{chapter}]`. By default, the value and `\the` definition are restored at `\mainmatter`, but this behavior is suppressed by specifying Prestore=false`. * `frontmatter_heading={={},…}`: Changes the behavior of the heading command. In addition to the items that can be specified by `\Delare***Heading`, the following are accepted. - `heading_type=[Tobira/Block/Runin/Cutin/Modify]`: The type of heading1. If Modify is specified, it will be changed by `\ModifyHeading`. - `heading_level=`: Specifies the level of the heading command. If not specified, the value at `\frontmatter` is used. This is ignored when `heading_type=Modify`. - `restore=[true/false]`: If true is specified, the original definition is restored at `\mainmatter`. The default is true. * `frontmatter_pagestyle={[,restore=[true/false]]}`: Switches to the specified page style at `\frontmatter`. By default, it returns to the original page style at `\mainmatter`, but this can be prevented by specifying `restore=false`. * `frontmatter_pagination={[,continuous,independent]}`: Specifies the output format of the page number, such as `frontmatter_pagination=roman`, with the LaTeX command name. In addition, continuous makes it a continuous number, and independent makes it a separate number. * `frontmatter_precode=`: The code that is executed first at `\frontmatter`. * `frontmatter_postcode=`: The code that is executed last at `\frontmatter`. There are also settings that change `frontmatter` to `mainmatter`, `backmatter`, or `appendix`. However, there are some differences as follows. * `restore=[true/false]` is an invalid setting. * Pmainmatter_pagination` cannot specify continuous or independent. * `appendix_pagebreak`, `appendix_pagestyle`, `appendix_pagination` do not exist. #### Abstract * `abstract_with_maketitle=[true/false]`: If the abstract environment is written before `\maketitle`, it delays its content and outputs it with `\maketitle`. Even in the case of two columns, it is output in one column. The default is false. This option is available only when `article` and `report` are specified. ## Headings You can create new headings with commands like `\New***Heading` ( is a string that corresponds to the type of heading). The format is always `\New***Heading{}{}{}`. Also, `\Renew***Heading`, `\Provide***Heading`, and `\Declare***Heading` are available at the same time. They are respectively * `\Renew***Heading`: If the command with the specified name is not defined, it causes an error. * `\Provide***Heading`: If the command with the specified name is not defined, it defines a new heading command. * `\Declare***Heading`: It defines a new heading command regardless of whether the command with the specified name is defined or not. ### Tobira headings You can create it with \NewTobiraHeading. It creates a command with the same format as the usual class file’s \section and so on. The settings are as follows. . * `type=[han/naka]`: It creates a half-title heading if `han` is specified, and a middle-title heading if `naka` is specified. * `pagestyle=`: It specifies the page style of the heading area. * `label_format=`: It specifies the command to output the label. For example, specify it as `label_format={Chapter \thechapter}`. * `format=`: It specifies the format to actually output. `#1` is replaced with the label, `#2` with the heading text. In this case, the commands `\jlreqHeadingLabel` and `\jlreqHeadingText` are available internally. They are commands that take one argument each, and output the given argument itself if the label and heading text are not empty, respectively, and output nothing otherwise. For example, if you specify it as `format={[\jlreqHeadingLabel{Label=#1}]}`, it outputs `[Label=