2

I tried to get this: Mixing Hebrew and English bibliographies? but the problem is that I'm using LyX. So I look here: How do I make my bibliography according to harvard-style (author-year, alphabetical by sourcetype...) in Lyx?
But I's still don't work (there are many many problems.... :( )

Here is the result: enter image description here

And here are the files:

% Preview source code

%% LyX 2.3.0 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[a4paper,english,hebrew]{article}
\usepackage{fontspec}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength{\parindent}{0bp}
\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
 breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
 {hyperref}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\usepackage{theorem}
\theorembodyfont{\upshape}
\newtheorem{theorem}{\R{משפט}}[section]
\AtBeginDocument{\make@lr\thetheorem}

% The following chunk fixes export with XeTeX.
% It is needed because polyglossia is used by default
% and \make@lr is only defined by babel.
\@ifundefined{make@lr}
{\def\make@lr#1{\begingroup
    \toks@=\expandafter{#1}%
    \edef\x{\endgroup
  \def\noexpand#1{\noexpand\@number{\the\toks@}}}%
  \x}}{\relax}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\newfontfamily\hebrewfont[Script=Hebrew]{David CLM}
\newfontfamily\hebrewfonttt[Script=Hebrew]{Miriam Mono CLM}
\newfontfamily\hebrewfontsf[Script=Hebrew]{Yehuda CLM}
\AtBeginDocument{
\renewcommand\footnoterule{%
  \kern -3pt
  \hbox to \textwidth{\hfill\vrule height 0.4pt width .4\textwidth}
  \kern 2.6pt
}}

\makeatother

\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\begin{document}
שלום\cite{sep-plato}

שלום\cite{מישהו1990}

\bibliographystyle{plain}
\bibliography{simplebib}

\end{document}

And the bib file:

% Encoding: UTF-8

@Book{מישהו1990,
  title     = {ספר},
  publisher = {הוצאה},
  year      = {1990},
  author    = {מישהו},
}

@InCollection{sep-plato,
  author       = {Kraut, Richard},
  title        = {Plato},
  booktitle    = {The Stanford Encyclopedia of Philosophy},
  publisher    = {Metaphysics Research Lab, Stanford University},
  year         = {2017},
  editor       = {Edward N. Zalta},
  edition      = {Fall 2017},
  howpublished = {\url{https://plato.stanford.edu/archives/fall2017/entries/plato/}},
}

@Comment{jabref-meta: databaseType:bibtex;}

What can I do for the English resource [2] will write at the right direction? (biber and natbib makes my errors...)

P.S. I'm using JabRef software.

heblyx
  • 2,571

1 Answers1

3

Update: See below for an attempt in LyX.

This is almost certainly not a suitable answer, but does demonstrate a possible way forward using babel, lualatex, and biblatex. babel is still pretty rough for RTL languages and biblatex doesn't support Hebrew either, so you would need to do some work to set strings up (but I think it could be done).

My code includes a couple of workarounds that I think shouldn't be necessary, but I had to make in order to get things working.

It works by specifying a langid field in your bibliography entries, then getting biblatex to change the language for every entry in the bibliography based on this (set up using autolang=other*).

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Book{מישהו1990,
  title     = {ספר},
  publisher = {הוצאה},
  date      = {1990},
  author    = {מישהו},
  langid    = {hebrew}
}

@InCollection{sep-plato,
  author    = {Kraut, Richard},
  title     = {Plato},
  booktitle = {The Stanford Encyclopedia of Philosophy},
  publisher = {Metaphysics Research Lab, Stanford University},
  date      = {2017},
  editor    = {Edward N. Zalta},
  edition   = {Fall 2017},
  url       = {https://plato.stanford.edu/archives/fall2017/entries/plato/},
  langid    = {english}
}
\end{filecontents}

\usepackage[nil,bidi=basic-r,layout=lists]{babel}
\babelprovide[import=he,main]{hebrew}
\babelprovide[import=en]{english}
\babelfont{rm}[
  Ligatures=TeX,
  Extension=.ttf,
  UprightFont=*-Medium,
  ItalicFont=*-MediumOblique,
  BoldFont=*-Bold,
  BoldItalicFont=*-BoldOblique
]{TaameyDavidCLM}
\babelfont[american]{rm}[
  Ligatures=TeX,
  SmallCapsFont={Latin Modern Roman Caps}
]{Latin Modern Roman}
\babelfont{tt}[Ligatures=TeX]{Latin Modern Mono}

\usepackage[autolang=other*]{biblatex}
\addbibresource{\jobname.bib}

% set labels left to right, otherwise brackets are wrong. Why is this??
\DeclareFieldFormat{labelnumberwidth}{\textdir TLT \mkbibbrackets{#1}}

% slight tweak to bibliography environment
\defbibenvironment{bibliography}
  {\list
     {\printtext[labelnumberwidth]{%
        \printfield{labelprefix}%
        \printfield{labelnumber}}}
     {\setlength{\labelwidth}{\labelnumberwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item \leavevmode}% add \leavevmode to work around babel quirk

\begin{document}

שלום \autocite{sep-plato}.

שלום \autocite{מישהו1990}.

\printbibliography[title=מקורות]
\end{document}

enter image description here


LyX File

You can actually do this in LyX. But it's a bit of a pain. And I'm not sure how robust it is. You have to do the language and biblatex setup in the preamble. Here's my attempt:

#LyX 2.3 created this file. For more info see http://www.lyx.org/
\lyxformat 544
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\begin_preamble
\usepackage[nil,bidi=basic-r,layout=lists]{babel}
\babelprovide[import=he,main]{hebrew}
\babelprovide[import=en]{english}
\babelfont{rm}[
  Ligatures=TeX,
  Extension=.ttf,
  UprightFont=*-Medium,
  ItalicFont=*-MediumOblique,
  BoldFont=*-Bold,
  BoldItalicFont=*-BoldOblique
]{TaameyDavidCLM}
\babelfont[english]{rm}[
  Ligatures=TeX,
  SmallCapsFont={Latin Modern Roman Caps}
]{Latin Modern Roman}
\babelfont{tt}[Ligatures=TeX]{Latin Modern Mono}

\usepackage[style=numeric,autolang=other*]{biblatex}

% set labels left to right, otherwise brackets are wrong. Why is this??
\DeclareFieldFormat{labelnumberwidth}{\textdir TLT \mkbibbrackets{#1}}

% slight tweak to bibliography environment
\defbibenvironment{bibliography}
  {\list
     {\printtext[labelnumberwidth]{%
        \printfield{labelprefix}%
        \printfield{labelnumber}}}
     {\setlength{\labelwidth}{\labelnumberwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item \leavevmode}% add \leavevmode to work around babel quirk

% set references string, since biblatex falls back to english
\DefineBibliographyStrings{english}{
  references = {מקורות}
}
\end_preamble
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package none
\inputencoding default
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts true
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
\use_dash_ligatures true
\graphics default
\default_output_format pdf5
\output_sync 0
\bibtex_command biber
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine biblatex
\cite_engine_type numerical
\biblio_style plain
\biblio_options autolang=other*
\biblatex_bibstyle numeric
\biblatex_citestyle numeric
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\use_minted 0
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard

\lang hebrew
שלום 
\begin_inset CommandInset citation
LatexCommand autocite
key "sep-plato"
literal "false"

\end_inset

.
\end_layout

\begin_layout Standard

\lang hebrew
שלום 
\begin_inset CommandInset citation
LatexCommand autocite
key "מישהו1990"
literal "false"

\end_inset

.
\end_layout

\begin_layout Standard
This is in English.
\end_layout

\begin_layout Standard

\lang hebrew
\begin_inset CommandInset bibtex
LatexCommand bibtex
btprint "btPrintCited"
bibfiles "simplebib"

\end_inset


\end_layout

\end_body
\end_document

And simplebib.bib:

@Book{מישהו1990,
  title     = {ספר},
  publisher = {הוצאה},
  date      = {1990},
  author    = {מישהו},
  langid    = {hebrew}
}

@InCollection{sep-plato,
  author    = {Kraut, Richard},
  title     = {Plato},
  booktitle = {The Stanford Encyclopedia of Philosophy},
  publisher = {Metaphysics Research Lab, Stanford University},
  date      = {2017},
  editor    = {Edward N. Zalta},
  edition   = {Fall 2017},
  url       = {https://plato.stanford.edu/archives/fall2017/entries/plato/},
  langid    = {english}
}

Output is basically the same as above. (Except with the English paragraph added as well.)

David Purton
  • 25,884
  • First of all - Thank you!! I can't run this solution (in TeXworks), and I don't really understand what I need to do.... How I doing what you did at LyX... – heblyx Aug 13 '18 at 09:47
  • 1
    @heblyx, I don't use LyX, but I started experimenting to see of I could make this work. I think I can, I'll post some code when I figure it out – David Purton Aug 13 '18 at 10:26
  • It's doesn't work at all :( – heblyx Aug 27 '18 at 13:59
  • Can you explain me more please how you make it and what you put at preamble and other important things? – heblyx Aug 27 '18 at 14:21
  • @heblyx, can you open the lyx file I made? – David Purton Aug 27 '18 at 14:25
  • Yes, but the output is still wrong :-(. what can I do? https://i.imgur.com/KdXY8Ie.png – heblyx Aug 27 '18 at 14:32
  • @heblyx. I made a slight change to the files above (I'd left an american in that I meant to change to english). Can you try again? Make sure you use the exact lyx file and exact simplebib.bib file. (Your screenshot suggests at least the Hebrew entry is different.) – David Purton Aug 27 '18 at 15:24
  • @heblyx, if it still doesn't work. The next thing to check is that your TeX distribution is up to date and you have the latest version of babel (currently 3.22) – David Purton Aug 27 '18 at 15:29
  • How I'm checking it?? (It's still doesn't work...) – heblyx Aug 27 '18 at 15:31
  • I think it's work except two things: https://i.imgur.com/ctY2eI8.png 1. Can you remove the filed of language from the bibliography? (at yellow). 2. The dot need to remove the end of the line https://i.imgur.com/XwVTkOQ.png . After those it should be fine. can you fix dose? – heblyx Aug 27 '18 at 16:09
  • @heblyx, your output does not match what I see. My output from lyx is exactly the same as in my screenshot above. Notice that your font is different. The language is not correctly being changed. It's your Hebrew font always being used. And I do not see the "English" and "Hebrew" in my bibliography. Also, your screenshot does not show the URL. Are you sure both files match mine? – David Purton Aug 27 '18 at 16:18
  • Oh, there is another problem, I need to use XeTeX: Can you try to run this file? https://shrib.com/#zefG2Dl8iB0auOcEj_a0 – heblyx Aug 27 '18 at 16:20
  • Now it's work fine... But I need to change the language to Hebrew because I'm writing at Hebrew.. – heblyx Aug 27 '18 at 16:24
  • @heblyx. Oh. My solution will not work with xelatex. It is only for lualatex. I think when I originally looked at your question. I tried with xelatex, but couldn't do it. – David Purton Aug 27 '18 at 16:25
  • @heblyx, you can switch languages using the edit→language menu. – David Purton Aug 27 '18 at 16:27
  • I did it, thank you! But why I can't change the font? when I put other font from TaameyDavidCLM it says that the font doesn't found and I can't write at Sans-Serif fonts.... – heblyx Aug 27 '18 at 16:30