1

UPDATE: In hindsight, I realize that this question is really, "Is there any way for LaTeX to keep the file context and warning/error message on the same line?"

This would be fore the purpose of automated parsing of a log file using regular expressions (e.g. looking for a key word like "Invalid" and having the file context be in the result, not just the one line containing the message).

egreg answered this with a definitive NO, it is hardcoded in XeTeX. :(

UPDATE 2016-05-19

In an e-mail to the maintainer of anyfontsize P. Szabó:

I'm not actively maintaining this package anymore. Feel free to convert it to UTF-8, and upload the new version of CTAN. You have my approval.


Original question text

I am typesetting documents with XeLaTeX. I have the bold aspiration to remove all warnings and errors from my document builds :D (nearly impossible, but nothing I cannot strive for!)

One of the warnings I and a colleague finally tracked down to anyfontsize, which is an official package in TeX Live. All packages are either in UTF-8 or ASCII, except this one (ISO-8859), because the creator has diacritics in his name (likely Hungarian ;) ) I e-mailed him about this already. Anyway, my real concern is the following message:

grep -Pin 'Invalid' myfile.log

Invalid UTF-8 byte or sequence at line 3 replaced by U+FFFD.

This message is useless without a context (yes, line 3 is a context, but hardly useful as you can see). I propose adding context to these messages by adding the file name. This way, I could immediately know that this error was cause during the reading of anyfontsize. Maybe something like "show last file loaded" before every error/warning.

Is this already possible? I know about \listfiles, which is great!

I can try to suppress messages that are not a problem by using the silence package. However, it is not a good idea to do this, because the message is not unique enough without a context (line 3 of what?).

  • I don't think this package can really raise that error, because the accented letters in the 8 bit encoding are commented. Any MWE? – egreg May 13 '16 at 8:32
  • But the context is there. You only need to look one line up. – Ulrike Fischer May 13 '16 at 8:33
  • 1
    @egreg it is not an error, only a silent message in the log-file – Ulrike Fischer May 13 '16 at 8:36
  • 2
    And to answer your question: the message is a message from the xetex engine and is issued very early while processing/reading the file. Latex can't do anything about it. – Ulrike Fischer May 13 '16 at 8:42
  • 1
    This behaviour of XeTeX on inputting files does not seem to be documented in xetex-reference.pdf. – user4686 May 13 '16 at 8:44
4

When you compile with XeLaTeX the following document

\documentclass{article}
\usepackage{fontspec}
\usepackage{anyfontsize}

\begin{document}

aaa

\end{document}

your log file will contain

(/usr/local/texlive/2015/texmf-dist/tex/latex/anyfontsize/anyfontsize.sty
Invalid UTF-8 byte or sequence at line 3 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 3 replaced by U+FFFD.
Package: anyfontsize 2007/11/22 anyfontsize.sty by pts
)

that's pretty self explanatory: (Xe)TeX has opened anyfontsize.sty and found the bad byte sequences on line 3.

Solution: none. Either you change the .sty yourself or the author does it. The message cannot be silenced.

On the other hand, anyfontsize does nothing useful when fontspec is loaded. It does little useful, in general, frankly speaking.

  • What is the alternative to \fontsize{20}{25}\selectfont Hello using only fontspec? – Jonathan Komar May 13 '16 at 8:50
  • @macmadness86 The alternative is \fontsize{20}{25}\selectfont: where is the problem? – egreg May 13 '16 at 8:52
  • Ah, you mean that fontspec loads this functionality or has equivalent functionality? If it loads anyfontsize, then won't the message persist? – Jonathan Komar May 13 '16 at 8:53
  • @macmadness86 I mean that you don't need anyfontsize at all. You're starting from a false premise. If you want to use the Computer Modern fonts at any size, load fix-cm. There are some fonts that still have .fd files with fixed sizes; in that case it's usually very easy to overcome the limitation. – egreg May 13 '16 at 8:56
  • 1
    @macmadness86 You can't change that message in any way; it's hard coded in XeTeX, as I said in my answer. – egreg May 13 '16 at 9:41

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.