TransWikia.com

Tables with Hebrew text using babel

TeX - LaTeX Asked by Tom Ron on December 8, 2020

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]
 hlinehline
 1 & 6   
 hline
end{tabular}
end{center}



end{document}

2 Answers

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]
 hlinehline
 1 & 6   
 hline
end{tabular}
end{center}



end{document}

Correct answer by Elad Den on December 8, 2020

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]
 hlinehline
 1 & 6   
 hline
end{tabular}
end{center}

end{document}

Libertinus sample

Answered by Davislor on December 8, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP