1

I have a document in Hebrew which I render using babel and now I want to add a table which includes text in Hebrew. While the entire document renders ok, in this case the text is rendered in the wrong direction (left to right instead of right to left).

I would appreciate any help (I'm also flexible moving from babel as long the new package is supported by Overleaf).

\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage[english,hebrew]{babel}
\selectlanguage{hebrew}
\usepackage[top=2cm,bottom=2cm,left=2.5cm,right=2cm]{geometry}


\begin{document}

\begin{center}
 \begin{tabular}{||c |c||} 
 \hline
 טור 1 & טור 2 \\[0.5ex]
 \hline\hline
 1 & 6  \\ 
 \hline
\end{tabular}
\end{center}



\end{document}
1
  • Did my answer solve the problem? If it did I'd thank you if you accept it. If not, please let us know so we can try and find other solutions.
    – Elad Den
    Sep 12 '20 at 8:54
1

babel does not force the bidi on a tabular. You need to do that yourself. What I do is use array package to define a new column type to support hebrew:

\newcolumntype{C}{>{\beginR}c<{\endR}}

And a full MWE:

\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage[english,hebrew]{babel}
\selectlanguage{hebrew}
\usepackage[top=2cm,bottom=2cm,left=2.5cm,right=2cm]{geometry}
\usepackage{array}

\newcolumntype{C}{>{\beginR}c<{\endR}}

\begin{document}

\begin{center}
 \begin{tabular}{||C |C||} 
 \hline
 טור 1 & טור 2 \\[0.5ex]
 \hline\hline
 1 & 6  \\ 
 \hline
\end{tabular}
\end{center}



\end{document}
1
  • Note however this only reverses the cell, not the table. The first column is still shown at the left. The only way to get the correct order is with luatex. Nov 6 '20 at 13:31
0

As of 2020, babel supports the tabular option to do this for you. It requires LuaTeX and does not work perfectly.

\documentclass{article}
\usepackage[english, bidi=basic, layout=sectioning.tabular]{babel}
\usepackage{fontspec}
\babelprovide[import,main]{hebrew}
\usepackage[top=2cm,bottom=2cm,left=2.5cm,right=2cm]{geometry}

\babelfont{rm}
          [Ligatures={Common,Discretionary,TeX}]{Libertinus Serif} % Or any font that supports Hebrew.
\babelfont{sf}
          [Ligatures={Common,Discretionary,TeX}]{Libertinus Sans}
\babelfont{tt}
          [Ligatures=TeX]{Libertinus Mono}

\begin{document}

\begin{center}

 \begin{tabular}{||c |c||} 
 \hline
 טור 1 & טור 2 \\[0.5ex]
 \hline\hline
 1 & 6  \\ 
 \hline
\end{tabular}
\end{center}

\end{document}

Libertinus sample

3
  • “does not work perfectly”. Please, report any issue you find. I'm aware it's not perfect, but I need specific cases where it doesn't work. Well, at least this example seems to work 🙂. Nov 6 '20 at 6:48
  • @JavierBezos It looks to me as if the first row is typeset LTR, when it should be RTL.
    – Davislor
    Nov 6 '20 at 8:02
  • 1
    It's the browser, which is mixing RTL and LTR 🙂. If I copypaste the code in an RTL editor, it's shown correctly. Nov 6 '20 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.