如何逐字书写 č,ć,ž,š,đ?

如何逐字书写 č,ć,ž,š,đ?

我遇到了一个问题verbatim,它无法读取我的塞尔维亚语符号,如 č、ć、ž、š、đ。

如果我尝试

\begin{verbatim}
č,ć,ž,š,đ 
\end{verbatim}

我得到的是空白,如果我尝试使用\v{c},\'{c},\v{z},\v{s},\dj{}(此代码用于 TeX 中的 č、ć、ž、š、đ 的普通文本)verbatim,我得到

\v{c},\'{c},\v{z},\v{s},\dj{}

代替

č,ć,ž,š,đ.

我使用 Overleaf,在得到答案后我更新了我的 usepackage

    \documentclass[12pt,leqno, style=sailor,
    display=slides,
    paper=smartboard,
    orient=landscape]{article}



\usepackage{listings}
\lstnewenvironment{code}{%
\lstset{frame=single,escapeinside=`',
  backgroundcolor=\color{yellow!20},
  basicstyle=\footnotesize \ttfamily}
}{}




%\usepackage{latexsym}
%\usepackage{odj}
%\usepackage{lscape}
%\usepackage[landscape]{geometry}

\usepackage[rightcaption]{sidecap}
\usepackage{wrapfig}
\usepackage{graphicx}
%\usepackage[pdftex]{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage[pdflatex]{xcolor}
\usepackage{multicol}
\usepackage[active]{srcltx}
\usepackage{pifont}
\usepackage{amsmath}
\usepackage{gensymb}


\setlength{\topmargin}{-2cm}
\setlength{\oddsidemargin}{-0.3cm}
\setlength{\evensidemargin}{0cm}
\setlength{\textheight}{23.7cm}
\setlength{\textwidth}{17.5cm}


%%%%%%%%%%%%%%%% COLOR DEFINITION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\definecolor{GreenYellow}   {cmyk}{0.15,0,0.69,0}
\definecolor{Yellow}        {cmyk}{0,0,1,0}
\definecolor{Goldenrod}     {cmyk}{0,0.10,0.84,0}
\definecolor{Dandelion}     {cmyk}{0,0.29,0.84,0}
\definecolor{Apricot}       {cmyk}{0,0.32,0.52,0}
\definecolor{Pea\v{c}}         {cmyk}{0,0.50,0.70,0}
\definecolor{Melon}         {cmyk}{0,0.46,0.50,0}
\definecolor{YellowOrange}  {cmyk}{0,0.42,1,0}
\definecolor{Orange}        {cmyk}{0,0.61,0.87,0}
\definecolor{BurntOrange}   {cmyk}{0,0.51,1,0}
\definecolor{Bittersweet}   {cmyk}{0,0.75,1,0.24}
\definecolor{RedOrange}     {cmyk}{0,0.77,0.87,0}
\definecolor{Mahogany}      {cmyk}{0,0.85,0.87,0.35}
\definecolor{Maroon}        {cmyk}{0,0.87,0.68,0.32}
\definecolor{BrickRed}      {cmyk}{0,0.89,0.94,0.28}
\definecolor{Red}           {cmyk}{0,1,1,0}
\definecolor{OrangeRed}     {cmyk}{0,1,0.50,0}
\definecolor{RubineRed}     {cmyk}{0,1,0.13,0}
\definecolor{WildStrawberry}{cmyk}{0,0.96,0.39,0}
\definecolor{Salmon}        {cmyk}{0,0.53,0.38,0}
\definecolor{CarnationPink} {cmyk}{0,0.63,0,0}
\definecolor{Magenta}       {cmyk}{0,1,0,0}
\definecolor{VioletRed}     {cmyk}{0,0.81,0,0}
\definecolor{Rhodamine}     {cmyk}{0,0.82,0,0}
\definecolor{Mulberry}      {cmyk}{0.34,0.90,0,0.02}
\definecolor{RedViolet}     {cmyk}{0.07,0.90,0,0.34}
\definecolor{Fu\v{c}sia}       {cmyk}{0.47,0.91,0,0.08}
\definecolor{Lavender}      {cmyk}{0,0.48,0,0}
\definecolor{Thistle}       {cmyk}{0.12,0.59,0,0}
\definecolor{Or\v{c}id}        {cmyk}{0.32,0.64,0,0}
\definecolor{DarkOr\v{c}id}    {cmyk}{0.40,0.80,0.20,0}
\definecolor{Purple}        {cmyk}{0.45,0.86,0,0}
\definecolor{Plum}          {cmyk}{0.50,1,0,0}
\definecolor{Violet}        {cmyk}{0.79,0.88,0,0}
\definecolor{RoyalPurple}   {cmyk}{0.75,0.90,0,0}
\definecolor{BlueViolet}    {cmyk}{0.86,0.91,0,0.04}
\definecolor{Periwinkle}    {cmyk}{0.57,0.55,0,0}
\definecolor{CadetBlue}     {cmyk}{0.62,0.57,0.23,0}
\definecolor{CornflowerBlue}{cmyk}{0.65,0.13,0,0}
\definecolor{MidnightBlue}  {cmyk}{0.98,0.13,0,0.43}
\definecolor{NavyBlue}      {cmyk}{0.94,0.54,0,0}
\definecolor{RoyalBlue}     {cmyk}{1,0.50,0,0}

\definecolor{Blue}          {cmyk}{1,1,0,0}
\definecolor{Cerulean}      {cmyk}{0.94,0.11,0,0}
\definecolor{Cyan}          {cmyk}{1,0,0,0}
\definecolor{ProcessBlue}   {cmyk}{0.96,0,0,0}
\definecolor{SkyBlue}       {cmyk}{0.62,0,0.12,0}
\definecolor{Turquoise}     {cmyk}{0.85,0,0.20,0}
\definecolor{TealBlue}      {cmyk}{0.86,0,0.34,0.02}
\definecolor{Aquamarine}    {cmyk}{0.82,0,0.30,0}
\definecolor{BlueGreen}     {cmyk}{0.85,0,0.33,0}
\definecolor{Emerald}       {cmyk}{1,0,0.50,0}
\definecolor{JungleGreen}   {cmyk}{0.99,0,0.52,0}
\definecolor{SeaGreen}      {cmyk}{0.69,0,0.50,0}
\definecolor{Green}         {cmyk}{1,0,1,0}
\definecolor{ForestGreen}   {cmyk}{0.91,0,0.88,0.12}
\definecolor{PineGreen}     {cmyk}{0.92,0,0.59,0.25}
\definecolor{LimeGreen}     {cmyk}{0.50,0,1,0}
\definecolor{YellowGreen}   {cmyk}{0.44,0,0.74,0}
\definecolor{SpringGreen}   {cmyk}{0.26,0,0.76,0}
\definecolor{OliveGreen}    {cmyk}{0.64,0,0.95,0.40}
\definecolor{RawSienna}     {cmyk}{0,0.72,1,0.45}
\definecolor{Sepia}         {cmyk}{0,0.83,1,0.70}
\definecolor{Brown}         {cmyk}{0,0.81,1,0.60}
\definecolor{Tan}           {cmyk}{0.14,0.42,0.56,0}
\definecolor{Gray}          {cmyk}{0,0,0,0.50}
\definecolor{Black}         {cmyk}{0,0,0,1}
\definecolor{White}         {cmyk}{0,0,0,0}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\dj{d\kern-0.4em\\v{c}ar"16\kern-0.1em}
\def\Dj{\mbox{\raise0.3ex\hbox{-}\kern-0.4em D}}

\def\o{\omega}
\def\e{\varepsilon}
\def\F{{\cal F}}
\def\f{\frac}
\def\p{\partial}
\def\vf{\varphi}
\def\vfp{\varphi^\prime}
\def\l{\lambda}
\def\L{{\bf L}}
\def\a{\alpha}
\def\b{\beta}
\def\ol{\overline}
\def\R{{\Bbb R}}\def\G{{\Bbb G}}\def\D{{\Bbb D}}
\def\C{{\Bbb C}}
\def\nin{\noindent}
\def\DJ{{\rm DJ\ }}

\newcommand{\tg}{\mathop{\rm tg}\nolimits}
\newcommand{\ctg}{\mathop{\rm ctg}\nolimits}
\newcommand{\arctg}{\mathop{\rm arctg}\nolimits}
\newcommand{\arcctg}{\mathop{\rm arcctg}\nolimits}


\def\df{\displaystyle\frac}
\def\dsum{\displaystyle\sum}
\def\dint{\displaystyle\int}
\def\fstp{{\hskip-0.5em}{\bf .}{\hskip0.5em}}

%\renewcommand{\figurename}{Slika}%
\newtheorem{te}{Teorema}
\newtheorem{de}{Definicija}
\newtheorem{po}{Posledica}
\newtheorem{lema}{Lema}
\newtheorem{stav}{Stav}
\newtheorem{primer}{Primer}

\def\bt{\color{Maroon}\begin{te}}
\def\et{\end{te}}

\def\bd{\color{Blue}\begin{de}}
\def\ed{\end{de}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Č \v{C} %
% Đ \Dj{} %
% Š \v{S} %
% Ž \v{Z} %

% č \v{c} %
% ć \'{c} %
% đ \dj{} %
% š \v{s} %
% ž \v{z} %

有了这个包我得到空白

   \begin{verbatim}
č,ć,ž,š,đ 
\end{verbatim}

当我添加

\usepackage[T1]{fontenc}     % default is 'OT1'
%\usepackage[utf8]{inputenc} % needed if you have an older TeX distribution
\usepackage{lmodern}         % recommended
\setlength\parindent{0pt}    % just for this example

我得到了“ÄŊÄĞÅ”ÅąÄŚ 。

答案1

我假设您使用 pdfLaTEx 编译文档。如果是这样,那么只要您的 TeX 发行版是最新的,您需要做的就是 (a) 使用fontenc选项加载包T1(需要覆盖的默认值是OT1)和 (b) 加载字体包,例如lmodern针对重音字形进行了优化的字体包。如果您有较旧的 TeX 发行版(即超过 1 年),您还需要 (c)inputenc使用合适的选项加载包;很有可能,该utf8选项就没问题。

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}     % default is 'OT1'
%\usepackage[utf8]{inputenc} % needed if you have an older TeX distribution
\usepackage{lmodern}         % recommended
\setlength\parindent{0pt}    % just for this example

\begin{document}
č ć ž š đ

\textsf{č ć ž š đ}

\texttt{č ć ž š đ}

\begin{verbatim}
č,ć,ž,š,đ 
\end{verbatim}
\end{document}

相关内容