I am trying to write a file using the document class file provided by the journal Semantics and Pragmatics at http://info.semprag.org/style. However, I can't even compile the example template they provide... Whenever I try to run LaTeX on it, I get the following error:

ERROR: Undefined control sequence.

--- TeX said ---
Undefined control sequence.
<recently read> \DeclareUnicodeCharacter 

l.107 \DeclareUnicodeCharacter

I tried both with auctex and on overleaf.com but the error remained the same.

Strangely, I couldn't find anything related to "undefined control sequence" error caused by \DeclareUnicodeCharacter by Googling. This doesn't make sense to me since apparently the TeX engines just think \DeclareUnicodeCharacter isn't a valid command at all, while the document class file as well as various examples on the Internet just use this command directly without any issue. Is there something wrong with the document class file when used with the newest version of TeX engine, or did I misconfigure something?

EDIT: The compile log: https://www.dropbox.com/s/49mkenzngua0we0/sp-template.log?dl=0

  • I posted an answer but deleted it as your problem is probably something else. Briefly: \DeclareUnicodeCharacter comes from inputenc (with utf8), but your sp.cls already contains \RequirePackage[utf8]{inputenc}. And if I download your sp-template.tex and sp.cls, I am able to compile sp-template.tex with no errors. Please include the complete compilation log (from either your local installation or Overleaf (or link to the file at the latter)); that may help. Commented Jul 7, 2017 at 15:08
  • Line 107 of sp.cls indeed has \DeclareUnicodeCharacter{2011}{\mbox{-}\nobreak\hskip0pt}, but the immediate (non-comment) line before that is line 103 with \RequirePackage[utf8]{inputenc}. Either that line gave an error, or loaded the wrong file somehow. Whichever it is, if you include your full compilation log (and not just those lines), then it will become clear. Commented Jul 7, 2017 at 15:16
  • @ShreevatsaR Weirdly, if I create a new blank project on overleaf and try to compile again, it works without any error. I guess some previous configuration of my project is interfering with it. I have uploaded the log. Could it be that the XeTeX engine used by default caused the bug?
    – xji
    Commented Jul 7, 2017 at 15:19
  • Don't use xe(la)tex with this style Commented Jul 7, 2017 at 15:21
  • There also seems to be a bug with /usr/local/texlive/2016/texmf-dist/tex/latex/breakurl/breakurl.sty:311: Undefined control sequence in the log.
    – xji
    Commented Jul 7, 2017 at 15:22

1 Answer 1


The macro \DeclareUnicodeCharacter is defined in the package inputenc when loaded with the utf8 encoding. So normally you need the following line before you use \DeclareUnicodeCharacter:


In this case though, the sp.cls already contains the line \RequirePackage[utf8]{inputenc} on line 103, before it uses \DeclareUnicodeCharacter on line 107, so you should be able to compile sp-template.tex with pdflatex even without explicitly adding the line.

However, if you compile with the xelatex or lualatex engines (which are Unicode-based and default to utf8), then the inputenc package gets ignored, and (only) a warning is printed in the error log:

% xelatex sp-template.tex
This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2017-04-15>
Babel <3.10> and hyphenation patterns for 84 language(s) loaded.
Document Class: sp 2015/01/04 v.3.0 Class for Semantics & Pragmatics
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/size12.clo)) (/usr/local/texlive/2017/texmf-dist/tex/latex/stmaryrd/stmaryrd.sty) (/usr/local/texlive/2017/texmf-dist/tex/latex/base/textcomp.sty (/usr/local/texlive/2017/texmf-dist/tex/latex/base/ts1enc.def)) (/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/local/texlive/2017/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (/usr/local/texlive/2017/texmf-dist/tex/latex/base/fontenc.sty (/usr/local/texlive/2017/texmf-dist/tex/latex/base/t1enc.def) (/usr/local/texlive/2017/texmf-dist/tex/latex/lm/t1lmr.fd)) (/usr/local/texlive/2017/texmf-dist/tex/latex/psnfss/mathptmx.sty) (/usr/local/texlive/2017/texmf-dist/tex/latex/base/inputenc.sty

Package inputenc Warning: inputenc package ignored with utf8 based engines.

! Undefined control sequence.
<recently read> \DeclareUnicodeCharacter 

l.107 \DeclareUnicodeCharacter

(Note the line that starts with "Package inputenc warning". IMO it makes sense for this to be an error instead, but probably the authors of inputenc chose to make it a warning because many files written with inputenc have a chance of working on Unicode-based engines if inputenc simply does nothing.)

So you need to either

  1. compile your file with the pdfTeX engine, or
  2. if you wish to compile with XeTeX/LuaTeX, hack sp.cls to remove the following line:


    (note it was added to deal with a hyphenation problem which you are unlikely to have with a Unicode-based engine as presumably no one would define hyphenation after U+2011) and also these lines that use \ifpdf to mean “non-PostScript output” but unfortunately excludes XeTeX but not LuaTeX (they're ok to remove because breakurl is not needed):

    % If the author is using postscript (discouraged), then load the
    % breakurl package, else don't load it.

(Note that if you're sending the source .tex file to someone else, such as the journal, then you shouldn't choose the latter option: and in general if you're submitting papers to journals you shouldn't mess with their style files. But if you're not going to send the file to anyone and are simply typesetting it in the journal's style for your own amusement, you can do whatever you like.)

  • 1
    It no longer works with \usepackage[utf8]{inputenc}. Commented Nov 23, 2019 at 11:41
  • 1
    @NicoSchlömer What no longer works? The question was about an issue with the style file of the journal Semantics and Pragmatics as of the time the question was asked. In the answer I explained the issue and how to work around it. Maybe the journal changed its class file since then. (Or possibly you're not even using sp.cls and it's hard to tell from your short comment; in that case please ask a new question.) Commented Nov 23, 2019 at 16:44
  • Did that. tex.stackexchange.com/questions/517845/… Commented Nov 24, 2019 at 19:01
  • @NicoSchlömer OK. But as this answer already explains, it won't work if you're using xelatex / lualatex. Are you sure you're using pdftex ? Commented Nov 24, 2019 at 19:44

You must log in to answer this question.

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