2

I've tried the solutions from Entering Unicode characters in LaTeX on Overleaf but they are not working.

Attempt 1: When using \usepackage[utf8]{inputenc}:

\documentclass{article}
\usepackage[letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage[utf8]{inputenc}

\begin{document} To stop the charges, frugal users are advised to click on the ⏻ \end{document}

It throws the error

LaTeX Error: Unicode character ⏻ (U+23FB)

Attempt 2: When trying \DeclareUnicodeCharacter{23FB}{\poweroff}

\documentclass{article}
\usepackage[letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}

\usepackage[utf8]{inputenc} \DeclareUnicodeCharacter{23FB}{\poweroff}

\begin{document} To stop the charges, frugal users are advised to click on the \poweroff \end{document}

It throws the error:

Undefined control sequence.

Attempt 3: When using \usepackage[utf8x]{inputenc}

\documentclass{article}
\usepackage[letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}

\usepackage[utf8x]{inputenc}

\begin{document} To stop the charges, frugal users are advised to click on the ⏻ \end{document}

It throws the error:

Package ucs Error: Unknown Unicode character 9211 = U+23FB,

Attempt 4: Using \usepackage{fontspec}, see https://www.overleaf.com/read/vkyzfjndxkgm

\documentclass{article}
\usepackage[letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}

\begin{document} To stop the charges, frugal users are advised to click on the {\fontspec{Symbola} \symbol{"1F343}} \end{document}

It just didn't compile and threw an error:

(fontspec)                      LuaTeX.
(fontspec)                      
(fontspec)                      You must change your typesetting engine to,
(fontspec)                      e.g., "xelatex" or "lualatex" instead of
(fontspec)                      "latex" or "pdflatex".

Type <return> to continue. ...

l.45 \msg_fatal:nn {fontspec} {cannot-use-pdftex}

alvas
  • 525
  • 1
    \DeclareUnicodeCharacter{23FB}{\poweroff} is fine but you need to define \poweroff as character from some font, or \includegraphics{... some image, or a tikz drawing or ... – David Carlisle Apr 14 '23 at 16:11
  • 2
    for the last you can use lualatex on overleaf, use the left sidebar and there is a dropdown choice to switch from pdflatex to lualatex but remove \usepackage[utf8]{inputenc} in that case (it is best always remove it, it is the default with pdflatex so not needed, and wrong for lualatex and xelatex) – David Carlisle Apr 14 '23 at 16:13
  • 1
    The fontawesome package has \faPowerOff which is maybe similar to what you are looking for. – Jasper Habicht Apr 14 '23 at 16:22
  • 2
    Obey that error from fontspec. Change the compiler to lualatex. – rallg Apr 14 '23 at 17:20

2 Answers2

6

Using lualatex (option in overleaf sidebar) you can use any font that has the character, eg

enter image description here

\documentclass{article}
\usepackage[letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage{fontspec}
\newfontfamily\sfam{symbola}
\begin{document}
To stop the charges, frugal users are advised to click on the {\sfam ⏻}
\end{document}

On the overleaf sidebar:

enter image description here

alvas
  • 525
David Carlisle
  • 757,742
6

As a workaround, if you have trouble with choosing the right font or with setting up the document, you could make use of \faPowerOff provided by the fontawesome package:

\documentclass{article}
\usepackage{fontawesome}

\begin{document} To stop the charges, frugal users are advised to click on the \faPowerOff \end{document}

enter image description here