2

I am using the following package: https://github.com/franen/matrita

There is a \rispostatutti command defined as follows:

\newcommand{\rispostatutti}[1]{%
 \par\nobreak\vspace{\prerisp}%
 \noindent\respindent\respsym\ {\respfont#1}\par%
 \vspace{\postrisp}%
}

This command prevents the correct rendering of the letter È. Indeed, writing

\rispostatutti{\`E cosa buona e giusta.}

returns the following:

enter image description here

Why the second \`E is properly formatted, while the first is not?

MWE to reproduce the problem:

  1. clone https://github.com/franen/matrita
  2. latex matrita.dtx
  3. go to line 997 of matrita.sty and change the Ès with \`Es
  4. pdflatex Esempio3.tex
  5. go to page 19 of Esempio3.pdf and check

BTW, if I don't change the Ès with \`Es I get the following errors:

! Package inputenc Error: Unicode char �\check@icr (U+3DB)
(inputenc)                not set up for use with LaTeX.

See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.207 \prefazio

? 

! Package inputenc Error: Keyboard character used is undefined
(inputenc)                in inputencoding `utf8'.
  • @campa I know it's not minimal, but it is its behavior right out of the box :/ – Alessandro Cuttin Sep 22 '17 at 15:05
  • Everything works fine for me also using the given examples... – campa Sep 22 '17 at 15:08
  • @campa are you using windows or linux? I'm wondering if it is a matter of file encoding, but I'm not sure about it, given that I generate the sty file on my machine – Alessandro Cuttin Sep 22 '17 at 15:12
  • 2
    Does \respfont try to grab the first token of its argument to do apply some special formatting to the first letter? In which case you may need to use grouping {È} or {\`E} – Nicola Talbot Sep 22 '17 at 15:21
3

There is an error in Esempio3.tex; the line

\renewcommand{\respfont}{\textbf}

should be

\renewcommand{\respfont}{\bfseries}

Here's the output after fixing and recompiling:

enter image description here

The command in the package is defined as

\newcommand{\respfont}{\itshape}

which is correct as \itshape is a declaration. To the contrary, \textbf is a command taking an argument and, in the context you use it, it either takes as argument \` or the first octet in the UTF-8 representation of È; in both cases an error happens.

2

(I'm guessing your comment means that my comment solved your problem :-) so I'll write it up as a proper answer.)

Some commands try to grab the first letter that follows it to apply some special formatting. It seems that \respfont is doing this with the argument of \rispostatutti.¹ If the first "letter" isn't a single token then it needs grouping, so you need

\rispostatutti{{\`E} cosa buona e giusta.}

With inputenc you also need to group UTF-8 characters:

\rispostatutti{{È} cosa buona e giusta.}

This is because È is actually treated as two octets with regular LaTeX. Without the grouping only the first octet is grabbed (which breaks the encoding). If you use XeLaTeX or LuaLaTeX that have native UTF-8 support then È is a single token and doesn't cause a problem.

(This is the same problem as that described in the UTF-8 section of the mfirstuc manual since \makefirstuc similarly tries to grab the first letter of its argument to case-change it.)


¹ Alternatively, the definition of \rispostatutti needs to be changed to use \respfont{#1} instead of \respfont #1 if the font change needs to be applied to the entire argument.

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.