1

I am using the cjhebrew package to write Jewish dates. If for example, I want to write the 17th of the month of Iyyar, it would be written something like j"g Iyyar, with a double quote between the two parts of the number, or a single quote after a one part number, e.g. f', or rather `f. (The quote(s) would angle in the open quote direction.)

Regarding the j"g and f', Jewish dates are written with Hebrew letters instead of digits.

Aside from typesetting the month, the quote, and the date in that order (or even part of the date, the month, the quotes, and the rest of the date as in the second example), is there a simpler way to do it as a single command? Or is there a way to include a backtick as a Hebrew character?

The following MWE displays the first of the month of Iyyar on a line, followed by the 16th of the month of Iyyar. It seems very roundabout to me.

\documentclass{standalone}
\usepackage{cjhebrew}
\begin{document}
\cjRL{'yyr} `\cjRL{'}\\
\cjRL{z 'yyr}``\cjRL{.t}
\end{document}
2

You can write a simple macro with three arguments, i.e., the part before the ticks, the ticks, and the part after the ticks. This is already slightly easier than typing the separate \cjRL commands, and no additional packages required.

Alternatively, you can use a string manipulation package such as xstring to provide one argument and split it inside a macro.

MWE for both options:

\documentclass{article}
\usepackage{cjhebrew}
\usepackage{xstring}

% simple macro
\newcommand{\hebrewdate}[3]{%
\cjRL{#1}#2\cjRL{#3}%
}    

% xstring macro
\newcommand{\hbdate}[1]{%
\StrCount{#1}{`}[\nrticks]%
\StrPosition[1]{#1}{`}[\firsttick]%
\StrPosition[\nrticks]{#1}{`}[\lasttick]%
\StrBefore[1]{#1}{`}[\firstpart]%
\StrMid{#1}{\firsttick}{\lasttick}[\ticks]%
\StrBehind[\nrticks]{#1}{`}[\secondpart]%
\cjRL{\firstpart}\ticks\cjRL{\secondpart}%
}

\begin{document}
\noindent1st of Iyyar: \cjRL{'yyr} `\cjRL{'}\\
16th of Iyyar: \cjRL{z 'yyr}``\cjRL{.t}\\
simple macro 1st: \hebrewdate{'yyr}{ `}{'}\\
simple macro 16th: \hebrewdate{z 'yyr}{``}{.t}\\
xstring macro 1st: \hbdate{ 'yyr`'}\\
xstring macro 16th: \hbdate{z 'yyr``.t}
\end{document}

Result:

enter image description here

Issue: when you want a space next to the quote, you have to write it in front (see 5th example).


Edit As commented by @SSL, the quote characters can be improved.

Below two adjustments to the MWE, one to use position-altered tiny math quotes in case pdflatex is preferred and one with unicode characters for use with xelatex and the Linux Libertine O font.

A disadvantage of the pdflatex version is that it still looks a bit odd and it probably does not work well outside of normal text.

A disadvantage of the xelatex version is that the font may not be available (and switching engines is tricky in general). Also: you have to type the geresh and gershayim, although you could alter the macro to take an ascii equivalent as input and replace it with the appropriate Hebrew accent.

New MWE:

\documentclass{article}
\usepackage{fontspec}                           % xelatex only
\setmainfont[Ligatures=TeX]{Linux Libertine O}  % xelatex only
\usepackage{cjhebrew}
\usepackage{xstring}

% pdflatex xstring macro
\newcommand{\hbdate}[1]{%
\StrCount{#1}{`}[\nrticks]%
\StrPosition[1]{#1}{`}[\firsttick]%
\StrPosition[\nrticks]{#1}{`}[\lasttick]%
\StrBefore[1]{#1}{`}[\firstpart]%
\StrMid{#1}{\firsttick}{\lasttick}[\ticks]%
\StrSubstitute{\ticks}{`}{'}[\quotes]
\StrBehind[\nrticks]{#1}{`}[\secondpart]%
\cjRL{\firstpart}\raisebox{1pt}{\tiny$\quotes$}\cjRL{\secondpart}%
}

% xelatex xstring macro
\newcommand{\uhbdate}[1]{%
\IfSubStr{#1}{״}{\def\quotes{״}}{\def\quotes{׳}}
\StrBefore{#1}{\quotes}[\firstpart]%
\StrBehind{#1}{\quotes}[\secondpart]%
\cjRL{\firstpart}\quotes\cjRL{\secondpart}%
}

% pdflatex simple macro
\newcommand{\hebrewdate}[3]{%
\cjRL{#1}\raisebox{1pt}{\tiny$#2$}\cjRL{#3}%
}

% xelatex simple macro
\newcommand{\uhebrewdate}[3]{%
\cjRL{#1}#2\cjRL{#3}%
}

\begin{document}
\noindent\textbf{math quotes with pdflatex}\\
1st of Iyyar: \cjRL{'yyr}\raisebox{1pt}{ \tiny$'$}\cjRL{'}\\
16th of Iyyar: \cjRL{z 'yyr}\raisebox{1pt}{\tiny$''$}\cjRL{.t}\\
simple macro 1st: \hebrewdate{ 'yyr}{'}{'}\\
simple macro 16th: \hebrewdate{z 'yyr}{''}{.t}\\
xstring macro 1st: \hbdate{ 'yyr`'}\\
xstring macro 16th: \hbdate{z 'yyr``.t}\\

\noindent\textbf{unicode characters with xelatex}\\
\noindent1st of Iyyar: \cjRL{'yyr} ׳\cjRL{'}\\
16th of Iyyar: \cjRL{z 'yyr}״\cjRL{.t}\\
simple macro 1st: \uhebrewdate{ 'yyr}{׳}{'}\\
simple macro 16th: \uhebrewdate{z 'yyr}{״}{.t}\\
xstring macro 1st: \uhbdate{ 'yyr׳'}\\
xstring macro 16th: \uhbdate{z 'yyr״.t}\\
\end{document}

New result:

enter image description here

| improve this answer | |
  • Using quotes here seems awkward. It should be geresh or gershaim. I suggest upquotes package to fix that, or the use of UTF character. – Elad Den Nov 8 '16 at 14:06
  • Any chance you can provide a MWE for that? – SSL Nov 8 '16 at 15:30
  • 1
    @EladDen good suggestion, I made an edit to address the issue. – Marijn Nov 8 '16 at 17:35

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.