背景
我在编码示例中使用该包来处理阿拉伯语文本。但是,在我的主文件中,每次我执行此操作时,包都会处理中的arabtex
代码(例如<!DOCTYPE html>
)。\section{}
arabtex
我试图复制该问题,但如果我不使用特殊的文档类,似乎就不会遇到这个问题。
问题
有没有办法告诉arabtex
包不要处理章节标题中的代码?
如下面的 MWE 所示,代码写为,\< h_dh al-l.gT al-rbyT>
并且由于某种原因它似乎会产生影响\section{Document type <!DOCTYPE html>}
。
期望输出
以防止/逃避里面的代码\section{}
受到其他包的影响。
最小工作示例(MWE)
\documentclass[cmyk]{article}
\usepackage[OT6,LAE,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{listings}
%: ---------------------------------------------------------------------------
%: Arabic font support - https://en.wikipedia.org/wiki/ArabTeX
%: ---------------------------------------------------------------------------
\makeatletter
\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
\DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
\DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl}
\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}
\makeatother
\usepackage{arabtex}
% ----------------------------------------------------------------------
% Definition of colors
% ----------------------------------------------------------------------
\definecolor{editorGray}{gray}{0}
\definecolor{editorPurple}{cmyk}{0.75, 1, 0, 0}
\definecolor{editorDarkOrange}{cmyk}{0, 0.8, 0.9, 0}
\definecolor{editorBlue}{cmyk}{1, 0.35, 0, 0}
\definecolor{editorPink}{cmyk}{0, 1, 0, 0}
% ----------------------------------------------------------------------
% HTML
% ----------------------------------------------------------------------
\lstdefinelanguage{HTML5}{
language=html,
sensitive=true,
tagstyle=\color{editorBlue},
markfirstintag=true,
alsoletter={!-'}
}
% ----------------------------------------------------------------------
% Code style
% ----------------------------------------------------------------------
\lstset{%
% General design
inputencoding=utf8,
backgroundcolor=\color{white},
basicstyle=\ttfamily\upshape\lst@ifdisplaystyle\tiny\fi,
frame=l,
float,
belowskip=0pt,
escapeinside=`',
% Line numbers
framesep=5pt,
xleftmargin={14pt},
numbers=left,
stepnumber=1,
firstnumber=1,
numberfirstline=true,
numberstyle=\color{black},
% Code design
identifierstyle=\color{editorDarkOrange},
keywordstyle=[1]\color{editorPink},
keywordstyle=[7]\color{black},
commentstyle=\color{editorGray},
stringstyle=\color{editorPurple},
% Code
language=HTML5,
alsodigit={.:},
tabsize=2,
showtabs=false,
showspaces=false,
showstringspaces=false,
keepspaces=true,
extendedchars=true,
breaklines=false
}
% ----------------------------------------------------------------------
% Color style for < and > for code examples
% ----------------------------------------------------------------------
\gdef\lst@BeginTag{%
\lst@DelimOpen
\lst@ifextags\else
{\let\lst@ifkeywords\iftrue
\lst@ifmarkfirstintag\lst@firstintagtrue\fi\color{editorBlue}}}
\gdef\lst@EndTag{\lst@DelimClose\lst@ifextags\else\color{editorBlue}}
\begin{document}
\section{Dokumenttyp <!DOCTYPE>}
\begin{lstlisting}[language=HTML5,numbers=left,firstnumber=1]
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="utf-8">
<title>`\color{editorDarkOrange}HTML and CSS'</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<main>
<section>
<h1>`\color{editorDarkOrange}Hantering av olika språk'</h1>
<p>`\color{editorDarkOrange}This is English, but \< h_dh al-l.gT al-`rbyT>'</p>
</section>
</main>
</body>
</html>
\end{lstlisting}
\end{document}