2

I'm compiling a document completely in Hebrew using XeLaTeX, but I'm having an issue creating a table: using polyglossia, the columns just don't compile...it just gives a string of words. How can I go about fixing this? Here's the MWE:

\documentclass[14pt]{memoir}
\usepackage[paperwidth=5in, paperheight=8in,top=2cm,bottom=1cm,left=1cm,right=1cm ]{geometry}
\setlength{\parindent}{0cm}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}

\newfontfamily\hebrewfont[Script=Hebrew]{Frank Ruhl Libre}

\begin{document}


 הזן אותנו  
\begin{tabular}{l l}
בטוב  & בחסד  \\
\end{tabular}
  הזן את הכל.
 \end{document}

enter image description here

6
  • Please note that if you want to use three backticks to mark block code, they must start at the very beginning of the line. Any text after the backticks will be interpreted as the language to be used for syntax highlighting. Therefore, \documentclass must not appear on the same line, but on the next line. Otherwise, it will not be shown in the output. Commented Jul 17 at 10:18
  • 1
    You've not shown what you get and also not shown the log file. So I don't know, what “it just gives a string of words” means. Note, that a tabular with as single row and without boarder lines is just a kind of ”string of words“. Maybe you are expecting that the tabular is in a line on its own. But this would only happen, if you put the tabular into another environment like table or a trivlist environment like center, flushright, flushleft. If I test your example with NotoSansHebrew and LuaLaTeX I get the IMHO expected result. Commented Jul 17 at 10:35
  • @CoenraadvanSchoor Can you make a sketch what result you expect instead? Commented Jul 17 at 11:00
  • 1
    At the top it should have the words הזן אותנו followed by a line and then the table with בטוב on one side and בחסד on the other side. Then a a line skip and then the words הזן את הכל Commented Jul 17 at 11:03
  • 1
    @CoenraadvanSchoor Please edit the question to add the additional information about the expected result into the question. Relevant information should not be hidden in comments, but always be part of the question to make it self-containing. Commented Jul 18 at 7:47

2 Answers 2

4

enter image description here

this is unrelated to Hebrew or xelatex. A tabular makes a box that is positioned inline in a paragraph just like a large letter. Similarly if you want it in a vertical display you need to place it in an environment such as center

\documentclass{article}

\begin{document}


aaa
\begin{tabular}{cc}
  123 & 456
\end{tabular}
bbb

\bigskip

aaa
\begin{center}
\begin{tabular}{cc}
  123 & 456
\end{tabular}
\end{center}
bbb


\end{document}
2
  • I also thought that perhaps it was an issue with centering, but even using \begin{centre} it didn't want to compile a table with Hebrew text properly. I just try to run it in XeLaTeX using tabularx rather and that seems to work perfectly well Commented Jul 17 at 11:55
  • 2
    @CoenraadvanSchoor tabularx is positioned exactly like tabular and would also be inline in the paragraph by default Commented Jul 17 at 12:00
2

As already told in a comment, a tabular with a single row is just something like ”string of words”. Even a tabular with more rows would be printed inline. By default such a tabular would be vertically centered to the current text line. But with the options arguments, you would be able to top or bottom align it:

\documentclass[14pt]{memoir}
\usepackage[paperwidth=5in, paperheight=8in,top=2cm,bottom=1cm,left=1cm,right=1cm ]{geometry}
\setlength{\parindent}{0cm}
\usepackage{fontspec}
\usepackage[bidi=default]{babel}
\babelprovide[main]{hebrew}
\babelfont{rm}{FreeSerif}% Sorry, I don't have Frank Ruhl Libre

\begin{document}


הזן אותנו
\begin{tabular}{l l}
בטוב  & בחסד  \\
בטוב  & בחסד  \\
\end{tabular}
הזן את הכל.

\bigskip

הזן אותנו
\begin{tabular}[t]{l l}
בטוב  & בחסד  \\
בטוב  & בחסד  \\
\end{tabular}
הזן את הכל.

\bigskip

הזן אותנו
\begin{tabular}[b]{l l}
בטוב  & בחסד  \\
בטוב  & בחסד  \\
\end{tabular}
הזן את הכל.

\end{document}

centered, top aligned and bottom aligned tabular

To move the table onto a line on it's own, you would need to put it inside an environment like table, center, flushleft, or flushright. Here an example using center:

\documentclass[14pt]{memoir}
\usepackage[paperwidth=5in, paperheight=8in,top=2cm,bottom=1cm,left=1cm,right=1cm ]{geometry}
\setlength{\parindent}{0cm}
\usepackage{fontspec}
\usepackage[bidi=default]{babel}
\babelprovide[main]{hebrew}
\babelfont{rm}{FreeSerif}% Sorry, I don't have Frank Ruhl Libre

\begin{document}


הזן אותנו
\begin{center}
\begin{tabular}{l l}
בטוב  & בחסד  \\
\end{tabular}
\end{center}
הזן את הכל.

הזן אותנו
\begin{flushleft}
\begin{tabular}{l l}
בטוב  & בחסד  \\
\end{tabular}
\end{flushleft}
הזן את הכל.

הזן אותנו
\begin{flushright}
\begin{tabular}{l l}
בטוב  & בחסד  \\
\end{tabular}
\end{flushright}
הזן את הכל.

\end{document}

hebrew tabular centered, left aligned, right aligned

You may also want to replace \begin{tabular}{l l} by \begin{tabular}{@{}ll@{}} to eliminate the column separation before the first and after the last column.

I've used babel for hebrew in this example, because font handling IMHO is better with babel but mostly because I know it much better than polyglossia.

Usually, I would suggest to use a floating tables to avoid large vertical gaps, if a longer table does not fit to the current page. Because I don't not speak Hebrew, here an example of the advantage in English:

\documentclass{article}

\usepackage{mwe}

\begin{document}

\blindtext[3]

As shown with the following table:
\begin{center}
  \begin{tabular}{rr}
    1 & first \\
    2 & second \\
    3 & third \\
    4 & fourth \\
    5 & fifth \\
    6 & sixth \\
    7 & seventh \\
    8 & eighth \\
    9 & ninth \\
    10 & tenth \\
    11 & eleventh \\
    12 & twelfth \\
    13 & thirteenth \\
    14 & fourteenth \\
    15 & fifteenth \\
  \end{tabular}
\end{center}
a longer table can result in large white gaps at the end of the page.

\lipsum[3]

But this does not happen, if you allow the table to float like shown with
table~\ref{tab:example}.%
\begin{table}[htp]
  \centering
  \begin{tabular}{rr}
    1 & first \\
    2 & second \\
    3 & third \\
    4 & fourth \\
    5 & fifth \\
    6 & sixth \\
    7 & seventh \\
    8 & eighth \\
    9 & ninth \\
    10 & tenth \\
    11 & eleventh \\
    12 & twelfth \\
    13 & thirteenth \\
    14 & fourteenth \\
    15 & fifteenth \\
  \end{tabular}
  \caption{An example table}\label{tab:example}
\end{table}

\blindtext[2]

\end{document}

three pages with one non-floating problematic tabular and a floating and therefore not problematic table

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.