0

The code below is generated by LyX. I trimmed down the original in order to make a MWE. No matter what I do with this, I keep getting an error message when the file tries to compile with pdflatex.

\documentclass[oneside,english,oldfontcommands,oneside, article, 
    extrafontsizes, 10pt, latin9, utf8, main=american]{memoir}
\usepackage[T1]{fontenc}
\usepackage{babel}

\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{200B}{\hspace{0pt}} % This works
%\DeclareUnicodeCharacter{CC}{\"a} % Neither this
\DeclareUnicodeCharacter{00E4}{\"a} % nor this works.

\begin{document}
This is a trägar. Hello world. Goodbye.
\end{document}

I would attach the log if I knew how. But this is the relevant part:

! Package inputenc Error: Unicode char äga (U+CC)
(inputenc)                not set up for use with LaTeX.

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

l.12 This is a träga
                r. Hello world. Goodbye.
user99581
  • 145
  • 1
    you do not need to declare U+00E4 it is declared by default by inputenc. It would appear that your file is not in UTF-8. However what is the intention of latin9, utf8 on the top line, the file can not be in both encodings, is it latin9 encoded? If so the unicode declarations will not work. The file is certainly in some encoding other than UTF-8, note how it has taken äga as three bytes of a single character as it is trying to read the document as multi-byte utf-8 – David Carlisle Feb 28 '18 at 00:08
  • The LyX wiki says "LyX file is always encoded in utf8." But this seems to apply to the .lyx file itself and not the .tex file LyX creates. I'm not sure how to control the coding of the .tex file. As for latin9, utf8: I got an error message which suggested using both as a way around the unicode troubles. I've been looking with no success for the error message that suggest both latin9 and utf8 and for instructions on how to control the coding for the *.tex file's characters. – user99581 Feb 28 '18 at 03:54
  • the log you show indicates your file is not in utf-8 (although debugging here is tricky as your code section (like all text on this site) is utf-8 as posted here. I have not got lyx so can't really help but there are many lyx users here: someone will answer and point you at the correct configuration option possibly this (although select use inputenc utf8 which the question was asking not to do, but it should point you to the correct menu option https://tex.stackexchange.com/questions/88189/how-to-encoding-of-lyx-latex-output-without-lyx-adding-inputenc-declaration-to-p – David Carlisle Feb 28 '18 at 08:45

1 Answers1

0

This LyX file (copy and paste in your favorite text editor and save as a .lyx file in utf8 encoding)

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 508
\begin_document
\begin_header
\textclass memoir
\options article, extrafontsizes, 10pt
\use_default_options true
\language english
\language_package default
\inputencoding utf8
\end_header

\begin_body
\begin_layout Standard
träga
\end_layout

\end_body
\end_document

will produce

\documentclass[oneside,english,oldfontcommands,article, extrafontsizes, 10pt]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{babel}
\begin{document}
träga
\end{document}

Both compile fine, I can see the ä in the output pdf. Your extra documentclass options "latin9, utf8..." don't really belong there. Inputencoding can be changed in LyX>Document>Settings...>Language>Encoding>Other:utf8.

PhilipPirrip
  • 1,443
  • 1
    Thanks, this does it. The main thing is changing the encoding in Settings. I've seen utf8 mentioned as the recommended encoding for all things LaTeX, and LyX even uses it internally for LyX files. So I'm not sure why LyX doesn't make utf8 the default output encoding. FWIW, I'm using LyX 2.3rc2 (supports BibLaTeX), so going forward this fix should continue to work. Thanks! – user99581 Mar 01 '18 at 14:02
  • @Gnosos I think it's because TeX and LaTeX are old and need translation tables from utf8 to tex-encoded accented characters ("a) they only know how to handle. Some people also like to have their files in plain ascii. You should be able to use latin9 with your ä, give it a try. – PhilipPirrip Mar 01 '18 at 14:12