20

It sounds simple but I have a really heavy issue with the "ö ü ä ß" in Latex. I use a template from my university, i have a mac and i use TeXShop if that matters.

Within there is a packages.tex with the following (...)

\usepackage[T1]{fontenc}            % Standard package for selecting font encodings
\usepackage{lmodern}                    % alternative Computer Modern-fonts for computer screens
\usepackage{textcomp}                   % LaTeX support for the Text Companion fonts
(...)

Also I have a thesis.tex with

(...)
\usepackage[utf8]{inputenc}     % Accept different input encodings
\usepackage{ifthen}                     % Conditional commands in LaTeX documents
(...)

Now I tried to use

\usepackage[ngerman]{babel}

as well as

\usepackage[applemac]{inputenc}

but unfortunately it doesn't work. The best case was another error "hyphenation flashed" or something.

\documentclass[
    fontsize=12pt,
    a4paper,
    portrait,                               
    oneside,                                    
    openright,                              
    final,                                          
    titlepage,                                  
    onecolumn,                                  
    bibliography=totoc,
    numbers=noenddot                    
]{scrbook}
\usepackage[T1]{fontenc}        
\usepackage{lmodern}    
\usepackage[utf8]{inputenc}     
\usepackage{ifthen}         
\begin{document}
öä
\end{document}

Now I replaced

\usepackage[utf8]{inputenc}     

with

\usepackage[applemac]{inputenc}

in the minimal working example above and it worked BUT in the other document it still doesn't work :( There it gives me the error (see picture)

error

editor

rebatoma
  • 351
Dean
  • 201
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Jul 29 '15 at 20:22
  • 10
    Leave utf8 and don't touch it! – Johannes_B Jul 29 '15 at 20:25
  • Try
    \documentclass{article} \usepackage[T1]{fontenc}   \usepackage[german]{babel} \usepackage[applemac]{inputenc} \begin{document} TEST \end{document}.
    
    

    I have no mac, but according to this forum it should work.

    – Amelie B. Blackstone Jul 29 '15 at 20:27
  • 'It doesn't work' is rather tricky to help with. Assemble a minimal working example (MWE) and post it along with the log as an edit to the question. – Joseph Wright Jul 29 '15 at 20:29
  • By the way (...) as ellipsis in a preamble is not really useful ;-) –  Jul 29 '15 at 20:29
  • I have edited an minimal working example which doesn't work. The problem are only "äöüß" and i didn't get to fix it even though i changed the packages all day :/ – Dean Jul 29 '15 at 20:29
  • 4
    which encoding DO your files have? you should be able to see that in a reasonably functionable editor – Bort Jul 29 '15 at 20:35
  • @Johannes_B What's wrong with utf8? – Sean Allred Jul 29 '15 at 20:35
  • 4
    @Dean don't randomly change packages, the code in your question runs without error. Copy it back from the website and save as a new file making sure that the file is saved in UTF-8 encoding. the pdflatex should run without error, – David Carlisle Jul 29 '15 at 20:40
  • 1
    @SeanAllred he meant leave the document as specifying utf-8 and don't change it:-) – David Carlisle Jul 29 '15 at 20:41
  • @David Charlisle unfortunately it doesn't run without error here... Bort what do you mean with encoding? where do i see that? – Dean Jul 29 '15 at 20:41
  • 1
    @SeanAllred What David just said :-) – Johannes_B Jul 29 '15 at 20:44
  • @Dean http://texwelt.de/wissen/fragen/2656/wie-uberprufe-ich-die-standardeingabekodierung-in-meinem-editor – Johannes_B Jul 29 '15 at 20:44
  • 2
    @Dean Please don't ask multiple unrelated questions in one question and always paste code and error messages as text not as an image, You have sone characters defined as text but used in math but without any real example hard to say what. – David Carlisle Jul 29 '15 at 20:44
  • Any text editor will allow you to save files in a specified encoding i guess that is texshop but I have not used it so someone else will have to tell you that, sorry. – David Carlisle Jul 29 '15 at 20:46
  • You should check what encoding TeXshop really uses. I think the default is still applemac (!), but you can (and should) set it to utf8. You can guess the real encoding with TeXmaker, which will deliver a message, and can convert any encoding to utf8. – Bernard Jul 29 '15 at 20:53
  • Those screen shots are not for the MWE. Please edit into the question the details from the log file for the MWE as text. – Joseph Wright Jul 29 '15 at 21:01
  • Also, I downloaded that complete 'template': it's in UTF-8 and compiles just fine with no edits at all. – Joseph Wright Jul 29 '15 at 21:36
  • 1
    It's not clear from what you say what your MWE does. In your comment you say that your MWE "doesn't work" (which is useful), but in your question you say that "it worked" (which is not useful). So please clarify, does your MWE produce the error for you or not? – Sverre Jul 29 '15 at 23:16
  • the first picture looks kind of weird to me, is the umlaut problem BEFORE begin{document}? and in the second picture the problem could be a "§" (which is \§ ) so to rephrase this: How sure are you this as ANYTHING to do with umlauts in the main text? Which do seem to work in some way in your MWE – Bort Jul 30 '15 at 07:31
  • I just looked at the template: It really needs an update. Please contact the author. There are some errors in te files. – Johannes_B Jul 30 '15 at 15:29

4 Answers4

27

Based on this LaTeX website, there are following solutions for your problem.

According the subsection "indirekte Eingabe von Umlauten" you can write \"A, \"O, \"U, \"a, \"o, \"u and \ss{} or {\"A}, {\"O}, {\"U}, {\"a}, {\"o}, {\"u} and {\ss} to get german letters.

If you include the german or ngmerman (ngerman has the new hyphentation rules), you can write "A, "O, "U, "a, "o, "u, "s to get the letters.

This is very usefull, if you need to write one or two german letters. But it's not too funny to write a german essay with that notation.

The subsection "direkte Verwendung der Umlaute" gives another solution (for Mac). Just put following lines in your preamble:

\usepackage[applemac]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

OR

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

If you know which encoding your editor uses, you can just use that instead. I think that Texmaker is a good cross-plattform editor.

I've tried to make an example, so you can see how it should work. If this example doesn't work, try to write applemac instead of utf8. That should end your problem.

\documentclass[a4paper]{article}

%German language
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

%Unimportant
\usepackage[top=2cm,right=2cm,bottom=2cm,left=2cm]{geometry}
\thispagestyle{empty}
\usepackage{verse}


\begin{document}
\null
\vfill
\null

\poemtitle{Die polyglotte Katze}
\settowidth{\versewidth}{in das die Maus vor kurzem kroch,}
\begin{verse}[\versewidth]
Die polyglotte Katze\\
Die Katze sitzt vorm Mauseloch,\\
in das die Maus vor kurzem kroch,\\
und denkt:'Da wart nicht lang ich,\\
die Maus, die fang ich!'\\!


Die Maus jedoch spricht in dem Bau:\\
'Ich bin zwar klein, doch bin ich schlau!\\
Ich rühr mich nicht von hinnen,\\
ich bleibe drinnen!'\\!


Da plötzlich hört sie - statt'miau' -\\
ein laut vernehmliches'wau-wau'\\
und lacht:'Die arme Katze,\\
der Hund, der hatse!\\
Jetzt muß sie aber schleunigst flitzen,\\
anstatt vor meinem Loch zu sitzen!'\\!


Doch leider - nun, man ahnt’s bereits -\\
war das ein Irrtum ihrerseits,\\
denn als die Maus vors Loch hintritt -\\
es war nur ein ganz kleiner Schritt -\\
wird sie durch Katzenpfotenkraft\\
hinweggerafft! - - -\\!


Danach wäscht sich die Katz die Pfote\\
und spricht mit der ihr eignen Note:\\
'Wie nützlich ist es dann und wann,\\
wenn man ’ne fremde Sprache kann ...!'\\
\end{verse}
\bigskip
\centering {\footnotesize \itshape Heinz Erhardt (1909--1979)}\footnote{Höret dieses Gedicht über Kätzchen, welches nie auf den Straßen in Straßburg gehör fand.}

\bigskip


\null
\vfill
\null
\end{document}

Here an image of how it looks

German letters.

NB! As a "Notfallplan" you can use sharelatex or overleaf (free online editors) untill you have fixed your problem.

Amelie B. Blackstone
  • 1,502
  • 1
  • 13
  • 26
  • 2
    The files were saved in an encoding by the first author, and as it states in the file thight have been utf-8. There is no use in setting the inputencoding to different values, make the editor match the encoding. If not, it will become an issue when adding new files. Please see http://texwelt.de/wissen/fragen/2656/wie-uberprufe-ich-die-standardeingabekodierung-in-meinem-editor (assuming you know german). – Johannes_B Jul 29 '15 at 21:44
4

First option with pure LaTeX:

enter image description here

