我正在用阿拉伯语写一本书,我想获得一本包含我文档中使用的阿拉伯语和英语单词的词典,并且希望词典中的条目采用两种不同的顺序,即阿拉伯字母顺序和英语字母顺序。我的想法是使用可生成多个索引的 multiind 包来生成两个 idx 文件dic_english.idx
和dic_arabic.idx
。
命令
\index{dic_english}{Random@\idxsechead{Random\hfill arabic_word}|idxnopage}
和
\index{dic_arabic}{arabic_word@\idxsechead{Random\hfill arabic_word}|idxnopage}
将生成这两个文件,相同的文件,第一个文件按英文顺序排列,第二个文件按阿拉伯文顺序排列。我的问题是 twocolumn 命令将在两个文件的右侧生成列(第一列在右侧,第二列在左侧)...但我想获取按英文顺序排列的索引,第一列在左侧,第二列在右侧。有人对此有什么想法吗?...确切地说,我如何才能同时获取从右到左的索引和从左到右的索引?
谢谢,Faouzi
答案1
可以使用flowfram
包,但它相当复杂。下面的示例从标题页和前两章的单列布局开始,然后切换到第三章的 LR 双列布局,接着是第四章的 RL 双列布局,然后切换回单列布局以显示最后两章。
\documentclass{book}
\usepackage{lipsum}
\usepackage{calc}
\usepackage{etoolbox}
\usepackage{flowfram}
\newlength\chapheadheight
\setlength\chapheadheight{0.25\textheight}
\newlength\chapflowheight
\setlength\chapflowheight{\textheight-\chapheadheight}
\newdynamicframe[none]{\textwidth}{\chapheadheight}{0pt}{\chapflowheight}[chaphead]
\dfchaphead*{chaphead}
\newflowframe[none]{\textwidth}{\chapflowheight}{0pt}{0pt}[chapmain]
\onecolumn
\setflowframe{2}{label=main}
\twocolumninarea[none]{\textwidth}{\chapflowheight}{0pt}{0pt}
\setflowframe{3}{label=chap-english-left}
\setflowframe{4}{label=chap-english-right}
\twocolumn[none]
\setflowframe{5}{label=english-left}
\setflowframe{6}{label=english-right}
\lefttorightcolumnsfalse
\twocolumninarea[none]{\textwidth}{\chapflowheight}{0pt}{0pt}
\setflowframe{7}{label=chap-arabic-right}
\setflowframe{8}{label=chap-arabic-left}
\twocolumn[none]
\setflowframe{9}{label={arabic-right}}
\setflowframe{10}{label={arabic-left}}
\newcommand*{\prechaphook}{%
\dynamicswitchonnextoddonly*{chaphead}%
\flowswitchonnextoddonly*{chapmain}%
\flowswitchoffnextoddonly*{main}%
}
\preto\chapter{\prechaphook}
\newcommand*{\switchonLRtwocolumns}{%
\flowswitchonnext*{english-left,english-right}%
\flowswitchoffnext*{chapmain,main}%
\dynamicswitchonnextoddonly*{chaphead}%
\flowswitchonnextoddonly*{chap-english-left,chap-english-right}%
\flowswitchoffnextoddonly*{english-left,english-right}%
\cleardoublepage
\renewcommand*{\prechaphook}{}%
}
\newcommand*{\switchonRLtwocolumns}{%
\flowswitchonnext*{arabic-left,arabic-right}%
\flowswitchoffnext*{english-left,english-right}%
\dynamicswitchonnextoddonly*{chaphead}%
\flowswitchonnextoddonly*{chap-arabic-left,chap-arabic-right}%
\flowswitchoffnextoddonly*{arabic-left,arabic-right}%
\cleardoublepage
}
\newcommand*{\switchononecolumn}{%
\flowswitchoffnext*{arabic-left,arabic-right}%
\flowswitchonnext*{main}%
\dynamicswitchonnextoddonly*{chaphead}%
\flowswitchonnextoddonly*{chapmain}%
\flowswitchoffnextoddonly*{main}%
\clearpage
\renewcommand*{\prechaphook}{%
\renewcommand*{\prechaphook}{%
\dynamicswitchonnextoddonly*{chaphead}%
\flowswitchonnextoddonly*{chapmain}%
\flowswitchoffnextoddonly*{main}%
}%
}%
}
\title{Sample Title}
\author{Sample Author}
\begin{document}
\maketitle
\chapter{Sample}
\lipsum
\chapter{Another Sample}
\lipsum[1-5]
\switchonLRtwocolumns
\chapter{LR}
\lipsum
\switchonRLtwocolumns
\chapter{RL}
\lipsum
\switchononecolumn
\chapter{One Column Again}
\lipsum
\chapter{And Again}
\lipsum
\end{document}
假设书是双面的。\chapheadheight
如果章节标题超出分配的空间,则可能需要设置更大的值。您应该能够\chapter{LR}
用\printindex{dico-english}
命令替换并\chapter{RL}
用\printindex{dico-arabic}{\LR{Arabic entries...}}
命令替换。(我没有安装编译示例所需的字体。)
编辑:
如果您想要使用polyglossia
,flowfram
您必须确保polyglossia
先加载,因为它们都会修改输出例程。
答案2
\documentclass[14pt,a4paper]{extbook}%{article}%
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{etoolbox}
\usepackage{multicol}
\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}
\usepackage{boxedminipage}
\usepackage{slashbox}
\usepackage{enumitem}
\usepackage{minitoc}
\usepackage{rotating}
\usepackage{fmultico}
\setlength{\columnseprule}{0.1pt}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{pdflscape}
\usepackage{array}
\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, AutoFakeSlant=-0.02]{Amiri}
\setsansfont[Script=Arabic,Scale=1.5]{Amiri}
\usepackage{multind}
\makeindex{dico-english}
\makeindex{dico-arabic}
%%% OBTAIN INDEX WITHOUT NUMBERS OF PAGE %%%%%
\newcommand{\idxnopage}[1]{{}}
\providecommand{\gobble}[1]{{}}
\newcommand{\idxsechead}[1]{#1\gobble}
\begin{document}
\index{dico-english}{c@\idxsechead{أ\hfill c}|idxnopage}
\index{dico-english}{a@\idxsechead{ب\hfill a}|idxnopage}
\index{dico-english}{b@\idxsechead{ت\hfill b}|idxnopage}
\index{dico-arabic}{أ@\idxsechead{أ\hfill c}|idxnopage}
\index{dico-arabic}{ب@\idxsechead{ب\hfill a}|idxnopage}
\index{dico-arabic}{ت@\idxsechead{ت\hfill b}|idxnopage}
\printindex{dico-english}{\LR{English entries...}}
\printindex{dico-arabic}{\LR{Arabic entries...}}
\end{document}
答案3
我可以为您提供这个解决方案。只要您在索引中没有可点击版本的索引页码,我们就可以单独创建英文索引。我创建了一个仅包含文档前言的新文件,以保留原始文档的设计和布局。
关键变化在于交换只能在前言中设置的\setmainlanguage
和命令。然后裁剪新文件()并将其重新包含到主文件()。我通常使用和来获取包含的 PDF 文件的页数,但 XeLaTeX 不支持这些 pdfTeX 原语。因此,我使用了它来完成这项任务,并且它运行顺利。\setotherlanguage
mal-english.pdf
mal-arabic.tex
\pdfximage
\pdflastximagepages
\XeTeXpdfpagecount
我尝试将更多术语添加到您的词典中,如果我拼错了或错误处理了一些阿拉伯语术语,请原谅。我认为您还有另一个问题需要解决,因为据makeindex
我所知,无法直接对复杂语言进行排序。此外,xindy
它可以处理复杂语言,但它也不支持阿拉伯语,至少 TeX Live(2013)的官方发行版中没有提供阿拉伯语。
我还编写了一个名为的新命令\aeindex
,它通过交换两个参数将术语保存到两个索引中。它应该可以为您节省一些时间。
我运行这些命令来获取一个 PDF 文件中的英语-阿拉伯语和阿拉伯语-英语索引。请记住,makeindex dico-arabic.idx
必须用更好的工具替换。您可能已经知道您需要哪种工具(也许是来自 ArabTeX、ArabXeTeX 或 ConTeXt 的工具?)。也可能是这种情况makeindex dico-english.idx
,因为英语术语可能会出现多次,您需要根据阿拉伯语排序规则进行排序。
xelatex mal-arabic.tex
makeindex dico-arabic.idx
makeindex dico-english.idx
xelatex mal-english.tex
pdfcrop --hires mal-english.pdf
xelatex mal-arabic.tex
第一个命令将索引条目存储到两个文件中,然后这两个文件经过处理makeindex
,然后我们得到英文索引作为独立的 PDF 文件,该文件被裁剪并包含回主 TeX 文件。
我附上了三个 TeX 文件(两个文档的序言、主要的阿拉伯语文件和英文索引)和两页排版的预览。
文件mal-arabic-preamble.tex
:
%! I am mal-arabic-preamble.tex...
%! Don't run me directly...
%
\documentclass[14pt,a4paper]{extbook}
%{article}%
%\usepackage{titlesec}
%\usepackage{titletoc}
%\usepackage{etoolbox}
%\usepackage{multicol}
%\usepackage{amsmath,amssymb}
%\usepackage[most]{tcolorbox}
%\usepackage{boxedminipage}
%\usepackage{slashbox}
%\usepackage{enumitem}
%\usepackage{minitoc}
%\usepackage{rotating}
%\usepackage{fmultico} \setlength{\columnseprule}{0.1pt}
\usepackage{fancyhdr} \pagestyle{fancy}
\headheight=17pt
%\usepackage{pdflscape}
%\usepackage{array}
\usepackage{multind}
\makeindex{dico-english}
\makeindex{dico-arabic}
%%% OBTAIN INDEX WITHOUT NUMBERS OF PAGE %%%%%
\newcommand{\idxnopage}[1]{{}} % This line deletes index page number.
\providecommand{\gobble}[1]{{}} % This line deletes a comma.
\newcommand{\idxsechead}[1]{#1\gobble}
\usepackage{polyglossia}
\def\RLarabic#1{\selectlanguage{arabic}\RL{#1}\selectlanguage{english}}
\def\aeindex#1#2{%
\index{dico-english}{#2@\string\idxsechead{#2\hfill\RLarabic{#1}}|idxnopage}%
\index{dico-arabic}{#1@\string\idxsechead{#1\hfill\LR{#2}}|idxnopage}%
}% End of \aeindex...
文件mal-arabic.tex
:
%! xelatex mal-arabic.tex
\input{mal-arabic-preamble.tex}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, AutoFakeSlant=-0.02]{Amiri}
\setsansfont[Script=Arabic,Scale=1.5]{Amiri}%1.0
\begin{document}
% Arabic--English index...
\aeindex{أ}{c}%
\aeindex{ب}{a}%
\aeindex{ت}{b}%
% http://www.lexilogos.com/english/arabic_dictionary.htm
\aeindex{ذاتَ اليَمِين}{to the right}
\aeindex{بُرتُقال ( نب )}{orange}
\aeindex{أُوتُومُوبِيل}{car}
\aeindex{تَشرِيعِيّ}{house}
\aeindex{مَحضَرُ ضَبطِ سَير}{ticket}
\aeindex{كَوكَب سَيّار}{planet}
\aeindex{مُستَحكَم}{serious}
% An old approach
%\printindex{dico-english}{\LR{English entries...}}
% One experiment...
\def\englishname{\LR{English entries...}}
\markright {\uppercase {\englishname}}
\addcontentsline {toc}{section}{\englishname}
\def\malname{mal-english-crop.pdf}%
\newcount\malcounter \malcounter=0%
\loop
\newpage
\advance\malcounter by 1
\hfill\includegraphics[page={\the\malcounter}]{\malname}% or
% A manual cropping in case pdfcrop doesn't work...
% viewport=2.35cm 4.5cm 17.4cm 25.3cm, clip
\ifnum\malcounter<\XeTeXpdfpagecount{\malname}\repeat % Number of pages of mal-english.pdf file...
\printindex{dico-arabic}{\LR{Arabic entries...}}
\end{document}
这是mal-english.tex
文件:
%! xelatex mal-english.tex
\input{mal-arabic-preamble.tex}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\setmainlanguage{english}
\setotherlanguage[numerals=maghrib]{arabic}
\newfontfamily\arabicfont[Script=Arabic, AutoFakeSlant=-0.02]{Amiri}
\setsansfont[Script=Arabic,Scale=1.5]{Amiri} % 1.5
\begin{document}
\printindex{dico-english}{\LR{English entries...}}
\end{document}
这是该文件的预览mal-arabic.pdf
:
答案4
The preamble file Preamble.tex %%%
\documentclass[14pt,a4paper]{extbook}
\usepackage{fancyhdr} \pagestyle{fancy}
\headheight=17pt
\usepackage{multind}
\makeindex{EN}
\makeindex{AR}
%%% OBTAIN INDEX WITHOUT NUMBERS OF PAGE %%%%%
\newcommand{\idxnopage}[1]{{}} % This line deletes index page number.
\providecommand{\gobble}[1]{{}} % This line deletes a comma.
\newcommand{\idxsechead}[1]{#1\gobble}
\usepackage{polyglossia}
\def\RLarabic#1{\selectlanguage{arabic}\RL{#1}\selectlanguage{english}}
\def\aeindex#1#2{%
\index{EN}{#2@\string\idxsechead{#2\hfill\RLarabic{#1}}|idxnopage}%
\index{AR}{#1@\string\idxsechead{#1\hfill\LR{#2}}|idxnopage}%
}% End of \aeindex...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
THE FILE
\input{Preamble.tex}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, AutoFakeSlant=-0.02]{Amiri}
\setsansfont[Script=Arabic,Scale=1.5]{Amiri}%1.0
\begin{document}
\aeindex{أ}{c}%
\aeindex{ب}{a}%
\aeindex{ت}{b}%
\aeindex{ذاتَ اليَمِين}{to the right}
\aeindex{بُرتُقال ( نب )}{orange}
\aeindex{أُوتُومُوبِيل}{car}
\aeindex{تَشرِيعِيّ}{house}
\aeindex{مَحضَرُ ضَبطِ سَير}{ticket}
\aeindex{كَوكَب سَيّار}{planet}
\aeindex{مُستَحكَم}{serious}
\aeindex{عداد}{counter}
\RTLdblcol
\printindex{AR}{\LR{Arabic entries...}}
\LTRdblcol
\printindex{EN}{\LR{English entries...}}
\end{document}