使用 TikZ 在花式目录中书写希腊文时出现编码问题

使用 TikZ 在花式目录中书写希腊文时出现编码问题

我正在使用 TikZ 创建一个精美的目录。我的代码是

\documentclass{book}
\usepackage{kerkis}
\usepackage{pifont}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage{epigraph}
\usepgflibrary{qrr.shapes.openrectangle}

\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{myblueii}{RGB}{63,200,244}
\definecolor{myblueiii}{RGB}{199,234,253}

\tikzset{
mynode/.style={
  rounded corners=30pt,
  shape=open rectangle,
  open rectangle fill=myblueii,
  open rectangle sides=#1,
  }
}

\titleformat{\chapter}[display]
  {\normalfont\huge\sffamily}
  {}
  {20pt}
  {%
  \begin{tikzpicture}[remember picture,overlay]
  \node[
    anchor=west,
    rectangle,
    minimum height=4cm,
    text width=\paperwidth,
    xshift=-\the\dimexpr\oddsidemargin+1in\relax,
    outer sep=0pt,
    fill=myblueiii] (titlerect) {};
  \node[
    anchor=south west,
    xshift=2cm,
    text width=\textwidth] 
    at ([yshift=5pt]titlerect.south west) {\fontsize{30}{36}\selectfont#1};
  \node[
    mynode=nw,
    anchor=south east,
    fill=myblueii,
    inner xsep=1.5cm,
    outer sep=0pt,
    font=\color{white},
    minimum height=30pt] 
    at (current page.east|-titlerect.north)
     {\bfseries\MakeUppercase{\chaptertitlename}\ \thechapter};
  \end{tikzpicture}%
  }
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\huge\sffamily}
  {}
  {20pt}
  {%
  \begin{tikzpicture}[remember picture,overlay]
  \node[
    anchor=west,
    rectangle,
    minimum height=4cm,
    text width=\paperwidth,
    xshift=-\the\dimexpr\oddsidemargin+1in\relax,
    outer sep=0pt,
    fill=myblueiii] (titlerect) {};
  \node[
    anchor=south west,
    xshift=2cm,
    text width=\textwidth] 
    at (titlerect.south west) {\Huge#1};
  \end{tikzpicture}%
  }
\titlespacing*{\chapter}
  {0pt}{-20pt}{60pt}

\usepackage[margin=2.8cm]{geometry}

\usepackage{titletoc}
\usepackage{xpatch}


%-------------------This for fancy ToC---------------------

\contentsmargin{0cm}
\titlecontents{chapter}[0pc]
{\addvspace{30pt}%
\begin{tikzpicture}[remember picture, overlay]%
\draw[fill=myblueii,draw=myblueii, rounded corners] (-4,-.1) rectangle (-0.5,.5);%
\pgftext[left,x=-2.7cm,y=0.2cm]{\color{white}\Large \chaptertitlename\ \thecontentslabel};%
\end{tikzpicture}\color{myblueii}\large\bfseries}%
{}
{}
{\hspace*{6pt}\titlerule\hspace*{6pt}\large\bfseries \thecontentspage
\begin{tikzpicture}[remember picture, overlay]
\draw[fill=doc!25,draw=myblueii, rounded corners=0pt] (2pt,0) rectangle (6,0.1pt);
\end{tikzpicture}}%
\titlecontents{section}[2.4pc]
{\addvspace{1pt}}
{\contentslabel[\thecontentslabel]{2.4pc}}
{}
{\hfill\small \thecontentspage}
[]
\titlecontents{subsection}[4.8pc]
{\addvspace{1.0pt}}
{\contentslabel[\thecontentslabel]{2.4pc}}
{}
{\hfill\small\thecontentspage}
[]

\makeatletter
\renewcommand{\tableofcontents}{%
\chapter*{%
\vspace*{-20\p@}%
\begin{tikzpicture}[remember picture, overlay]%
\pgftext[right,x=15cm,y=0.2cm]{\color{myblueii}\Huge \contentsname};%
\draw[fill=myblueii,draw=myblueii, rounded corners=15pt] (13,-.75) rectangle (20,1);%
\clip (13,-.75) rectangle (20,1);
\pgftext[right,x=15cm,y=0.2cm]{\color{white}\Huge \contentsname};%
\end{tikzpicture}}%
\@starttoc{toc}}
\makeatother


\begin{document}
\tableofcontents
\chapter{First}
\DoPToC
\chapter*{Κεφάλαιο χωρίς αρίθμηση}
\DoPToC
\chapter{Δεύτερο Κεφάλαιο}
\DoPToC
\section{A simple section}
\section{Another simple section}
\subsection{A simple subsection}
\subsection{Another simple subsection}
\subsubsection{A simple subsubsection}

\end{document}

我使用希腊语时的输出如下

在此处输入图片描述

我似乎不明白为什么会出现这些奇怪的符号!您知道可能出了什么问题吗?

答案1

这完美地工作:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[greek]{babel}
\usepackage{kerkis}
\usepackage{pifont}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage{epigraph}
\usepgflibrary{qrr.shapes.openrectangle}

\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{myblueii}{RGB}{63,200,244}
\definecolor{myblueiii}{RGB}{199,234,253}
\colorlet{doc}{mybluei}

\tikzset{
mynode/.style={
  rounded corners=30pt,
  shape=open rectangle,
  open rectangle fill=myblueii,
  open rectangle sides=#1,
  }
}

\titleformat{\chapter}[display]
  {\normalfont\huge\sffamily}
  {}
  {20pt}
  {%
  \begin{tikzpicture}[remember picture,overlay]
  \node[
    anchor=west,
    rectangle,
    minimum height=4cm,
    text width=\paperwidth,
    xshift=-\the\dimexpr\oddsidemargin+1in\relax,
    outer sep=0pt,
    fill=myblueiii] (titlerect) {};
  \node[
    anchor=south west,
    xshift=2cm,
    text width=\textwidth] 
    at ([yshift=5pt]titlerect.south west) {\fontsize{30}{36}\selectfont#1};
  \node[
    mynode=nw,
    anchor=south east,
    fill=myblueii,
    inner xsep=1.5cm,
    outer sep=0pt,
    font=\color{white},
    minimum height=30pt] 
    at (current page.east|-titlerect.north)
     {\bfseries\MakeUppercase{\chaptertitlename}\ \thechapter};
  \end{tikzpicture}%
  }
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\huge\sffamily}
  {}
  {20pt}
  {%
  \begin{tikzpicture}[remember picture,overlay]
  \node[
    anchor=west,
    rectangle,
    minimum height=4cm,
    text width=\paperwidth,
    xshift=-\the\dimexpr\oddsidemargin+1in\relax,
    outer sep=0pt,
    fill=myblueiii] (titlerect) {};
  \node[
    anchor=south west,
    xshift=2cm,
    text width=\textwidth] 
    at (titlerect.south west) {\Huge#1};
  \end{tikzpicture}%
  }
\titlespacing*{\chapter}
  {0pt}{-20pt}{60pt}

\usepackage[margin=2.8cm]{geometry}

\usepackage{titletoc}
\usepackage{xpatch}


%-------------------This for fancy ToC---------------------

\contentsmargin{0cm}
\titlecontents{chapter}[0pc]
{\addvspace{30pt}%
\begin{tikzpicture}[remember picture, overlay]%
\draw[fill=myblueii,draw=myblueii, rounded corners] (-4,-.1) rectangle (-0.5,.5);%
\pgftext[left,x=-2.7cm,y=0.2cm]{\color{white}\Large \chaptertitlename\ \thecontentslabel};%
\end{tikzpicture}\color{myblueii}\large\bfseries}%
{}
{}
{\hspace*{6pt}\titlerule\hspace*{6pt}\large\bfseries \thecontentspage
\begin{tikzpicture}[remember picture, overlay]
\draw[fill=doc!25,draw=myblueii, rounded corners=0pt] (2pt,0) rectangle (6,0.1pt);
\end{tikzpicture}}%
\titlecontents{section}[2.4pc]
{\addvspace{1pt}}
{\contentslabel[\thecontentslabel]{2.4pc}}
{}
{\hfill\small \thecontentspage}
[]
\titlecontents{subsection}[4.8pc]
{\addvspace{1.0pt}}
{\contentslabel[\thecontentslabel]{2.4pc}}
{}
{\hfill\small\thecontentspage}
[]

\makeatletter
\renewcommand{\tableofcontents}{%
\chapter*{%
\vspace*{-20\p@}%
\begin{tikzpicture}[remember picture, overlay]%
\pgftext[right,x=15cm,y=0.2cm]{\color{myblueii}\Huge \contentsname};%
\draw[fill=myblueii,draw=myblueii, rounded corners=15pt] (13,-.75) rectangle (20,1);%
\clip (13,-.75) rectangle (20,1);
\pgftext[right,x=15cm,y=0.2cm]{\color{white}\Huge \contentsname};%
\end{tikzpicture}}%
\@starttoc{toc}}
\makeatother


\begin{document}
\tableofcontents
\chapter{First}
\chapter*{Κεφάλαιο χωρίς αρίθμηση}
\chapter{Δεύτερο Κεφάλαιο}

\end{document}

在此处输入图片描述

相关内容