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
    Commented May 13, 2016 at 8:32
  • But the context is there. You only need to look one line up. Commented May 13, 2016 at 8:33
  • 1
    @egreg it is not an error, only a silent message in the log-file Commented May 13, 2016 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. Commented May 13, 2016 at 8:42
  • 1
    This behaviour of XeTeX on inputting files does not seem to be documented in xetex-reference.pdf.
    – user4686
    Commented May 13, 2016 at 8:44

1 Answer 1


When you compile with XeLaTeX the following document





your log file will contain

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? Commented May 13, 2016 at 8:50
  • @macmadness86 The alternative is \fontsize{20}{25}\selectfont: where is the problem?
    – egreg
    Commented May 13, 2016 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? Commented May 13, 2016 at 8:53
  • 1
    Respectfully, this is moving away from the question about proper logging in LaTeX. I'd like consolidate log messages and their contexts onto one line (instead of the multi line output currently). Is this possible? Like I said, I'll investigate what you suggest with anyfontsize further. Commented May 13, 2016 at 9:40
  • 1
    @macmadness86 You can't change that message in any way; it's hard coded in XeTeX, as I said in my answer.
    – egreg
    Commented May 13, 2016 at 9:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .