jlreq
jlreq copied to clipboard
Line break immediately after a ideographic space (zenkaku space)
In LuaLaTeX, a line break immediately after ideographic space (zenkaku space) is converted to a word space. This behavior is different from (u)pLaTeX.
The cause is that ideographic space (
) is active and line end is not commented out.
One solution is to add to callback to process_input_buffer
like LuaTeX-ja as followings.
% The parts of this program other than Lua code are public domain.
\documentclass{jlreq}
\begin{document}
□□□□ □□□□ □□□□ □□□□ □□□□ □□□□ □□□□ □□□□
□□□□
□□□□
□□□□
□□□□
□□□□
□□□□
□□□□
□□□□
\ifx\directlua\undefined
\end{document}
\fi
\directlua{
% This Lua code is based on ltj-inputbuf.lua of The LuaTeX-ja project.
% Rights is waived for changes from the original code by The LuaTeX-ja project.
% The original copyright notice (Modified BSD License) is as follows.
%
% > Copyright (c) 2011--2016 The LuaTeX-ja project, All rights reserved.
% >
% > Redistribution and use in source and binary forms, with or without
% > modification, are permitted provided that the following conditions are met:
% > * Redistributions of source code must retain the above copyright
% > notice, this list of conditions and the following disclaimer.
% > * Redistributions in binary form must reproduce the above copyright
% > notice, this list of conditions and the following disclaimer in the
% > documentation and/or other materials provided with the distribution.
% > * Neither the name of the LuaTeX-ja project nor the
% > names of its contributors may be used to endorse or promote products
% > derived from this software without specific prior written permission.
% >
% > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
% > ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
% > WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
% > DISCLAIMED. IN NO EVENT SHALL THE LUATEX-JA PROJECT OR CONTRIBUTORS BE LIABLE
% > FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
% > (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
% > LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
% > ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
% > (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% > SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
local function add_comment(buffer)
local getcatcode = tex.getcatcode
local getcount = tex.getcount
local i = utf.len(buffer)
local c = utf.byte(buffer, i)
while (i>0) and (getcatcode(c)==1 or getcatcode(c)==2) do
i = i - 1
if (i>0) then
c = utf.byte(buffer, i)
end
end
local te = tex.endlinechar
local lec = getcount 'ltjlineendcomment'
if (i>0) and (te \string~= -1) and (getcatcode(te)==5) and (getcatcode(lec)==14) then
if (c==utf.byte(' ')) and (getcatcode(c)==13) then
return buffer .. utf.char(lec)
end
end
return buffer
end
luatexbase.add_to_callback('process_input_buffer', add_comment, 'my.zenkaku_space')
}
□□□□ □□□□ □□□□ □□□□ □□□□ □□□□ □□□□ □□□□
□□□□
□□□□
□□□□
□□□□
□□□□
□□□□
□□□□
□□□□
\end{document}
- pLaTeX
- LuaLaTeX
Certainly it is better to take measures, but I think it's a rare case and it's okay if you don't take measures.
Thanks.
Thank you. I think just adding \ignorespaces
solve the problem.
% line 1150
\expandafter\long\expandafter\def\expandafter\jlreq@zenkakuspace@main\expandafter{\@tempa
\hskip 1\jlreq@zw\hbox{}%
\jlreq@lastnodechar=`
\expandafter\jlreq@fixjfm
\else\expandafter \fi
\ignorespaces % added
}
Thanks for your reply.
\ignorespaces
causes the following problem in really rare case.
% This program is in the public domain.
\documentclass{jlreq}% Added \ignorespaces
\begin{document}
\catcode`\@=\active
\let@ % For readability
@ @ □□□□
□□□□
@@□□□□
\end{document}
- LuaLaTeX
- pLaTeX
I think the importance of this problem is as low as the first problem.
Thank you again.
The current
is just an alias of \
and I think it's better to keep this to make understanding the correct behavior easier.
Perhaps, make
non-active may be a possibility. I thought users do not use
because this is not compatible with JLReq. This was a reason why I make
an alias of \
.
I understand, thanks.