Open minamotorin opened 2 years ago
I'm using end_adjust
field in JFM with LuaTeX-ja to hang punctuation. Usually LuaTeX-ja takes account into this information when it breaks lines. However, at the end of the paragraph, end_adjust
is ignored when TeX breaks lines. (It is explained in Chapter 19 of Japanese LuaTeX-ja manual, but unfortunately it is not available in English version.)
Therefore, in your example, TeX try to make lines from □□□□□。
where 。
has the usual width (0.5zw). To avoid overfull, TeX makes two lines, as shown in your image.
Thanks for you reply. I understood what is happening.
Did you mean this behavior is a specification of jlreq? Is this a technical constraint?
In JLReq, there is a figure with a hanging punctuation at end of a paragraph. https://www.w3.org/TR/jlreq/#fig2_54 Is there a way to hang punctuations at the end of the paragraph in LuaLaTeX?
This is just a technical constraint.
Is there a way to hang punctuations at the end of the paragraph in LuaLaTeX?
Perhaps modifying JFM may work, I'm not sure.
Okay, thanks. I'll study about JFM.
Experimentally, I wrote the following patch, and it seems work properly.
# This patch is in the public domain and no warranty.
diff --git a/jfm-jlreq.lua b/jfm-jlreq.lua
index c188528..6172b1b 100644
--- a/jfm-jlreq.lua
+++ b/jfm-jlreq.lua
@@ -1186,21 +1186,7 @@ if jlreq ~= nil then
-- ぶら下げ組を有効にする.
if jlreq.burasage == true then
for _,class in ipairs({6,7}) do
- table.insert(jfm[class].end_adjust,-0.5)
+ table.insert(jfm[class].end_adjust, 1.0)
+ local w = jfm[class].width
+ jfm[class].width = 0
+ for c, glue in pairs(jfm[class].glue) do
+ jfm[class].glue[c][1] = glue[1] + w
+ if glue.ratio == nil then glue.ratio = 0.5 end
+ jfm[class].glue[c].ratio = glue.ratio * (glue[1] - w) / glue[1]
+ end
+ for c,_ in pairs(jfm) do
+ if type(c) == "number" then
+ if jfm[class].glue[c] == nil and (jfm[class].kern == nil or jfm[class].kern[c] == nil) then
+ jfm[class].glue[c] = {w, 0, 0, ratio = 0}
+ end
+ end
+ end
end
end
end
Thank you for the patch.
If I'm not mistaken, this patch makes the width of 。
, 、
, etc. 0pt
and add a glue after these characters (like the current implementation of hanging punctuation for (u)pLaTeX. I thought that I want to avoid this approach if possible. The reason is simply that I don't want to make the width zero because the width of 。
is basically not zero (as JLReq in W3C says, for example). So if possible I want to use another approach. Well, this reason is probably not practical and in almost all cases your code will work well I think (except something like あ。\inhibitglue い
).
this patch makes the width of 。, 、, etc. 0pt and add a glue after these characters (like the current implementation of hanging punctuation for (u)pLaTeX.
Yes, that's right.
About jlreq class, I'll respect your thoughts. Hope you find another approach. But I'll patch myself because the difference in page break position between (u)pLaTeX and LuaLaTeX is actually a problem for me. Thanks!
In LuaLaTeX, punctuations at end of paragraph are not treated as hanging punctuation.
Example code.
Result of compiling the above code with LuaLaTeX.
Result of compiling the above code with pLaTeX (expected).
Thanks.