2

In another thread [here][1] I couldn't compile a code and we found out, that it is because of 'colour'.

When I use this code...

\documentclass{standalone} 
\newcommand\fsname{Shobhika} 
\usepackage{fontspec} 
\newfontfamily\fsnsk[Script=Devanagari]{\fsname}[Colour=0000ff]\begin{document} 
test 
\end{document}

... following error is occuring:

! LaTeX Error: Missing \begin{document}. l.4 ...ntfamily\fsnsk[Script=Devanagari]{\fsname}[ Colour=0000ff]\begin{docum...

When I leave [Colour=0000ff] away ...

\documentclass{standalone} 
\newcommand\fsname{Shobhika} 
\usepackage{fontspec} 
\newfontfamily\fsnsk[Script=Devanagari]{\fsname}
\begin{document} 
test 
\end{document}

... then the compilation is ok. Others don't have that problem and can compile this code with colour. Fonts we tested out and are working well. Where is the problem?

Denis
  • 91
  • Compiles OK for me (xelatex on Windows). Both Shobhika and Shobhika Regular as the font name work. What was the error? TexMaker is the editor; what compilation engine did you use? – Cicada Jan 03 '20 at 14:34
  • In the error message you quote, there is ping=iast_test.Script= with a . The . will indeed generate errors. But in the code you have ping=iast_test,Script= with a comma, which works. – Cicada Jan 03 '20 at 14:41
  • Yes, error message is with , you are right! – Denis Jan 03 '20 at 14:57
  • I use XeLaTex for compilation. I tried also in TeXStudio... – Denis Jan 03 '20 at 15:10
  • 1
    To reiterate the previous comment, in case it wasn't clear: The error message that you have showed contains a . (in ping=iast_test.Script=Devanagari), while the .tex source that you have showed contains a , (in Mapping=iast_test,Script=Devanagari). So either you have copied the error message here incorrectly, or copied the source here incorrectly, or you're compiling a source file different from the one you're copying from. Can you edit this question, this time being careful only to copy-paste (don't retype anything) exactly the source you use and the error message you get? – ShreevatsaR Jan 03 '20 at 17:56
  • @ShreevatsaR Thanks for reply. You are right! I couldn't copy from TexMaker. So it is ping=iast_test,Script=Devanagari in the error message. – Denis Jan 03 '20 at 22:43
  • Why can't you copy from Texmaker? Also, I have no problem with the file on Linux. I suggest uploading somewhere (e.g. Google Drive or Dropbox or whatever) the exact source file that you're using, and linking to it -- most likely it is not identical to what has been pasted here. – ShreevatsaR Jan 03 '20 at 22:47
  • @ShreevatsaR Only the error text I did not copy/ paste from the log. The codes I did... Here is the links: https://drive.google.com/drive/folders/1Y1LkUMVTjhHZzMFgVptsmD7gxwb25qZ_?usp=sharing Thanks for support! – Denis Jan 03 '20 at 23:07
  • Your test file works fine for me. Can you do the following: (1) delete missfont.log and see if it gets recreated (if you have the font Shobhika, it should not get recreated), (2) Make sure Texmaker is set to UTF-8 encoding by default (e.g. see Step 1 here). – ShreevatsaR Jan 03 '20 at 23:13
  • It seems that I have Shobhika, the deleted missfont.log does not get recreated. And UTF-8 encoding is by default. – Denis Jan 03 '20 at 23:29
  • Well, not sure what the problem could be then. You could try two things: (1) Try compiling directly using xelatex, without using Texmaker, and (2) Try removing the "[Colour=blue]" as that's what it's complaining about. – ShreevatsaR Jan 03 '20 at 23:41
  • Great, thanks for support. [Colour=blue] was the culprit. Any idea why this causes problems? – Denis Jan 03 '20 at 23:53
  • Can you try this simpler file and see if causes the same problems: \documentclass{standalone} \newcommand\fsname{Shobhika} \usepackage{fontspec} \newfontfamily\fsnsk[Script=Devanagari]{\fsname}[Colour=0000ff] \begin{document} test \end{document} – ShreevatsaR Jan 04 '20 at 00:14
  • Yes, I causes also an error. – Denis Jan 04 '20 at 00:26
  • Maybe you could edit your question to remove all the indic, mapping etc related stuff, and ask about just that small example. Then someone who's familiar with fontspec might be able to see this question and guess why you get that error. – ShreevatsaR Jan 04 '20 at 00:59
  • What if you try \newfontfamily\fsnsk[Script=Devanagari, Colour=0000ff]{\fsname}? – David Purton Jan 04 '20 at 09:54
  • @David now it works well, thank you. Do you have an explanation why other users could compile with the above code? – Denis Jan 04 '20 at 10:25

1 Answers1

1

Your MWE can be compiled fine with an up to date TeX distribution.

But your error indicates that [Colour=0000ff] is not being treated as an argument for \newfontfamily. In the past optional arguments for \newfontfamily went before the font name, but it was changed a while ago to put the optional argument after the font name.

I suspect that you are running an old version of fontspec that doesn't support putting the optional argument after the font name.

You could confirm this by adding \listfiles to the top of your TeX document. This will cause TeX to output your fontspec version.

My (working) version of fontspec is 2019/10/19 v2.7d.

If this proves to be the case, then the solution is to update your TeX distribution.

In the meantime, a workaround is to use:

\newfontfamily\fsnsk[Script=Devanagari, Colour=0000ff]{\fsname}

Once updated, you should probably use:

\newfontfamily\fsnsk{\fsname}[Script=Devanagari, Colour=0000ff]

rather than putting one option before the font name and one after.

David Purton
  • 25,884
  • That makes sense. My version is 2016/02/01 v2.5a. Hm, I couldn't find an easy manual for updating. Do I have to copy these files here into this directory: /usr/share/texlive/texmf-dist/tex/latex? – Denis Jan 04 '20 at 13:15
  • @Denis, almost certainly you should not just copy those files. You will miss dependencies of newer versions of fontspec. I take it you are running Debian or Ubuntu. Unless you want to switch to a rolling distribution like Debian Testing, you should uninstall all the texlive Debian/Ubuntu packages and install TeXLive 2019 directly from https://www.tug.org/texlive/. You may also find https://www.tug.org/texlive/debian.html helpful. – David Purton Jan 04 '20 at 13:24
  • 1
    @Denis, but if you're in the middle of writing something critical, just use the old syntax (it wont' hurt). You might find other problems with your document if you update from such an old version of TeXLive. – David Purton Jan 04 '20 at 13:27
  • Thanks for support. Yes, maybe better to let it how it is. – Denis Jan 04 '20 at 16:22