# How to write a letter “ģ”

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}

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

• With \char"0123 – User Dec 13 '15 at 14:13
• Do you use either LuaLaTeX or XeLaTeX, or do you use pdfLaTeX? Please advise. – Mico Dec 13 '15 at 14:16
• @Mico I want to compile it with pdflatex. It looks like only piece which now forces me to use xelatex (sometimes latex engine is hardcoded in software for example ipe.otfried.org). – Jānis Erdmanis Dec 13 '15 at 17:34
• I wouldn't really recommend combelow. – egreg Dec 13 '15 at 23:22
• @JānisErdmanis This is a “question and answers” site. You should provide an answer, instead of modifying the question to provide a solution. On the other hand, your question was just about ģ, and you're adding much more. Moreover, abusing \c for all diacritics is certainly wrong. – egreg Dec 13 '15 at 23:44

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.)

• Do I understand correctly that \DeclareUnicodeCharacter fix should be adressed to inputenc package? – Jānis Erdmanis Dec 29 '15 at 19:14
• I am a bit puzzled why it is not a babel issue, since when you add it half of the characters gets defined. – Jānis Erdmanis Dec 29 '15 at 20:22
• @JānisErdmanis See my edit. – Javier Bezos Dec 30 '15 at 10:12
• This is what I was looking for :) – Jānis Erdmanis Dec 30 '15 at 12:00
• I didn't test it with fourier package, but with lmodern I also am getting great results. – Jānis Erdmanis Dec 30 '15 at 12:04

Unfortunately, Latvian is quite poorly supported by babel: the letters with the comma diacritic are wrongly realized with a cedilla.

Here's a possibly better realization.

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

\makeatletter
\DeclareTextCommandDefault\textcommaabove[1]{%
\hmode@bgroup
\ooalign{%
\hidewidth
\raise.7ex\hbox{%
\check@mathfonts\fontsize\ssf@size\z@\math@fontsfalse\selectfont%
}%
\hidewidth\crcr
\null#1\crcr
}%
\egroup
}
\makeatother
\DeclareTextCompositeCommand{\c}{T1}{G}{\textcommabelow{G}}
\DeclareTextCompositeCommand{\c}{T1}{g}{\textcommaabove{g}}
\DeclareTextCompositeCommand{\c}{T1}{K}{\textcommabelow{K}}
\DeclareTextCompositeCommand{\c}{T1}{k}{\textcommabelow{k}}
\DeclareTextCompositeCommand{\c}{T1}{L}{\textcommabelow{L}}
\DeclareTextCompositeCommand{\c}{T1}{l}{\textcommabelow{l}}
\DeclareTextCompositeCommand{\c}{T1}{N}{\textcommabelow{N}}
\DeclareTextCompositeCommand{\c}{T1}{n}{\textcommabelow{n}}
\DeclareTextCompositeCommand{\c}{T1}{R}{\textcommabelow{R}}
\DeclareTextCompositeCommand{\c}{T1}{r}{\textcommabelow{r}}

\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}}

\begin{document}

\c{g} \c{G} ģ Ģ

\c{k} \c{K} ķ Ķ

\c{l} \c{L} ļ Ļ

\c{n} \c{N} ņ Ņ

\c{r} \c{R} ŗ Ŗ

\end{document}

If you don't have a recent LaTeX kernel (that is, a release before 2015/01/01) you may need to add support for \textcommabelow; in this case add, after \makeatletter,

\@ifundefined{textcommabelow}{%
\DeclareTextCommandDefault\textcommabelow[1]
{\hmode@bgroup\ooalign{\null#1\crcr\hidewidth\raise-.31ex
\hbox{\check@mathfonts\fontsize\ssf@size\z@
\math@fontsfalse\selectfont,}\hidewidth}\egroup}%
}{}

# Example for the full Latvian alphabet

The bar over the vowels might need some refinement.

\documentclass{article}

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

\makeatletter
\DeclareTextCommandDefault\textcommaabove[1]{%
\hmode@bgroup
\ooalign{%
\hidewidth
\raise.7ex\hbox{%
\check@mathfonts\fontsize\ssf@size\z@\math@fontsfalse\selectfont%
}%
\hidewidth\crcr
\null#1\crcr
}%
\egroup
}
% for older TeX distributions that don't have \textcommabelow
\@ifundefined{textcommabelow}{%
\DeclareTextCommandDefault\textcommabelow[1]
{\hmode@bgroup\ooalign{\null#1\crcr\hidewidth\raise-.31ex
\hbox{\check@mathfonts\fontsize\ssf@size\z@
\math@fontsfalse\selectfont,}\hidewidth}\egroup}%
}{}
\makeatother

% (re)declare some text composites
\DeclareTextCompositeCommand{\c}{T1}{G}{\textcommabelow{G}}
\DeclareTextCompositeCommand{\c}{T1}{g}{\textcommaabove{g}}
\DeclareTextCompositeCommand{\c}{T1}{K}{\textcommabelow{K}}
\DeclareTextCompositeCommand{\c}{T1}{k}{\textcommabelow{k}}
\DeclareTextCompositeCommand{\c}{T1}{L}{\textcommabelow{L}}
\DeclareTextCompositeCommand{\c}{T1}{l}{\textcommabelow{l}}
\DeclareTextCompositeCommand{\c}{T1}{N}{\textcommabelow{N}}
\DeclareTextCompositeCommand{\c}{T1}{n}{\textcommabelow{n}}
\DeclareTextCompositeCommand{\c}{T1}{R}{\textcommabelow{R}}
\DeclareTextCompositeCommand{\c}{T1}{r}{\textcommabelow{r}}

% declare some Unicode characters
\DeclareUnicodeCharacter{0100}{\=A}
\DeclareUnicodeCharacter{0101}{\=a}
\DeclareUnicodeCharacter{0112}{\=E}
\DeclareUnicodeCharacter{0113}{\=e}
\DeclareUnicodeCharacter{012A}{\=I}
\DeclareUnicodeCharacter{012B}{\=\i}
\DeclareUnicodeCharacter{016A}{\=U}
\DeclareUnicodeCharacter{016B}{\=u}
\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}}

\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}

The output is much better when adding \usepackage{lmodern}:

If you use LuaLaTeX or XeLaTeX, you just need to use a font that supports the glyphs, for instance CMU Serif or Linux Libertine.

\documentclass{article}

\usepackage[latvian]{babel}
\usepackage{fontspec}
\setmainfont{CMU Serif}
%\setmainfont{Linux Libertine O}

\begin{document}

\c{g} \c{G} ģ Ģ

\c{k} \c{K} ķ Ķ

\c{l} \c{L} ļ Ļ

\c{n} \c{N} ņ Ņ

\c{r} \c{R} ŗ Ŗ

\end{document}

### Output with Linux Libertine

• The command \textcommabelow worked indeed as expected, however the command \textcommaabove was not found in my system (Ubuntu 15.10). Could you tell your system configuration so \textcommaabove works? – Jānis Erdmanis Dec 13 '15 at 16:00
• @JānisErdmanis Sorry, I don't have it for testing. Does my solution work? – egreg Dec 13 '15 at 16:02
• Have you used your defined \textcommabelow with latex compilator? Should it work? – Jānis Erdmanis Dec 13 '15 at 17:46
• @JānisErdmanis Yes, it works provided you have an up-to-date TeX system. But if your system doesn't acknowledge \textcommabelow, you can add the definition as I showed. The definition of \textcommaabove is in the document, so it should work. – egreg Dec 13 '15 at 22:06
• Actually, if combelow is loaded latvian modifies its behaviour to render these characters correctly. The fact inputenc doesn't recognizes them, on the other hand, is nor directly related to babel (as explained in the babel-latvian manual). Now the LaTeX core provides a comma below, and a better one, I'll update the style (and perhaps avoid the dependency on `combelow', too, for older versions). – Javier Bezos Dec 29 '15 at 17:57