2

I have this multi page word document file which is consisted of a table with two columns. the left column is an English word in front of which in the left column the Persian translation is provided. I want to include this table in my latex document without using of converters. Is there anyway?(maybe by using datatool!) So far what i could find in the web is as follow:

\documentclass{article}
\begin{filecontents*}{table.csv}
English ,فارسی
Euclidean geometry, هندسۀ اقلیدسی 
Hippocrates, بقراط
Poetica,بوطیقا  
Plato, افلاطون
Al-Hazem, ابن رشد
\end{filecontents*}
\usepackage{xepersian}
\settextfont{Tahoma}
\usepackage{csvsimple}
\begin{document}
    \csvautotabular{table.csv}
\end{document}

THe folowing image is the XeLaTex output:enter image description here

this way it's easier but I still have to copy one by one into my csv file the contents of each column. now, if that direct inclusion of a word table into latex was possible I would like to know about it. If not there are three minor questions concerning the above code:

  1. As you see the Persian and English must swap their positions. Persian in the left and English in the right position.

  2. How can I add another column to include in it an automatic produced number for each row?

  3. How can I add my data in csv file, for each line only one Persian and one English entry but make LaTeX produce a four column table so that the space used for the entire table will be reduced in half?

Sorry, I didn't know what I could do about the font.

P.S. I changed the font to Tahoma.

nima
  • 393
  • What do you mean in your point 3 exactly? I'm not sure I understand why you need 2 extra columns to reduce space. – Alenanno Dec 26 '15 at 15:13
  • I don't want to write English ,فارسی,English ,فارسی in the first row and subsequently write four words in every line to have 4 columns. In this above form[the attached image] half of the page remains empty. You can assume that I want latex to make 2 tables in each page from the data file with a consistent numbering. I mean for example if the first table finishes with 20 the next table begin with 21 and the table on the next page begin with 41 and so on. – nima Dec 26 '15 at 15:40
  • Is this what you're looking for? I mean, is the column order how you want it? – Alenanno Dec 26 '15 at 16:06
  • http://i.imgur.com/aOZu4bQ.png and about the column order yes that's it. – nima Dec 26 '15 at 16:34
  • Yes I understood the double column, but you should add more content if possible :D using the format word, word to your question. – Alenanno Dec 26 '15 at 16:36
  • Could you please copy past lines 4 to 8 in the above code for 10 times so as to have 50 entries? – nima Dec 26 '15 at 16:42
  • On second thought, you're right. I will do that. – Alenanno Dec 26 '15 at 16:43

1 Answers1

5

As it turns out, using a table that spans across pages and is also enclosed in the multicol environment is almost impossible.

I managed to do everything, except making the table span two columns in the same page. However, this last part has been implemented from this David Carlisle's answer.

By the way, I have changed the Persian font (the one I used is free), but you're free to replace yours.

Output

example image

Code

\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage{longtable,csvsimple,booktabs}
\usepackage{fontspec} % for the Latin alphabet
\usepackage{multicol}
\usepackage{array}
\usepackage{xepersian}
\settextfont{Nazanin} % font for Persian
\setmainfont[Script=Arabic]{Times New Roman} % Latin Alphabet

\begin{filecontents*}{xtable.csv}
English, Persian
Euclidean geometry, هندسۀ اقلیدسی 
Hippocrates, بقراط
Poetica,بوطیقا  
Plato, افلاطون
Al-Hazem, ابن رشد
...
more content here
\end{filecontents*}

\newsavebox\ltmcbox

\begin{document}
\begin{multicols}{2}
\setbox\ltmcbox\vbox{
\makeatletter\col@number\@ne
\csvreader[
    longtable=rl>{\beginR}l,
    table head= 
    & \bfseries English & \bfseries فارسی \\
    \midrule\endhead
    \bottomrule\endfoot,
    late after line=\\]%
    {xtable.csv}{English=\English, Persian=\Persian}%
    {\thecsvrow & \English & \Persian}
\unskip
\unpenalty
\unpenalty}

\unvbox\ltmcbox
\end{multicols}
\end{document}
Alenanno
  • 37,338