# Unicode character ſ (U+17F) in LyX 2.3

How to use the following character ſ (U+17F) in LyX? Setting the UTF8 encoding does not work:

Package inputenc Error: Unicode character Ĺż (U+17F)


The complete source code of the document is:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\begin{document}
ſ
\end{document}


I have also tried to use:

\DeclareUnicodeCharacter{17F}{ſ}


• Please check the site for "Package inputenc Error: Unicode character", there are quite a few occurences. – albert Aug 30 '18 at 9:46
• @ albert: May I kindly ask you for the clarification of your recommendation? Thanks. – justik Aug 30 '18 at 10:47
• On the top of the page there is a "Search on TeX - LaTeX..." give the text there or use Google. – albert Aug 30 '18 at 11:09

First we have to find a way to insert the needed glyph. The standard font Computer Modern does not include a ſ, so another font is needed. A good alternative is Latin Modern, which should be mostly compatible with Computer Modern but features a significantly wider range of characters. Latin Modern has ſ encoded in slot 115 (ASCII s) of the TS1 encoding.

To make the TS1 encoding available, replace

\usepackage[T1]{fontenc}


with

\usepackage[TS1,T1]{fontenc}


Then you have two options: Use Latin Modern for you entire document or only use one glyph from this font. If you want to use the complete font, add

\usepackage{lmodern}
\DeclareUnicodeCharacter{17F}{{%
\fontencoding{TS1}%
\selectfont s%
}}


\DeclareUnicodeCharacter{17F}{{%
\fontencoding{TS1}%
\fontfamily{lmr}%
\selectfont s%
}}


This tells LaTeX to use the s from encoding TS1 (and family lmr), whenever Unicode character U+017F is requested.

\documentclass[english]{article}
\usepackage[TS1,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{lmodern}
\DeclareUnicodeCharacter{17F}{{%
\fontencoding{TS1}%
\selectfont s%
}}
\begin{document}
ſ
\end{document}


A more elegant solution would be switching to LuaLaTeX, there you can directly use ſ as long as the character exists in your font.

• @ Marcel: Thank you very much for your detailed explanation of the problem as well as for the proposed solution. It works well. Is there any other font supporting this unicode character? – justik Aug 30 '18 at 12:34
• @justik Without LuaTeX or XeTeX, you can not really speak about fonts supporting a unicode character, because they use completely different encodings than unicode. Anyway there probably are other fonts with this character, but I do not know them. You could try DayRoman. Also kpfonts includes the glyph but it is accessed in another way. See the documentation for details. – Marcel Krüger Aug 30 '18 at 12:53
• @ Marcel: Thanks. I will try the recommended fonts... – justik Aug 30 '18 at 14:08