\documentclass[
    fontsize=12pt,
    a4paper,
    portrait,                               
    oneside,                                    
    openright,                              
    final,                                          
    titlepage,                                  
    onecolumn,                                  
    bibliography=totoc,
    numbers=noenddot                    
]{scrbook}
\usepackage{lmodern}    
\usepackage{ifthen}         
\begin{document}

Try \"o, \"a, \"B, \"A, \"u, \"U, ...

\end{document}

This is sure tedious, but try now this second option:

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\begin{document}

Häuser

ü ö ä Ä Ü Ö ß

\end{document}

enter image description here

I used \usepackage [utf8]{inputenc} on Windows.

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
  • 8
    no one should be using [applemac] this century, especially if they are not on a mac. If the \"o syntax is used the input is ASCII so you do not need inputenc at all. – David Carlisle Jul 29 '15 at 20:37
  • 1
    Have you written a text in german like that? it's tedious – Bort Jul 29 '15 at 20:37
  • Thank you trying to help me but this is no alternative cause i have like thousand of öäüß's – Dean Jul 29 '15 at 20:43
  • @Dean See this page, it may help. – AboAmmar Jul 29 '15 at 20:46
  • 3
    @AboAmmar No! almost every line of that page is really bad advice. – David Carlisle Jul 29 '15 at 20:53
  • See the updated example, perhaps change \usepackage[utf8]{inputenc} on Mac. utf8-->applemac – AboAmmar Jul 29 '15 at 20:56
  • @Dean Doesn't this help? – AboAmmar Jul 29 '15 at 21:18
  • Unfortunately not :( With the minimal working example yes, but not with the template i have to use... – Dean Jul 29 '15 at 21:20
  • @DavidCarlisle I don't really see anything that's bad advice on that page other than the suggestion under 1.2 to try inputenc options like ansinew and applemac before trying utf8, an advice that's outdated (but no more outdated that various things mentioned in lshort, which people always recommend). – Sverre Jul 29 '15 at 23:24
  • 3
    @Sverre lshort is a big general introduction (and old) so yes can be out dated in parts but this is a specific page on German accents and suggests {\"A} (outer braces kill any kerning), (n)german package (rather than babel/polyglossia), using platform specific (and in 2/3 cases non standard) encodings rather than utf8. That's quite a high proportion of outdated advice in a rather short page. – David Carlisle Jul 30 '15 at 09:03
  • @DavidCarlisle Ok, didn't know about the kerning issue. – Sverre Jul 30 '15 at 10:48
  • @Sverre -- One piece of bad advice contained in the linked webpage is the suggestion to use the german or ngerman packages. These two packages are known to break all kinds of other stuff. At the very least, the suggestion should be changed to using the babel package with option ngerman or german -- the latter for old (pre-1998) hyphenation and spelling. – Mico Aug 29 '15 at 07:47
1

I don't know if it was mentioned before but you might try LuaLaTex or XeLaTeX which have genuine support for UTF8, means you can write äöüß how you want and all other characters too and don't have to worry about it normally. They have other advantages, too, like embedding other fonts easily etc.

Just ensure you save the TEX files in UTF8 encoding.

musicman
  • 3,559
0

Instead of \usepackage[whatever]{inputenc}, try to use

\usepackage{selinput}
\SelectInputMappings{adieresis={ä},germandbls={ß},Euro={€},} 

in the preamble of your document.

Nico
  • 1,694
  • What is the advantage over just using utf8 encoding? – Daniel Oct 28 '15 at 23:05
  • If the whole document is encoded in utf8 (and you are aware of that), than there's no advantage of using selinput-package. But the problem described sounds very much like there are parts that have different encodings. I had similar issues when copying excerpts from another file not encoded in utf8. Selinput can manage these different encodings, inputenc is determined on the encoding you define (utf8). Read package description for further information: link – Nico Oct 30 '15 at 09:21
  • Hm... IMHO, combining different encodings or being not aware of the actual encoding sound like asking for a lot of later trouble. – Daniel Oct 30 '15 at 12:41
  • You should probably make explicit, that one must not simply copy&paste your code, but actually enter the second line (or at least the umlauts) in the file. Reason: If you copy&paste from any half-recent browser, the encoding will most probably be UTF8. As an extra complication on OS X, this will in most cases even be UTF8-NFD (decomposed form), which "looks right" on screen and in the editor, but makes pdflatex choke. All the glory details to be find here – Daniel Oct 30 '15 at 12:52