-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
listings and unicode-math scriptsize bad #454
Comments
The problem is that fontspec/unicode-math reads font dimens with luacode. And while catcodes in the tex code are frozen when the code is read this is not true for values you get from directlua. So when trying to setup the font in the middle of lstlisting (which activates all chars) things explodes. The problem can be resolved by explicitly setting the catcode table when reading the dimens in the first argument of tex.sprint:
|
you shouldn't need luatexbase packae
\catcodetable@latex
is pre-defined in the format, see
latex3/fontspec#230
which was same issue in fontspec
…On 29 March 2018 at 10:09, u-fischer ***@***.***> wrote:
The problem is that fontspec/unicode-math reads font dimens with luacode.
And while catcodes in the tex code are frozen when the code is read this is
not true for values you get from directlua. So when trying to setup the
font in the middle of lstlisting (which activates all chars) things
explodes.
The problem can be resolved by explicitly setting the catcode table when
reading the dimens in the first argument of tex.sprint:
\documentclass{article}
\usepackage{unicode-math}
\RequirePackage{luacode}
\begin{luacode}
function fontspec.mathfontdimen(fnt, str)
local mathdimens = luaotfload.aux.get_math_dimension(fnt, str)
if mathdimens then
tex.sprint(luatexbase.catcodetables.latex,mathdimens)
tex.sprint(luatexbase.catcodetables.latex,"sp")
else
tex.sprint(luatexbase.catcodetables.latex,"0pt")
end
end
\end{luacode}
\usepackage{listings}
\lstset{basicstyle=\scriptsize}
\begin{document}
\begin{lstlisting}
-
\end{lstlisting}
\end{document}
(this needs the luatexbase package, I'm not sure how to get the table with
kernel code alone.)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#454 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABNcAnMKOIOu6jQ3-DEUPwUfes-sPaG6ks5tjKS3gaJpZM4S_wqW>
.
|
Description
Unicode-math and/or listings has a problem if
basicstyle=\scriptsize
is set and the maths fonts haven't been initialised. (IMO I don't think listings should be using maths characters, but maybe there's a good reason.)Check/indicate
Minimal example demonstrating the issue
Further details
Workaround:
\AtBeginDocument{\sbox0{\scriptsize $x$}}
or similar.The text was updated successfully, but these errors were encountered: