Closed Yarakashi-Kikohshi closed 2 years ago
Hi @Yarakashi-Kikohshi , thank you for your interest and for your suggestions.
I'd like to know more, if that's OK for you. But I don't want to get you on high hopes since, as far as I can tell from what you already described, I don't think zref-clever
can handle these requirements. Or at least not in fully general form. Truth is the package was designed with western European languages in mind (unfortunately, that's all I'm acquainted with...). But let's see if we can reach some setup which would render the package at least minimally useful for Japanese speakers.
Some things I'd like to understand better:
You suggested the inclusion of a namesep-pos
, but I don't understand its purpose. Would it be meant to be between ref
and name-pos
? Is that it? (I'm in doubt, for I don't see a space in the examples you provided).
You mention the following:
When you want to refer to multiple chapters in Japanese, this is because there are various cases.
For example, when referring to two consecutive chapters, the following three are possible.
- 第1,2章
- 第1章,2章
- 第1章,第2章
I don't know how to write it more commonly. And, I think other patterns need to be discussed as well.
As you found out, we could (ab)use refpos
to get the second case (not note
though, since it is not type-specific). But my first reaction here is that it is probably impossible to reach the other two, given how the package is constructed. Anyway, what determines which case should be used in any given situation? Is it preference? Is it context? If it is an arbitrary choice, would a document employ always one of them, or a variation of the cases could be used too?
How useful would it be if only case 2. can be produced?
chapters 1, 2 and 4 chapters 3 and 5, sections 1,3 and 6, and figure 8 figures 3, 6 and 8, tables 7 to 9, and equations 4 and 2 to 5
- There is no declension.
- There is no grammatical gender.
- Not case sensitive.
- There is no difference between the singular and the plural.
This may simplify some things, but the difficult part here is indeed the name part after the reference.
- There are some types of references that require name before and after type-group.
"Some" types? Not all of them? Is there a general rule?
Hi @gusbrs , it took me a while to answer, I'm sorry.
Truth is the package was designed with western European languages in mind (unfortunately, that's all I'm acquainted with...). But let's see if we can reach some setup which would render the package at least minimally useful for Japanese speakers.
This can't be helped. However, I am glad that you can consider it positively. :blush:
You suggested the inclusion of a
namesep-pos
, but I don't understand its purpose. Would it be meant to be between ref andname-pos
? Is that it?
Yes. To put it simply, I assumed something like the following:
"[Nn]ame-" "namesep" "ref" "namesep-pos" "name-pos"
I thought it would be necessary symmetrically, as namesep
was the separater between [Nn]ame-
and ref
.
In addition, I don't think there should be line breaks between ref
and name-pos
.
I'm in doubt, for I don't see a space in the examples you provided
For this part, it seems that special processing in Japanese and Western composition needs to be considered.
Before and after Western composition in Japanese composition must insert special spaces called "quarter em spaces".
The special space is automatically inserted between Japanese and Western composition by xkanjiskip
.
If you insert a half-width space manually, this special space will be lost.
Therefore, in Japanese composition, half-width spaces should not be inserted before and after arabic numeric.
It seems that this process is not well known to anyone other than the Japanese. (Actually, I also didn't know it well.)
Regarding "quarter em spaces", I think you can know from the following:
You can find out about xkanjiskip
from texdoc
as follows.
$ texdoc japanese
$ texdoc luatexja
Anyway, what determines which case should be used in any given situation? Is it preference? Is it context? If it is an arbitrary choice, would a document employ always one of them, or a variation of the cases could be used too?
Maybe, which case to use is arbitrary and preference. But, it is used only one of them. No multiple cases are used in one document. Sorry for not knowing exactly which case is the best way.
However, it may have been established as a standard rule as an official outline of Japanese. I think JIS may correspond to them.
How useful would it be if only case 2. can be produced?
Rather, it may be most desirable that Case 2. be realized.
When I checked how cleveref was set when creating the various examples shown below, it seemed that the 2nd method was adopted.
1. 第1,2章
2. 第1章,2章 ← often used in cleveref
3. 第1章,第2章
I'd like some more examples. How would one write, in each of the relevant cases you mentioned above, the following references?:
Just in case, I will create Japanese-English correspondence table:
Japanese | English |
---|---|
章 | chapter |
節 | section |
図 | figure |
表 | table |
式 | equation |
For "chapter", I will show each of the three cases. (In the same order)
chapters 1, 2 and 4
第1,2章,および4章
第1章,2章,および4章
第1章,第2章,および第4章
chapters 3 and 5, sections 1,3 and 6, and figure 8
第3,5章,第1,3節,および6節,図8
第3章,5章,第1節,3節,および6節,図8
第3章,第5章,第1節,第3節,および第6節,図8
figures 3, 6 and 8, tables 7 to 9, and equations 4 and 2 to 5
I think the reference number is strange, but it looks like this:
図3,6,および8,表7から9,式4と2から5
For these, I referred to articles related to LaTeX using cleveref.
cleveref | Settings for Japanese |
---|---|
\crefrangeconjunction |
から or -- or ~ |
\crefpairconjunction |
と or , |
\crefmiddleconjunction |
, |
\creflastconjunction |
,および or , |
\crefpairgroupconjunction |
, |
\crefmiddlegroupconjunction |
, |
\creflastgroupconjunction |
, |
\crefrangepreconjunction} |
none |
\crefrangepostconjunction} |
none |
The code for the settings in cleveref looks like this:
\crefname{chapter}{第}{第}
\crefname{section}{第}{第}
\crefname{figure}{図}{図}
\crefname{table}{表}{表}
\crefname{equation}{式}{式}
\creflabelformat{chapter}{#2#1{}章#3}
\creflabelformat{section}{#2#1{}節#3}
\newcommand{\crefrangeconjunction}{から}
\newcommand{\crefpairconjunction}{と}
\newcommand{\crefmiddleconjunction}{,}
\newcommand{\creflastconjunction}{,および}
\newcommand{\crefpairgroupconjunction}{,}
\newcommand{\crefmiddlegroupconjunction}{,}
\newcommand{\creflastgroupconjunction}{,}
- There are some types of references that require name before and after type-group.
"Some" types? Not all of them? Is there a general rule?
It was an ambiguous expression. I'll write it in as much detail as possible.
Like the "chapter", the heading requires a name
before and after the type-group
.
第1部
)第2章
)第3節
)第4項
)If you try to write the following two in Japanese, you only need the name at right side. Which style to use is up to the editor.
5ページ
or p.5
pp.5
)6行目
or l.6
)I apologize that it may be causing a lot of confusion.
Hi @Yarakashi-Kikohshi , I'm still processing your answer, but I'd like to ask you something else, which might be helpful. So cleveref
can be made to work for Japanese, hence probably (or hopefully ;-) zref-clever
can do something similar. With this in mind, could you provide a MWE with a cleveref
setup for Japanese? Since cleveref
does not support it out of the box, I suppose you have one at hand. This would be useful for two reasons, a good concrete starting point on technical requirements that I'm better acquainted with and, since I don't know how to setup LaTeX for Japanese, it would spare me starting from scratch for something which is probably trivial to you.
I'm sorry it took me a while to reply again. :pensive:
Use upLaTeX+dvipdfmx or LuaLaTeX to compile the document. These are the mainstream methods. Either method will give you similar results.
Document body is not a particularly meaningful sentence, but I think it is sufficient to verify cross-references.
Note: these have slightly different preambles.
ptex2pdf
takes care of the uplatex
and dvipdfmx
sequence in one step.
Run the following in a terminal.
$ ptex2pdf -u -l -ot -kanji=utf8 mweja-ptex.tex
% mweja-ptex.tex
\documentclass[uplatex,dvipdfmx,report,11pt,a4paper]{jlreq}
\usepackage{amsmath}
\usepackage{cleveref}
\crefname{chapter}{第}{第}
\crefname{section}{第}{第}
\crefname{figure}{図}{図}
\crefname{table}{表}{表}
\crefname{equation}{式}{式}
\creflabelformat{chapter}{#2#1{}章#3}
\creflabelformat{section}{#2#1{}節#3}
\newcommand{\crefrangeconjunction}{から}
\newcommand{\crefpairconjunction}{と}
\newcommand{\crefmiddleconjunction}{,}
\newcommand{\creflastconjunction}{,および}
\newcommand{\crefpairgroupconjunction}{,}
\newcommand{\crefmiddlegroupconjunction}{,}
\newcommand{\creflastgroupconjunction}{,}
\begin{document}
% chapters 1, 2 and 4
\cref{chp:1,chp:2,chp:4}
% chapters 3 and 5, sections 1,3 and 6, and figure 8
\cref{chp:3,chp:5,sec:1,sec:3,sec:4,sec:5,sec:6,fig:8}
% figures 3, 6 and 8, tables 7 to 9, and equations 1 and 3 to 5
\cref{fig:3,fig:6,fig:7,fig:8,tbl:7,tbl:8,tbl:9,eqn:1,eqn:3,eqn:4,eqn:5}
\chapter{1}\label{chp:1}
\chapter{2}\label{chp:2}
\chapter{3}\label{chp:3}
\chapter{4}\label{chp:4}
\chapter{5}\label{chp:5}
\section{1節}\label{sec:1}
\section{2節}\label{sec:2}
\section{3節}\label{sec:3}
\section{4節}\label{sec:4}
\section{5節}\label{sec:5}
\section{6節}\label{sec:6}
\section{7節}\label{sec:7}
\begin{table}[tbp]\centering\caption{demo table 1}\label{tbl:1}\end{table}
\begin{table}[tbp]\centering\caption{demo table 2}\label{tbl:2}\end{table}
\begin{table}[tbp]\centering\caption{demo table 3}\label{tbl:3}\end{table}
\begin{table}[tbp]\centering\caption{demo table 4}\label{tbl:4}\end{table}
\begin{table}[tbp]\centering\caption{demo table 5}\label{tbl:5}\end{table}
\begin{table}[tbp]\centering\caption{demo table 6}\label{tbl:6}\end{table}
\begin{table}[tbp]\centering\caption{demo table 7}\label{tbl:7}\end{table}
\begin{table}[tbp]\centering\caption{demo table 8}\label{tbl:8}\end{table}
\begin{table}[tbp]\centering\caption{demo table 9}\label{tbl:9}\end{table}
\begin{figure}[tbp]\centering\caption{demo figure 1}\label{fig:1}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 2}\label{fig:2}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 3}\label{fig:3}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 4}\label{fig:4}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 5}\label{fig:5}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 6}\label{fig:6}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 7}\label{fig:7}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 8}\label{fig:8}\end{figure}
\begin{align}
\text{demo equation 1}\label{eqn:1}\\
\text{demo equation 2}\label{eqn:2}\\
\text{demo equation 3}\label{eqn:3}\\
\text{demo equation 4}\label{eqn:4}\\
\text{demo equation 5}\label{eqn:5}
\end{align}
\end{document}
The following warning will remain, but it is not a problem.
LaTeX Warning: Unused global option(s):
[dvipdfmx].
This is probably the easiest way to do it.
Run the following in a terminal.
$ lualatex mweja-lua.tex
% mweja-lua.tex
\documentclass[report,11pt,a4paper]{jlreq}
\usepackage{luatexja}
\usepackage{amsmath}
\usepackage{cleveref}
\crefname{chapter}{第}{第}
\crefname{section}{第}{第}
\crefname{figure}{図}{図}
\crefname{table}{表}{表}
\crefname{equation}{式}{式}
\creflabelformat{chapter}{#2#1{}章#3}
\creflabelformat{section}{#2#1{}節#3}
\newcommand{\crefrangeconjunction}{から}
\newcommand{\crefpairconjunction}{と}
\newcommand{\crefmiddleconjunction}{,}
\newcommand{\creflastconjunction}{,および}
\newcommand{\crefpairgroupconjunction}{,}
\newcommand{\crefmiddlegroupconjunction}{,}
\newcommand{\creflastgroupconjunction}{,}
\begin{document}
% chapters 1, 2 and 4
\cref{chp:1,chp:2,chp:4}
% chapters 3 and 5, sections 1,3 and 6, and figure 8
\cref{chp:3,chp:5,sec:1,sec:3,sec:4,sec:5,sec:6,fig:8}
% figures 3, 6 and 8, tables 7 to 9, and equations 1 and 3 to 5
\cref{fig:3,fig:6,fig:7,fig:8,tbl:7,tbl:8,tbl:9,eqn:1,eqn:3,eqn:4,eqn:5}
\chapter{1}\label{chp:1}
\chapter{2}\label{chp:2}
\chapter{3}\label{chp:3}
\chapter{4}\label{chp:4}
\chapter{5}\label{chp:5}
\section{1節}\label{sec:1}
\section{2節}\label{sec:2}
\section{3節}\label{sec:3}
\section{4節}\label{sec:4}
\section{5節}\label{sec:5}
\section{6節}\label{sec:6}
\section{7節}\label{sec:7}
\begin{table}[tbp]\centering\caption{demo table 1}\label{tbl:1}\end{table}
\begin{table}[tbp]\centering\caption{demo table 2}\label{tbl:2}\end{table}
\begin{table}[tbp]\centering\caption{demo table 3}\label{tbl:3}\end{table}
\begin{table}[tbp]\centering\caption{demo table 4}\label{tbl:4}\end{table}
\begin{table}[tbp]\centering\caption{demo table 5}\label{tbl:5}\end{table}
\begin{table}[tbp]\centering\caption{demo table 6}\label{tbl:6}\end{table}
\begin{table}[tbp]\centering\caption{demo table 7}\label{tbl:7}\end{table}
\begin{table}[tbp]\centering\caption{demo table 8}\label{tbl:8}\end{table}
\begin{table}[tbp]\centering\caption{demo table 9}\label{tbl:9}\end{table}
\begin{figure}[tbp]\centering\caption{demo figure 1}\label{fig:1}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 2}\label{fig:2}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 3}\label{fig:3}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 4}\label{fig:4}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 5}\label{fig:5}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 6}\label{fig:6}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 7}\label{fig:7}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 8}\label{fig:8}\end{figure}
\begin{align}
\text{demo equation 1}\label{eqn:1}\\
\text{demo equation 2}\label{eqn:2}\\
\text{demo equation 3}\label{eqn:3}\\
\text{demo equation 4}\label{eqn:4}\\
\text{demo equation 5}\label{eqn:5}
\end{align}
\end{document}
In Japan, the following two methods are used:
upLaTeX is a LaTeX engine for processing Japanese (Supports Unicode).
LuaLaTeX uses LuaTeX-ja to process Japanese.
Unfortunately, it is said that pdfLaTeX and XeLaTeX have not yet developed a way to handle Japanese well. I don't know if babel or polyglossia will be able to handle Japanese well, but I think that few people in Japan compile using these in general.
Note: If you are using TeX Live, LuaTeX-ja and jlreq are included in collection-langjapanese
.
Hi @Yarakashi-Kikohshi , I'm glad I asked for the examples, I'd probably stumble quite a lot to get there, if at all. :-) Thank you.
Please allow some time for me to look into it and think this through.
Hi @Yarakashi-Kikohshi , I've been working on this and have some stuff you'll probably like. :smile:
I've extended the mechanism for setting the reference block parts with a new option refbounds
, which will be part of the next release. (To check the documentation for it, run l3build doc
form the root of a local clone of the repository, Sections "Reference format" and "Advanced reference formatting").
I believe it should cover all the needs for the different cases you presented. Not that I grasped well what they require, but the new option covers all logical possibilities the package is able to distinguish, so currently it is "as far as it can go". It is similar in the degree of flexibility offered by \creformat
and friends (which is a lot).
However, one thing you suggested / requested which I've put some thought about, but which I'm not willing to accommodate, is to provide an option named "namerefbounds
is a general positional option and just calling it "name" would not only not help much, but would complicate maintainability. Besides, the business of handling type names in the package, and their capitalization and abbreviation, is only available for the current [Nn]ame-
options. So, calling refbounds
"name
That said, I have transposed the luatex
example for the current implementation of zref-clever
:
\documentclass[report,11pt,a4paper]{jlreq}
\usepackage{luatexja}
\usepackage{amsmath}
\usepackage[lang=japanese]{zref-clever}
\zcDeclareLanguage[allcaps]{japanese}
\zcLanguageSetup{japanese}{
namesep = {} ,
pairsep = {と} ,
listsep = {,} ,
lastsep = {,および} ,
tpairsep = {,} ,
tlistsep = {,} ,
tlastsep = {,} ,
rangesep = {から} ,
type=chapter,
Name-sg={第},
Name-pl={第},
refbounds={,,{}章,},
type=section,
Name-sg={第},
Name-pl={第},
refbounds={,,{}節,},
type=figure,
Name-sg={図},
Name-pl={図},
type=table,
Name-sg={表},
Name-pl={表},
type=equation,
Name-sg={式},
Name-pl={式},
}
\usepackage{hyperref}
\begin{document}
% chapters 1, 2 and 4
\zcref{chp:1,chp:2,chp:4}
% chapters 3 and 5, sections 1,3 and 6, and figure 8
\zcref{chp:3,chp:5,sec:1,sec:3,sec:4,sec:5,sec:6,fig:8}
% figures 3, 6 and 8, tables 7 to 9, and equations 1 and 3 to 5
\zcref{fig:3,fig:6,fig:7,fig:8,tbl:7,tbl:8,tbl:9,eqn:1,eqn:3,eqn:4,eqn:5}
\chapter{1}\zlabel{chp:1}
\chapter{2}\zlabel{chp:2}
\chapter{3}\zlabel{chp:3}
\chapter{4}\zlabel{chp:4}
\chapter{5}\zlabel{chp:5}
\section{1節}\zlabel{sec:1}
\section{2節}\zlabel{sec:2}
\section{3節}\zlabel{sec:3}
\section{4節}\zlabel{sec:4}
\section{5節}\zlabel{sec:5}
\section{6節}\zlabel{sec:6}
\section{7節}\zlabel{sec:7}
\begin{table}[tbp]\centering\caption{demo table 1}\zlabel{tbl:1}\end{table}
\begin{table}[tbp]\centering\caption{demo table 2}\zlabel{tbl:2}\end{table}
\begin{table}[tbp]\centering\caption{demo table 3}\zlabel{tbl:3}\end{table}
\begin{table}[tbp]\centering\caption{demo table 4}\zlabel{tbl:4}\end{table}
\begin{table}[tbp]\centering\caption{demo table 5}\zlabel{tbl:5}\end{table}
\begin{table}[tbp]\centering\caption{demo table 6}\zlabel{tbl:6}\end{table}
\begin{table}[tbp]\centering\caption{demo table 7}\zlabel{tbl:7}\end{table}
\begin{table}[tbp]\centering\caption{demo table 8}\zlabel{tbl:8}\end{table}
\begin{table}[tbp]\centering\caption{demo table 9}\zlabel{tbl:9}\end{table}
\begin{figure}[tbp]\centering\caption{demo figure 1}\zlabel{fig:1}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 2}\zlabel{fig:2}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 3}\zlabel{fig:3}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 4}\zlabel{fig:4}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 5}\zlabel{fig:5}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 6}\zlabel{fig:6}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 7}\zlabel{fig:7}\end{figure}
\begin{figure}[tbp]\centering\caption{demo figure 8}\zlabel{fig:8}\end{figure}
\begin{align}
\text{demo equation 1}\label{eqn:1}\\
\text{demo equation 2}\label{eqn:2}\\
\text{demo equation 3}\label{eqn:3}\\
\text{demo equation 4}\label{eqn:4}\\
\text{demo equation 5}\label{eqn:5}
\end{align}
\end{document}
Admittedly, this particular setup was already possible with the previous state of things, with refpre
/refpos
. But now, a lot more flexibility and control has been added and, as I said, presumably cases 1 and 3 can be implemented with it as well. (You need the repo version to test this at the moment, if you need some guidance with how to use it, let me know).
With this in hand, would you like to provide a language file for Japanese and include in the package?
Hi @gusbrs , it took me a while to answer, I'm sorry.
I downloaded the repository as zip file and ran $ l3build doc
in terminal, which created ./build/local/zref-clever.sty
was created and executed using it.
I haven't checked it in detail yet, but this version including refbounds
seems to work well.
However, one thing you suggested / requested which I've put some thought about, but which I'm not willing to accommodate, is to provide an option named "name" for the purpose of better semantics for Japanese.
I agree that adding the name
option makes the option names cumbersome and should be avoided.
With this in hand, would you like to provide a language file for Japanese and include in the package?
I think it is very good to include the language files for Japanese. I think this will lower the barrier for Japanese users to use this package.
I downloaded the repository as zip file and ran
$ l3build doc
in terminal, which created./build/local/zref-clever.sty
was created and executed using it.
That will do. You may find more convenient though to use l3build install
. The files needed to use the package (.sty
and language files) get sent to your $TEXMFHOME
. And you can later use l3build uninstall
to revert to the version in your regular distribution.
I haven't checked it in detail yet, but this version including
refbounds
seems to work well.
Thanks, I do hope it will turn up to be useful.
I agree that adding the
name
option makes the option names cumbersome and should be avoided.
Thanks for your understanding.
I think it is very good to include the language files for Japanese. I think this will lower the barrier for Japanese users to use this package.
If you feel so inclined to contribute one, that would be much welcome. If you need any guidance in that regard, just let me know.
Insert a character to the right of
type-group
I'm not familiar with other languages, but this issue may not be a Japanese-specific.
Current problems
In Japanese, when referring to a chapter heading or section heading, it is also required after the number as follows.
In Japanese, the right side
章
is more important than the left side第
. There is no problem even if there is no第
on the left side, but第1章
is more polite and general than1章
.I want to insert this in the same way as
[Nn]ame-
option.Of course, you can get the expected output by using
refpos
as follows, but I think this isn't good semantic result. Also, if you refer to multiple chapters, you may not get very satisfactory results.Alternatively, use the
note
option?Expected interface
I would like you to provide keys like
name-pos
andnamesep-pos
.Alternatively, you may give
name-pos
the role ofnamesep-pos
.Behavior when multiple references are made
This bothers me a lot. When you want to refer to multiple chapters in Japanese, this is because there are various cases.
For example, when referring to two consecutive chapters, the following three are possible.
I don't know how to write it more commonly. And, I think other patterns need to be discussed as well.
I think it is a content that requires a lot of discussion. Or you need to find a comprehensive solution
Notes about Japanese
I'm not a linguist, so I can understand it at general level. However, I think Japanese has the following characteristics.
name
before and aftertype-group
.Therefore, as a minimum, I think that there is no problem if the general settings are set as follows.
I didn't use cleveref because it couldn't work with the
showonlyrefs
option of mathtools. However, I really want to take advantage of these clever features, and I think this package is what I'm expecting!:blush: Thank you.