# Which inputenc for these Latvian letters?

I type in English but I need the following few Latvian letters.

Minimal case

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
diņš
\end{document}


which gives di only.

How can you have those Latvian letters?

The letter š is supported by the T1 encoding and you should load

\usepackage[T1]{fontenc}


anyway. The “n with cedilla” is not supported by the fonts, so it must be composed. With newunicodechar it's pretty easy:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{newunicodechar}
\newunicodechar{Ņ}{\c{N}}
\newunicodechar{ņ}{\c{n}}

\begin{document}
diņš DIŅŠ
\end{document}


However you might prefer a comma below, instead of a cedilla.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{newunicodechar}

\makeatletter
\ProvideTextCommandDefault\textlatviancommabelow[1]
{\hmode@bgroup\ooalign{\null#1\crcr\hidewidth
\raise-.15ex\hbox{\check@mathfonts
\fontsize\ssf@size\z@
\math@fontsfalse\selectfont,}\hidewidth}\egroup}
\makeatother

\newunicodechar{Ņ}{\textlatviancommabelow{N}}
\newunicodechar{ņ}{\textlatviancommabelow{n}}

\begin{document}
diņš DIŅŠ
\end{document}


With some more work you can make the composite character copyable (provided the PDF viewer supports the feature; Adobe Reader does); the following is similar to my answer to Unable to search word with Romanian characters in output pdf

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{accsupp}
\usepackage{newunicodechar}

\makeatletter
\ProvideTextCommandDefault\textlatviancommabelow[1]
{\hmode@bgroup\ooalign{\null#1\crcr\hidewidth
\raise-.15ex\hbox{\check@mathfonts
\fontsize\ssf@size\z@
\math@fontsfalse\selectfont,}\hidewidth}\egroup}
\makeatother

\newunicodechar{Ņ}{%
\BeginAccSupp{method=hex,unicode,ActualText=0145}%
\textlatviancommabelow{N}%
\EndAccSupp{}%
}
\newunicodechar{ņ}{%
\BeginAccSupp{method=hex,unicode,ActualText=0146}%
\textlatviancommabelow{n}%
\EndAccSupp{}%
}
\begin{document}
diņš DIŅŠ
\end{document}

• Thank you very much for your fast answer with clear examples! – Léo Léopold Hertz 준영 Nov 21 '14 at 21:21
• wouldn't inverted accent-grave be a bit better? – yo' Nov 22 '14 at 15:38
• @tohecz I don't think so, but it depends on preferences. – egreg Nov 22 '14 at 15:52
• @Masi I have a workaround (ugly). The best thing to do would be persuading the maintainer of europecv that using utf8 is good. A new question is surely necessary: other people might incur in the same problem. – egreg Dec 15 '14 at 14:31
• @Masi The game is the usual one: open a new question with a MWE – egreg Feb 26 '15 at 14:10

UTF-8 input is fine, you just need to tell tex what to do with that character:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{0146}{\c{n}}
\begin{document}
diņš
\end{document}


If you can use XeLaTeX or LuaLaTeX, I would like to welcome you to current century:

\documentclass{article}
\usepackage{polyglossia} % also loads package fontspec
\setmainfont{Minion Pro} % or whatever OTF you have on your system
\setmainlanguage{latvian} % loads language hyphenation rules and such

\usepackage{unicode-math} % if you also need maths
\setmathfont{Cambria Math} % or whatever math OTF you have on your system

\begin{document}
diņš
\end{document}


(and save your files in utf8)

• I really like this answer! Kiitos! @egrep What do you think about this? I think the typography here is better. What are possible side-effects etc? I only need those Latvian characters to type the name of my university. Mostly, I am writing English. I like the math-things there too. – Léo Léopold Hertz 준영 Nov 22 '14 at 15:42
• I set the language to be english as \setmainlanguage{english} and I still get the correct symbols for the name of my university. So "Contents" is seen correctly, and not in Latvian. – Léo Léopold Hertz 준영 Nov 22 '14 at 15:45
• @Masi: Jūs esat laipni. (I hope Google translate did that correctly). But yes, I assumed your text would've been in Latvian, but I see you already found out how to change that :) – morbusg Nov 22 '14 at 15:49
• @Masi If you're bound to pdflatex this is nothing you can make profit of. If you can use XeLaTeX or LuaLaTeX, of course you get the “real” glyph. – egreg Nov 22 '14 at 15:52
• @Masi: I guess egreg didn't see your question because you misspelled his handle, but I think what he meant is that the line: \usepackage[utf8]{inputenc} would assume PDFLaTeX because you wouldn't use it with (Lua/Xe)LaTeX. Although, to know that already requires some amount of expertise. I think it would be helpful to draw some kind of diagram regarding different engine choices and link it to our help pages. – morbusg Nov 29 '14 at 9:09

It's the older version: utf8x, but this works with pdflatex

\documentclass{article}
\usepackage[T1]{fontenc}%
\usepackage[utf8x]{inputenc}
\begin{document}
diņš
\end{document}


• I wouldn't recommend loading utf8x – egreg Nov 21 '14 at 21:06
• @egreg: I know... it's outdated – user31729 Nov 21 '14 at 21:07
• @ChristianHupfer ... it’s outdated, but it works here. if the user agrees to sign a declaration that he’ll never use the package elsewhere, perhaps he should be allowed to use it. after all, it saves him typing. (in fact, errors with utf8x are pretty rare, so they tend to “throw” us when they do appear.) – wasteofspace Nov 22 '14 at 14:40