[Tex/LaTex] How to write a letter “ģ”

charactersfontsinput-encodings

In my language we use the letter "ģ" representing LATIN SMALL LET­TER G WITH CEDILLA with code U+0123. How can I write it with pure latex?

Solution
Ok I got what I wanted, thanks to WriteLatex utf-8 ģ symbol problem and @egreg answer. The basic code which writes all Latvian alphabet looks like:

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

\usepackage{combelow}

\DeclareTextCompositeCommand{\c}{T1}{G}{\cb{G}}
\DeclareTextCompositeCommand{\c}{T1}{g}{\cb{g}}
\DeclareTextCompositeCommand{\c}{T1}{K}{\cb{K}}
\DeclareTextCompositeCommand{\c}{T1}{k}{\cb{k}}
\DeclareTextCompositeCommand{\c}{T1}{L}{\cb{L}}
\DeclareTextCompositeCommand{\c}{T1}{l}{\cb{l}}
\DeclareTextCompositeCommand{\c}{T1}{N}{\cb{N}}
\DeclareTextCompositeCommand{\c}{T1}{n}{\cb{n}}
\DeclareTextCompositeCommand{\c}{T1}{R}{\cb{R}}
\DeclareTextCompositeCommand{\c}{T1}{r}{\cb{r}}

\DeclareTextCompositeCommand{\c}{T1}{a}{\={a}}
\DeclareTextCompositeCommand{\c}{T1}{A}{\={A}}
\DeclareTextCompositeCommand{\c}{T1}{e}{\={e}}
\DeclareTextCompositeCommand{\c}{T1}{E}{\={E}}
\DeclareTextCompositeCommand{\c}{T1}{i}{\=\i}
\DeclareTextCompositeCommand{\c}{T1}{I}{\={I}}
\DeclareTextCompositeCommand{\c}{T1}{u}{\={u}}
\DeclareTextCompositeCommand{\c}{T1}{U}{\={U}}

\DeclareTextCompositeCommand{\c}{T1}{c}{\v{c}}
\DeclareTextCompositeCommand{\c}{T1}{C}{\v{C}}
\DeclareTextCompositeCommand{\c}{T1}{s}{\v{s}}
\DeclareTextCompositeCommand{\c}{T1}{S}{\v{S}}
\DeclareTextCompositeCommand{\c}{T1}{z}{\v{z}}
\DeclareTextCompositeCommand{\c}{T1}{Z}{\v{Z}}


\DeclareUnicodeCharacter{0122}{\c{G}}
\DeclareUnicodeCharacter{0123}{\c{g}}
\DeclareUnicodeCharacter{0136}{\c{K}}
\DeclareUnicodeCharacter{0137}{\c{k}}
\DeclareUnicodeCharacter{013B}{\c{L}}
\DeclareUnicodeCharacter{013C}{\c{l}}
\DeclareUnicodeCharacter{0145}{\c{N}}
\DeclareUnicodeCharacter{0146}{\c{n}}
\DeclareUnicodeCharacter{0156}{\c{R}}
\DeclareUnicodeCharacter{0157}{\c{r}}

\DeclareUnicodeCharacter{0100}{\c{A}}
\DeclareUnicodeCharacter{0101}{\c{a}}
\DeclareUnicodeCharacter{0112}{\c{E}}
\DeclareUnicodeCharacter{0113}{\c{e}}
\DeclareUnicodeCharacter{012A}{\c{I}}
\DeclareUnicodeCharacter{012B}{\c{i}}
\DeclareUnicodeCharacter{016A}{\c{U}}
\DeclareUnicodeCharacter{016B}{\c{u}}

\DeclareUnicodeCharacter{010C}{\c{C}}
\DeclareUnicodeCharacter{010D}{\c{c}}
\DeclareUnicodeCharacter{0160}{\c{S}}
\DeclareUnicodeCharacter{010E}{\c{s}}
\DeclareUnicodeCharacter{017D}{\c{Z}}
\DeclareUnicodeCharacter{017E}{\c{z}}

\begin{document}
Aa, Āā, Bb, Cc, Čč, Dd, Ee, Ēē, Ff, Gg, Ģģ, Hh, Ii, Īī, Jj, Kk, Ķķ, Ll, Ļļ, Mm, Nn, Ņņ, Oo, Pp, Rr, Ss, Šš, Tt, Uu, Ūū, Vv, Zz, Žž
\end{document}

Latvian with pure latex

Simplificaction Could it be a part of latvian babel? What are the steps to get the package in CTAN?

Best Answer

If you don't mind relying on combelow I think the simplest solution is:

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{combelow}
\usepackage[latvian.t1composite]{babel}
\usepackage{lmodern}

\DeclareUnicodeCharacter{0122}{\c{G}}
\DeclareUnicodeCharacter{0123}{\c{g}}
\DeclareUnicodeCharacter{0136}{\c{K}}
\DeclareUnicodeCharacter{0137}{\c{k}}
\DeclareUnicodeCharacter{013B}{\c{L}}
\DeclareUnicodeCharacter{013C}{\c{l}}
\DeclareUnicodeCharacter{0145}{\c{N}}
\DeclareUnicodeCharacter{0146}{\c{n}}
\DeclareUnicodeCharacter{0156}{\c{R}}
\DeclareUnicodeCharacter{0157}{\c{r}}

\DeclareUnicodeCharacter{0100}{\={A}}
\DeclareUnicodeCharacter{0101}{\={a}}
\DeclareUnicodeCharacter{0112}{\={E}}
\DeclareUnicodeCharacter{0113}{\={e}}
\DeclareUnicodeCharacter{012A}{\={I}}
\DeclareUnicodeCharacter{012B}{\={i}}
\DeclareUnicodeCharacter{016A}{\={U}}
\DeclareUnicodeCharacter{016B}{\={u}}

\begin{document} 
Aa, Āā, Bb, Cc, Čč, Dd, Ee, Ēē, Ff, Gg, Ģģ, Hh, Ii, Īī, Jj, Kk, Ķķ,
Ll, Ļļ, Mm, Nn, Ņņ, Oo, Pp, Rr, Ss, Šš, Tt, Uu, Ūū, Vv, Zz, Žž
\end{document}

Note fontencand combelow are loaded before babel. See the manual for further info. (Internally, \c{g} has a different definition, just in case, and as to the undefined Unicode characters, this is not directly related to babel).


EDIT. And even simpler... (why didn't I think of that before? :-)).

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage[L7x,T1]{fontenc}
\usepackage{combelow}
\usepackage[latvian.t1composite]{babel}
\usepackage{fourier}

\begin{document} 
Aa, Āā, Bb, Cc, Čč, Dd, Ee, Ēē, Ff, Gg, Ģģ, Hh, Ii, Īī, Jj, Kk, Ķķ,
Ll, Ļļ, Mm, Nn, Ņņ, Oo, Pp, Rr, Ss, Šš, Tt, Uu, Ūū, Vv, Zz, Žž
\end{document}

Why does it work? The problem is utf8 only defines the available characters (ie, precomposed) in the requested font encodings. T1 doesn't contain these Latvian characters, and therefore they remain undefined. This is by design, for efficiency reasons, so it's not a bug (perhaps a misfeature). However, L7x does include them, and therefore they are defined. But IMO, loading an unused font encoding is far from ideal. (Caveat: some fonts render macron-i with the dot, because l7xenc.def defines it as \=i.)