2

I am preparing a bilingual document and using the comment package to distinguish between the two languages.

When I use the special character ß in a comment environment then I get an error message (Undefined control sequence.) although I use \usepackage[latin1]{inputenc} correctly.

Outside of the comment environment the character works fine.

The document class seems not to matter - I have the problem with scrbook and book.

\documentclass[]{scrbook}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[
    english,
    ngerman]
        {babel}

\usepackage{comment}

\includecomment{Version-DE}
\excludecomment{Version-EN}

\begin{document}
ß % <-- no problem here

\begin{Version-DE}
Version-DE
ß % <-- big problem here!
\end{Version-DE}

\begin{Version-EN}
Version-EN
\end{Version-EN}

\end{document}

I am not sure what tags to use here...

For Future Reference

I have found some other packages that maybe could be an alternative:

Here's all the packages of this kind (con­di­tional type­set­ting) on CTAN: https://www.ctan.org/topic/cond-comp

7
  • 1
    Sometimes it's useful to revert to the old-style \ss then ;-)
    – user31729
    Jul 9, 2016 at 18:48
  • @ChristianHupfer Hi, yes that's possible but I would like to avoid the work around :). Jul 9, 2016 at 18:52
  • @ChristianHupfer Can you reproduce the problem? Jul 9, 2016 at 19:07
  • 1
    comment doesn't work with “high bit set” characters. See tex.stackexchange.com/questions/159820/… for a similar problem
    – egreg
    Jul 9, 2016 at 19:42
  • 1
    Yes I get the same error
    – user31729
    Jul 9, 2016 at 19:56

1 Answer 1

3

One way forward -- hopefully feasible for you -- is to switch to either LuaLaTeX or XeLaTeX and to load the fontspec package. All you will need to change in the document is (a) comment out (or delete) the instructions \usepackage[utf8]{inputenc} and \usepackage[T1]{fontenc} in the preamble and (b) add the instruction \usepackage{fontspec}.

Of course, the document must be utf8-encoded, but these days utf8 is the default for most editors and web browsers. If the file isn't utf8-encoded at the moment, see the posting How to change a .tex file's input encoding system (preferably to UTF-8) for practical information on how to change the input encoding.

enter image description here

\documentclass{scrbook}

%\usepackage[latin1]{inputenc}
%\usepackage[T1]{fontenc}
\usepackage{fontspec} % <-- new

\usepackage[english,ngerman]{babel}

\usepackage{comment}
\includecomment{Version-DE}
\excludecomment{Version-EN}

\begin{document}
ß % <-- no problems here

\begin{Version-DE}
Version-DE
ß % <-- no more problem here either :-)
\end{Version-DE}

\begin{Version-EN}
Version-EN
\end{Version-EN}

\end{document}
2
  • Thanks a lot. Can you explain what is different? Does the write command not longer expand the special characters? Do oyu think that there is a drawback with solution of egreg (\immediate\write\CommentStream{\unexpanded{#1}}%)? Jul 9, 2016 at 20:56
  • 2
    @Dr.ManuelKuehner - I should have mentioned that the answer I've posted works with XeLaTeX too, and not just with LuaLaTeX. (I've edited the posting to rectify this omission.) I suspect it's the fontspec package that most of the heavy lifting, so to say, in the code I posted. One of the many nice things about LuaLaTeX/XeLaTeX/fontspec is that the way a given character is encoded in utf8 (with either 1, 2, 3, or even 4 bytes) is immaterial for a great many uses cases. I'm afraid I can't comment knowledgeably on Enrico's method.
    – Mico
    Jul 9, 2016 at 21:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.