6

Yesterday, I installed TexLive2017 to Linux Mint to use lualatex, and lualatex 1.0.4 is installed now. But so simple a code shown below doesn't work properly.

\documentclass{ltjarticle}
\usepackage{luatexja}
% \documentclass{article}

\begin{document}

\begin{eqnarray}
f(x) = x^2 + 4 \label{eq:1}
\end{eqnarray}

then we can find
\begin{eqnarray}
a = 4.\ \ \ (\mathrm{by\ eq.(\ref{eq:1})})
\end{eqnarray}

\end{document}

The error message is this.

*! You can't use `\spacefactor' in math mode.
\@setref ...d}\else \expandafter #2#1\spacefactor 
                                                  \@m {}\fi 
l.13 a = 4.\ \ \ (\mathrm{by\ eq.(\ref{eq:1})}
                                            )
? 
Missing character: There is no è (U+00E8) in font cmex10!
[1*

The code can be complied without any errors if I write the code from scratch and save as new name and compile for the first time. It means the error occurs when \label{eq:1} and \ref{eq:1} are tethered.

How can I solve this problem? This code works properly on my mac (texlive2016, lualtex 0.95.0). If I comment out the first two lines and uncomment the third line, the problem dissolves at once, but I have to use luatex Japanese packages as I'm Japanese.

5

The issue you've uncovered isn't related directly to Lua(La)TeX. Instead, it would appear to be related to the insertion of whitespace inside a \mathrm{...} wrapper. I suggest that you load the amsmath package and use the \text{...} wrapper instead.

Oh, and please do not use the badly-deprecated eqnarray environment. Instead, use the equation environment for single-line equations and the align environment (provided by the amsmath package) for multi-line equations.

\documentclass{ltjarticle}
\usepackage{amsmath} % for '\text' macro
\usepackage{luatexja}
\usepackage{cleveref} % optional, for '\cref' macro

\begin{document}    
\begin{equation} \label{eq:1}
f(x) = x^2 + 4 
\end{equation}
then we can find
\begin{equation}
a = 4\quad(\text{by \cref{eq:1}})
\end{equation}  
\end{document}
  • 1
    Thank you so much. \text{} command is really helpful and now no problem is left. – ynn Oct 22 '17 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.