3

I have \usepackage[utf8]{inputenc}

I typed

something something γ something

I am getting the error "Package inputenc Error: Unicode character γ (U+03B3)" and it won't render in the output

How can I make that and other modern greek render?

I don't want to use [english, greek]{babel} and select language just for single words at a time

$\gamma$ isn't a solution because math-mode gamma is italicised, and I want the gamma I type using my keyboard γγγγ to render as exactly that (in the typeface that the document is in or whichever most similar typeface supports it)

2 Answers 2

6

In LuaLaTeX or XeLaTeX, load fontspec and select fonts that contain Greek, such as New Computer Modern or Computer Modern Unicode. Either \usepackage{newcomputermodern} or \usepackage{libertinus} should do it.

In PDFLaTeX, you need to load the LGR encoding and the textgreek package for this to work:

\documentclass{article}
\usepackage[LGR,T1]{fontenc}
\usepackage{textgreek}

\begin{document}
something something γ something
\end{document}

This gives you a Greek letter as it would appear in an actual Greek word, which might look different from a math symbol.

An alternative way to get the math symbol is to declare the letter active with newunicodechar:

\usepackage{newunicodechar}
\newunicodechar{γ}{\ensuremath{\gamma}}

You could also use 𝛾 (U+1D6FE) for the mathematical symbol, declaring it the same way. This will not conflict with actual Greek text, should you need it.

2
  • adding \usepackage[LGR,T1]{fontenc} \usepackage{textgreek} after \usepackage[utf8]{inputenc} worked
    – minseong
    Commented Mar 28, 2021 at 2:15
  • 1
    @theonlygusti On some particularly old installations, you might need to put fontenc before inputenc. Since 2018, you haven’t needed inputenc; UTF-8 is the default. But that works.
    – Davislor
    Commented Mar 28, 2021 at 2:16
0

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{03B3}{$\gamma$}
\begin{document}
something something γ something $\gamma$
\end{document}
3
  • 1
    But this is italicised
    – minseong
    Commented Mar 28, 2021 at 2:06
  • was that mentioned in the question
    – js bibra
    Commented Mar 28, 2021 at 2:10
  • 1
    okay thanks I'll specify
    – minseong
    Commented Mar 28, 2021 at 2:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .