如何设置带有 °(度数符号)的地址scrlttr2
?
我们来看这个最小的例子:
\documentclass[fontsize=10pt,paper=a4,DIN]{scrlttr2}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\setkomavar{fromaddress}{%
Main Street 1\\
55555 Springfield)}
\setkomavar{fromname}{John Doe}
\begin{document}
\begin{letter}{Jack ° Jones \\
2nd Street 15 \\
55555 Springfield}
\opening{Hi Jack,}
\closing{Yours,}
\end{letter}
\end{document}
里面\begin{letter]
有一个°
在编译时引起问题
! Package inputenc Error: Unicode char \u8:° not set up for use with LaTeX.
当我尝试使用units
类似这样的包时也会发生这种情况
\unit[99]{°}
或\textcelcius
出textcomp
。
答案1
您可以使用siunitx
哪些优惠\degree
和\celsius
\documentclass[fontsize=10pt,paper=a4,DIN]{scrlttr2}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\setkomavar{fromaddress}{%
Main Street 1\\
55555 Springfield)}
\setkomavar{fromname}{John Doe}
\begin{document}
\begin{letter}{Jack \si{\degree} Jones \\
2nd Street 15 \\
55555 Springfield}
\opening{Hi Jack,}
\SI{99}{\celsius}
\closing{Yours,}
\end{letter}
\end{document}
答案2
utf8.def
from 包inputenc
仅支持在声明的输出编码之一中使用的字符。否则 LaTeX 不知道如何打印字符。在 encoding°
中定义TS1
,可以通过包加载textcomp
:
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[utf8]{inputenc}
完整示例:
\documentclass[fontsize=10pt,paper=a4,DIN]{scrlttr2}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[utf8]{inputenc}
\setkomavar{fromaddress}{%
Main Street 1\\
55555 Springfield)}
\setkomavar{fromname}{John Doe}
\begin{document}
\begin{letter}{Jack ° Jones \\
2nd Street 15 \\
55555 Springfield}
\opening{Hi Jack,}
\closing{Yours,}
\end{letter}
\end{document}