5

This question is concerned about writing a non-english document in LaTeX.

I compile my Hebrew document with pdfLaTeX. I know, XeLaTex or LuaLaTeX with the polyglossia package are Unicode engines, and are the recommended engines for non-Latin scripts. But I decided to stick to pdfLaTeX for its other useful features.

As I learned here, one can declare the Hebrew glyphs in the preamble, thus defining behavior for Unicode characters:

\documentclass{article}
\usepackage[T1]{fontenc} % Specifies which font encoding LATEX should
                         % use, (8-bit encoding (T1))
\usepackage[utf8]{inputenc} % Translate various standard and other
                            % input encodings into a ‘LaTeX internal language‘
\usepackage{culmus} % Hebrew fonts from the Culmus project
\usepackage[main=english, hebrew]{babel} % Multilingual support,
                                         % typographical (and other) rules
\pdfmapfile{=culmus.map} % pdflatex now reads the file culmus.map,
                        %  which tells pdflatex how to get the font into the output file

%% Declarations %% \DeclareUnicodeCharacter{05D0}{\hebalef} \DeclareUnicodeCharacter{05D1}{\hebbet} \DeclareUnicodeCharacter{05D2}{\hebgimel} % and so on, up to \DeclareUnicodeCharacter{05EA}{\hebtav} %% Document %% \begin{document} כיתוב בעברית \end{document}

Now comes my question: I want to write down these 27 declarations in a separate file (probably a .sty or a .def file?) so as to make my preamble cleaner.

What is the correct way to do that?

What command should I pass to my latexmkrc file so that pdfLaTeX searches there for the declarations list?

Does the inputenx package can do this for me? If yes, then what argument should I pass to \usepackage[...]{inputenx}?

Any suggestion or help would be much appreciated.

tush
  • 1,115
  • Out of curiosity, which features of PDFTeX did you need? – Davislor Mar 16 '21 at 02:27
  • A good approach is to stick all the Hebrew set-up in a .sty file. – Davislor Mar 16 '21 at 02:28
  • 2
    if you create such a list the best is to call it lheenc.dfu. Then it will be loaded automatically. If it is complete you could upload to ctan. Put it in a texmf tree e.g. in tex/latex/hebrew-unicode. – Ulrike Fischer Mar 16 '21 at 08:52
  • @ Davisor, XeTeX includes some of the pdfTeX primitives, but not currently all of them. – tush Mar 16 '21 at 09:08
  • @Ulrike Fischer sorry, could you elaborate a bit about the path for the file? If I compile my project in overleaf, where should the file be saved inside my project? What command should be passed to a latexmkrc file? – tush Mar 16 '21 at 16:26
  • in overleaf I would probably simply put it in the main folder. Or where ever overleaf find files. – Ulrike Fischer Mar 16 '21 at 16:48
  • I tried that. Doesn't work. Then I tried to use a latexmkrc file with $ENV{'DFUINPUTS'}='./dfu//:' . $ENV{'DFUINPUTS'}; as its content. Still doesn't work. – tush Mar 16 '21 at 16:55

1 Answers1

2

I think that a possible solution is to write the declarations in an external .sty file, and call it from the preamble.

% file hebrewDeclarations.sty
%% Declarations %%
\DeclareUnicodeCharacter{05D0}{\hebalef}
\DeclareUnicodeCharacter{05D1}{\hebbet}
\DeclareUnicodeCharacter{05D2}{\hebgimel}
% and so on, up to 
\DeclareUnicodeCharacter{05EA}{\hebtav}

Whereas the tex file is:

\documentclass{article}
\usepackage[T1]{fontenc} % Specifies which font encoding LATEX should
                         % use, (8-bit encoding (T1))
\usepackage[utf8]{inputenc} % Translate various standard and other
                            % input encodings into a ‘LaTeX internal language‘
\usepackage[main=english, hebrew]{babel} % Multilingual support,
                                         % typographical (and other) rules
\usepackage{hebrewDeclarations} % Reference to the external sty file

%% Document %% \begin{document} כיתוב בעברית \end{document}

tush
  • 1,115