abenori / jlreq

Other
125 stars 18 forks source link

Using both gutter and fore-edge makes right and left pages misaligned #118

Open glandium opened 1 year ago

glandium commented 1 year ago

Example:

\documentclass[uplatex,tate,book,paper=a6,fontsize=9pt,gutter=2cm,fore-edge=1cm]{jlreq}
\usepackage{bxpapersize}
\usepackage{bxjalipsum}

\begin{document}
\jalipsum{wagahai}
\end{document}

I would expect the right margin on the right page to match the left margin on the left page, and the right margin on the left page to match the left margin on the right page, but they don't.

abenori commented 1 year ago

I think the reason is that the width for text is not the integral multiple of baselineskip.

glandium commented 1 year ago

My main question would be should jlreq do some adjustments on its own, rather than expect every configured values to line up perfectly?

abenori commented 1 year ago

For horizontal writing mode, it was discussed in #28. I followed the suggestion by @kmuto ( https://twitter.com/kmuto/status/985047331279028226 ). (The discussions are in Japanese, sorry for that.)

I didn't think about vertical writing mode at that time. The implementation has been made to be compatible with the horizontal writing mode.

glandium commented 1 year ago

For horizontal writing mode, it was discussed in #28. I followed the suggestion by @kmuto ( https://twitter.com/kmuto/status/985047331279028226 ). (The discussions are in Japanese, sorry for that.)

No worries, I can read Japanese just fine. Writing is a very different skill, I'm more confident writing issues in English (English is not my native language either)

I didn't think about vertical writing mode at that time. The implementation has been made to be compatible with the horizontal writing mode.

So if I'm not mistaken, this is the implementation for horizontal writing mode: 16b3d6d5a2bb04fa0e2c57a53cee6cf2c6520a5b. Or at least what it looked like when it was implemented. I haven't looked if it has changed since. Presumably, adjusting the \else clauses of the \if @tate branches would address the issue. I can give it a shot when I have some time.

abenori commented 1 year ago

Well, implementations are done separately for vertical and horizontal writing mode (assuming that I remember correctly). The point is that it is not clear which behavior (current one? the one you expect?) is natural.

kmuto commented 1 year ago

In my opinion, the current implementation of jlreq.cls is as intended.

Declaring gutter and fore_edge means determining the width of the content area. Notice that this width of the content area has nothing to do with paragraphs or lines.

In vertical writing, the origin is always the upper right (both left/right page). Without properly calculated baseline skip, a gap is created to the left of the last line (this is also true for horizontal writing, appearing as a gap at the bottom).

So simple solution is to specify number_of_lines explicitly. If you'd like to write 14 lines per page, set number_of_lines=14. This will calculate the appropriate baseline skip to be exactly the content area width.

If you want to calculate baseline skip manually, you can do so as follows:

The result is baselineskip=5.525mm.

glandium commented 1 year ago

In vertical writing, the origin is always the upper right (both left/right page). Without properly calculated baseline skip, a gap is created to the left of the last line (this is also true for horizontal writing, appearing as a gap at the bottom).

I don't think I agree that this is a desirable behavior, when left pages and right pages have a different attachment point, respectively the right and left edges. It also feels weird when you open the resulting book that the lines are not aligned between the left and right page, and that the margins on the left of the left page and the right of the right page are different. None of the novels I have on my bookshelf, from many different publishing companies, are that way.

As a matter of fact, you could argue the same way with horizontal mode, where the origin is always the upper left, so a gap would be created to the right of the last character. Yet, the margins in that case are what I'd expect.

kmuto commented 1 year ago

OK, there are two ways to determine the content area in jlreq (and also in InDesign).

The first is to determine the area first, and fit the content there. The size of the area and the size of the margins are most important, and it is the user's responsibility to fit the content exactly. Note that a gap occurs when the last line and the content area do not match. In vertical writing, the gap is on the right, and in horizontal writing, the gap is at the bottom. This is easier to create when there are many elements other than text, such as in magazines and technical books.

The second method, which is particularly common in vertical writing, such as novels, and recommended by jlreq, is to determine the font size, baseline skip, number of characters per line, number of lines, top margin and gutter margin. The fore-edge and bottom margins are those leftovers.

Therefore, in this case, the second method should be used. It is appropriate to remove fore_edge and set baselineskip, line_length, and number_of_lines (and may head_space).

For example:

\documentclass[uplatex,tate,book,paper=a6,fontsize=9pt,baselineskip=15.2pt,line_length=35zw,number_of_lines=14,gutter=2cm]{jlreq}
glandium commented 1 year ago

The second method, which is particularly common in vertical writing, such as novels, and recommended by jlreq

Where is this recommendation? I didn't read https://github.com/abenori/jlreq/blob/master/README-ja.md thoroughly, but I didn't see anything obvious there.

is to determine the font size, baseline skip, number of characters per line, number of lines, top margin and gutter margin. The fore-edge and bottom margins are those leftovers.

I would argue that whatever is set should be used to derive what is not set in a reasonable manner. There might be too many combinations, though...

kmuto commented 1 year ago

The second method, which is particularly common in vertical writing, such as novels, and recommended by jlreq

Where is this recommendation? I didn't read https://github.com/abenori/jlreq/blob/master/README-ja.md thoroughly, but I didn't see anything obvious there.

https://www.w3.org/TR/jlreq/#elements_of_kihonhanmen Since jlreq.cls is aimed at implementing the JLREQ specification, the details are in this specification.

is to determine the font size, baseline skip, number of characters per line, number of lines, top margin and gutter margin. The fore-edge and bottom margins are those leftovers.

I would argue that whatever is set should be used to derive what is not set in a reasonable manner. There might be too many combinations, though...

I believe that deriving what is not set from the configuration items is generally implemented. For example, the content area is centered at the top and bottom even though the head margin is not defined. number_of_lines will cause the baseline skip to be calculated according to the content area. The number of characters will be set to the appropriate percentage height even if line_length is not defined. I agree that it is complicated, but paper design is much more complex than one might imagine and has a typesetting background.

glandium commented 1 year ago

number_of_lines will cause the baseline skip to be calculated according to the content area

While my original example didn't set number_of_lines, doing so doesn't change the baseline skip, and thus the outcome is the same. But with fore_edge, gutter and number_of_lines set, baseline skip is the only degree of liberty left, and would be the natural thing to adjust, as you mention. That's not implemented, unfortunately.

abenori commented 1 year ago

Perhaps you miss the following situation. (This is related to the first way to determine the content area in @kmuto mention.)

In the first example, the width of the main text is 10.5cm - 1cm - 2cm = 7.5cm. It is not the integral multiple of baselineskip, so I think your proposal is to set larger left margin on the left pages. Now assume that you have a page whose width is exactly 7.5cm (it's possible, for example if the page contains a figure). So the current implementation gives the desired margins, 1cm and 2cm. However, your proposal gives larger left margin (so maybe some elements will go to the next page).

I would argue that whatever is set should be used to derive what is not set in a reasonable manner. There might be too many combinations, though...

While my original example didn't set number_of_lines, doing so doesn't change the baseline skip, and thus the outcome is the same. But with fore_edge, gutter and number_of_lines set, baseline skip is the only degree of liberty left, and would be the natural thing to adjust, as you mention. That's not implemented, unfortunately.

I think it is too much to set baselineskip automatically. It will make it difficult to understand what will happen. (and maybe it will make some bugs... )

glandium commented 1 year ago

FWIW, there is something similar happening when setting head_space and foot_space, but not line_length: the last line in a paragraph doesn't use the same character spacing as the other lines.

abenori commented 1 year ago

Thank you. This is based on the same consideration.