Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In my document, which is encoded as utf8 throughout (hopefully), umlaute etc. in the document body are put out correctly, but those defined in a \newcommand are not. I have tried some alternatives to writing the unlaute plain, and \symbol works, while the international accent does not, and I'd rather not use it since it is a little cumbersome.

See the following example:

\newcommand{\myPlace}{Örtlichkeit}
\newcommand{\myWhat}{\"{O}rtlichkeit}
\newcommand{\myHmm}{Stra\symbol{255}e}

\documentclass{scrlttr2} 

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

\begin{document}

\myPlace

\myWhat

\myHmm

ÖÄÜäöüß
\end{document}

Thanks for any input!

share|improve this question
    
Thanks! That was a really stupid error. I adapted the document, and changed the inputenc. I even thought "Maybe I should check the position of the newcommand before I open a question ..." :/ If you put this is an answer, I will gladly mark it as correct. e: Oh, the other mistake was even more stupid ... not my day today! –  Narretz Sep 21 '12 at 12:06
2  
If you want to leave the definitions at the top, you should use the LaTeX internal character representation (LICR) of the characters; so \newcommand{\myPlace}{\"{O}rtlichkeit} and \newcommand{\myHmmm}{Stra\ss e}. It's the inputenc package that assigns the desired meaning to the non ASCII characters and using them before loading the package can lead to puzzling results. –  egreg Sep 21 '12 at 12:08
    
@Narretz - I've resubmitted my comment as an answer, per your suggestion. I've also fixed the typo in the second \newcommand instruction. –  Mico Sep 21 '12 at 12:15

1 Answer 1

up vote 2 down vote accepted

If you move the three \newcommand instructions to a point after the \usepackage[utf8]{inputenc} instruction, you won't experience the problems you're reporting.

Addendum -- A comment provided by @egreg -- If you wanted to leave the definitions at the top, you should use the LaTeX internal character representation (LICR) of the characters: \newcommand{\myPlace}{\"{O}rtlichkeit} and \newcommand{\myHmmm}{Stra\ss e}. It's the inputenc package that assigns the desired meaning to the non-ASCII characters, and using them before loading the package is what leads to puzzling results.

share|improve this answer
    
If you like, you can move also my comment in your answer. –  egreg Sep 21 '12 at 12:16
1  
Move @egreg's comments after your answer and you will experience a full answer. –  ℝaphink Sep 21 '12 at 12:55
1  
For a full answer babel shorthands are missing, they are available after package babel is loaded and activated in \begin{document} for the main language by default. –  Heiko Oberdiek Sep 21 '12 at 12:59
    
@HeikoOberdiek My point was how to have the commands safely at the top, which can be handy in some applications; your useful comment adds that those shortcuts can't be used there. –  egreg Sep 21 '12 at 13:05
1  
@HeikoOberdiek I wouldn't recommend to the general public starting a file with \catcode declarations. ;-) –  egreg Sep 21 '12 at 14:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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