I want to add these two utf-8 symbols ☐ , ⌧ in my latex document, I also added \usepackage[utf8]{inputenc}
. How can I do that?
[Tex/LaTex] How to add utf-8 symbols correctly
text;unicode
Related Question
- [Tex/LaTex] How to change a .tex file’s input encoding system (preferably to UTF-8)
- [Tex/LaTex] Problem with defining new unicode character
- [Tex/LaTex] To input symbols with utf8 codes beyond the standard utf8 packet in Latex
- [Tex/LaTex] Package inputenc Error: Unicode char (U+2060)(inputenc) not set up for use with LaTeX
- [Tex/LaTex] How to (La)TeX read UTF-8
Best Answer
If you use a Unicode engine (
xetex
orluatex
) it is just a matter of finding a font, which offers these symbols. I have expereinced the DejaVu Sans font to be pretty complete in that regard. You might not want to change the font of the whole document just for these symbols, so it becomes necessary to allocate a\newfontfamily
which I named\boxedsymbols
. Then you can locally switch fonts to print the exotic symbols.For
pdflatex
, there is the possibility to make the Unicode characters active and define them to print a symbol, that is available in the font, which looks similar. Here I use the math symbols\square
and\boxtimes
(fromamssymb
). Note, that these are not the actual Unicode symbols which you enter in your document, but rather visual equivalents.If you want to use them in math-mode as well, replace
$<symbol>$
by\ensuremath{<symbol>}
. (This is one of the rare cases, where\ensuremath
is appropriate.)The functionality obtained with the
pdflatex
solution, namely typing the symbols directly without having to switch fonts, seems appealing and can also be achieved with thexetex
/luatex
variant. Bear in mind, that this is not really a good practice, as now the characters☐
,⌧
are active and code is executed each time they are encountered in the text.The output is the same as for the first variant.