我正在尝试使用“XeLaTeX”通过“TeXLive”编译“*.tex”文件(其中包含一些波斯语单词)。
例如,“Sample.tex”文件包含以下带有波斯语单词的脚本。它运行正确并显示结果:
\documentclass{article}
\usepackage{xepersian}
\settextfont{XB Roya}
\begin{document}
سلام!
\end{document}
但是,当我在“template.tex”文件中使用“xpersian”包时,会出现一些错误。问题是,我的模板文件是一个日记模板,基于英语(Springer LaTeX 宏包)。如果我在模板文件中添加“xpersian”包,我必须更改其他预定义包。还有其他方法可以解决这个问题吗?
答案1
当您使用该xepersian
包时,它会自动加载bidi
适用于RTL
{从右到左}环境的包。因此您必须更改一些代码。对于english
文本或其他英文代码,您可以从latin
环境中使用,如下所示:
\begin{latin}
content...
\end{latin}
对于persian
文本(英文文本之间),您可以使用波斯语环境,如下所示:
\begin{persian}
محتوا
\end{persian}
这将是你的输出:
要改变标题的方向,您应该使用caption
包中的以下结构:
\usepackage{caption}
\captionsetup{justification=raggedright,singlelinecheck=false}
这将是你的输出:
这将是您的复合 thebibliography
输出:
但是要更改标题,您需要更改 svjour3.cls 文件的第 240 行至 249 行,如下所示:
\def\ps@headings{%
\let\@oddfoot\@empty\let\@evenfoot\@empty
\def\@evenhead{\small\rlap{
\csname runheadhook\endcsname}\lr{\leftmark}
\hfil\lr{\thepage}\unskip}%
\def\@oddhead{\small\csname runheadhook\endcsname
\ignorespaces\llap{\lr{\thepage}}\hfil\lr{\rightmark}}
\let\@mkboth\@gobbletwo
\let\sectionmark\@gobble
\let\subsectionmark\@gobble
}
或者将下面的代码放在 xepersian 包后的序言中:
\makeatletter
\def\ps@headings{%
\let\@oddfoot\@empty\let\@evenfoot\@empty
\def\@evenhead{\small\rlap{
\csname runheadhook\endcsname}\lr{\leftmark}
\hfil\lr{\thepage}\unskip}%
\def\@oddhead{\small\csname runheadhook\endcsname
\ignorespaces\llap{\lr{\thepage}}\hfil\lr{\rightmark}}
\let\@mkboth\@gobbletwo
\let\sectionmark\@gobble
\let\subsectionmark\@gobble
}
\makeatother
\pagestyle{headings}
\begin{filecontents*}{example.eps}
gsave
newpath
20 20 moveto
20 220 lineto
220 220 lineto
220 20 lineto
closepath
2 setlinewidth
gsave
.4 setgray fill
grestore
stroke
grestore
\end{filecontents*}
\RequirePackage{fix-cm}
\documentclass[smallextended]{svjour3} %
\smartqed
\usepackage{graphicx}
\usepackage{caption}
\captionsetup{justification=raggedright,singlelinecheck=false}
\usepackage[%
inlinemathdigits=persian,%
displaymathdigits=persian%
]{xepersian}
\settextfont[Scale=1.1]{XB Niloofar}
\settextdigitfont[Scale=1.1]{Yas}
\setmathdigitfont[Scale=.9]{PGaramond}
%\setlatintextfont[Scale=1.2]{Times New Roman}
\makeatletter
\def\ps@headings{%
\let\@oddfoot\@empty\let\@evenfoot\@empty
\def\@evenhead{\small\rlap{
\csname runheadhook\endcsname}\lr{\leftmark}
\hfil\lr{\thepage}\unskip}%
\def\@oddhead{\small\csname runheadhook\endcsname
\ignorespaces\llap{\lr{\thepage}}\hfil\lr{\rightmark}}
\let\@mkboth\@gobbletwo
\let\sectionmark\@gobble
\let\subsectionmark\@gobble
}
\makeatother
\pagestyle{headings}
\begin{document}
\latin
\title{\lr{Insert your title here}
}
\subtitle{Do you have a subtitle?\\ If so, write it here}
\author{\lr{First Author \and
Second Author }%etc.
}
\institute{F. Author \at
first address \\
Tel.: +123-45-678910\\
Fax: +123-45-678910\\
\email{[email protected]} % \\
% \emph{Present address:} of F. Author % if needed
\and
S. Author \at
second address
}
\date{Received: date / Accepted: date}
% The correct dates will be entered by the editor
\maketitle
\begin{abstract}
Insert your abstract here. Include keywords, PACS and mathematical
subject classification numbers as needed.
\keywords{First keyword \and Second keyword \and More}
% \PACS{PACS code1 \and PACS code2 \and more}
% \subclass{MSC code1 \and MSC code2 \and more}
\end{abstract}
\section{Introduction}
\label{intro}
Your text comes here. Separate text sections with
\section{Section title}
\label{sec:1}
Text with citations \cite{RefB} and \cite{RefJ}.
\subsection{Subsection title}
\label{sec:2}
as required. Don't forget to give each section
and subsection a unique label (see Sect.~\ref{sec:1}).
\paragraph{Paragraph headings} Use paragraph headings as needed.
\begin{equation}
a^2+b^2=c^2
\end{equation}
% For one-column wide figures use
\begin{figure}
% Use the relevant command to insert your figure file.
% For example, with the graphicx package use
\includegraphics{example.eps}
% figure caption is below the figure
\setLTR{\caption{Please write your figure caption here}}
\label{fig:1} % Give a unique label
\end{figure}
%
% For two-column wide figures use
\begin{figure*}
% Use the relevant command to insert your figure file.
% For example, with the graphicx package use
\includegraphics[width=0.75\textwidth]{example.eps}
% figure caption is below the figure
\caption{Please write your figure caption here}
\label{fig:2} % Give a unique label
\end{figure*}
%
% For tables use
\begin{table}
% table caption is above the table
\caption{Please write your table caption here}
\label{tab:1} % Give a unique label
% For LaTeX tables use
\begin{tabular}{lll}
\hline\noalign{\smallskip}
first & second & third \\
\noalign{\smallskip}\hline\noalign{\smallskip}
number & number & number \\
number & number & number \\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
\begin{persian}\noindent
سلام بر شما
من الان میتوانم لابلای متن لاتین، متن فارسی ایجاد کنم. این خواستهی من به کمک بستهی زیپرشین و همت دکتر وفا خلیقی قابل انجام است.
\end{persian}
\begin{thebibliography}{99}
\linespread{1.5}
\bibitem{RefJ}
Author, Article title, Journal, Volume, page numbers (year)
\bibitem{RefB}
Author, Book title, page numbers. Publisher, place (year)
{\persian
\bibitem{46}
آذرپناه, فریبرز.: نخستین درس در توپولوژی, انتشارات دانشگاه شهید چمران اهواز, 1382.
\bibitem{47}
دی, کارالامبوس., پرانتز, علی., بورکین شاو, اون.: اصول آنالیز حقیقی, 1389.
\bibitem{45}
کوچکپور, عبدعلی., نامداری, مهرداد.: مقدمهای بر نظریهی اصولی مجموعهها, انتشارات دانشگاه شهید چمران اهواز, 1394.
}
\end{thebibliography}
\end{document}
[1]: https://i.stack.imgur.com/oc674.jpg
[2]: https://i.stack.imgur.com/yhzJA.jpg
祝你好运。