bidi-tex / xepersian

Persian for LaTeX, using XeTeX
Other
11 stars 1 forks source link

problem with natbib (style: chicago-fa) #4

Open eliadb opened 4 years ago

eliadb commented 4 years ago

I am using xepersian with hyperref and natbib (bibliograpgystyle: chicago-fa). The problem is this: If a reference with two authors is cited in a way that the first author's namepositioned is at the end of one line and the second author's name at the beginning of the next line, the whole text in these two lines (instead of the names and the year) will be linked to the bib entry.

P.S. I am using the texlive distribution included in Debian Buster.

davidcarlisle commented 4 years ago

Getting links right in the scope of direction changes is tricky, and the issue might be in hyperref or the chicago-fa bib style rather than here, but if you add a small example file that shows the problem we might be able to debug.

Please show clearly what output you expect, most of the people with write access to this repository or to hyperref can not read right to left scripts, so it is sometimes hard to spot things that are obviously wrong to someone who can read the document.

Is the issue just with the chicago-fa style or does it apply to any entry that has a linebreak in the standard styles? If it is just with the chicago-fa style it may be best to raise first with the maintainers of that style as listed in the ctan page https://ctan.org/pkg/persian-bib

eliadb commented 4 years ago

Here is a minimal working example:

\documentclass[12pt,a4paper]{article}

\usepackage{natbib}
\usepackage[pdfusetitle]{hyperref}
\usepackage{xepersian}
\settextfont[
Script=Arabic,
ItalicFont=Nazli,
ItalicFeatures={FakeSlant=0.25},
]{Nazli}
\setlatintextfont{Liberation Serif}
\begin{document}
    سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام
    \cite{Staniforth2012Horizontal}
    سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام سلام
\bibliographystyle{chicago-fa}
\bibliography{main}

\end{document}

main.bib

@Article{Staniforth2012Horizontal,
  author    = {Staniforth, Andrew and Thuburn, John},
  title     = {Horizontal grids for global weather and climate prediction models: a review},
  journal   = {Quarterly Journal of the Royal Meteorological Society},
  year      = {2012},
  volume    = {138},
  number    = {662},
  pages     = {1-26},
  authorfa  = { استنیفورث and توبرن },
  doi       = {10.1002/qj.958},
  eprint    = {https://rmets.onlinelibrary.wiley.com/doi/pdf/10.1002/qj.958},
}
davidcarlisle commented 4 years ago

@eliadb you closed this? Have you moved it elsewhere or did you solve the issue?

eliadb commented 4 years ago

@eliadb you closed this? Have you moved it elsewhere or did you solve the issue?

I accidentally closed it. I didn't know how to re-open it. I posted an example above.

davidcarlisle commented 4 years ago

@eliadb reopened:-)

eliadb commented 4 years ago

@eliadb reopened:-)

Thanks!

eliadb commented 4 years ago

Is the issue just with the chicago-fa style or does it apply to any entry that has a linebreak in the standard styles?

I just tested it with plainnat-fa and asa-fa. It happens regardless of the bibliography style.

FrankMittelbach commented 4 years ago

Am 20.01.20 um 14:57 schrieb Eliad:

I just tested it with plainnat-fa and asa-fa. It happens regardless of the bibliography style.

and what happens with "plain" or "plainnat"? or does that question makes no sense?

eliadb commented 4 years ago

and what happens with "plain" or "plainnat"? or does that question makes no sense?

The same thing happens with "plainnat" (It just uses the author field instead of authorfa). It doesn't happen with "plain", since it uses numbers and not name and year (hence no line breaks).

eliadb commented 4 years ago

Please show clearly what output you expect, most of the people with write access to this repository or to hyperref can not read right to left scripts, so it is sometimes hard to spot things that are obviously wrong to someone who can read the document.

If you use \bibliographystyle{plainnat}, the only parts of the text that should be hyperlinked are the names and the year (in square brackets), i.e. Staniforth and Thuburn [۲۰۱۲].

u-fischer commented 4 years ago

I have some doubts that it is possible to solve this. I can find nothing in the dvipdfm(x) documentation about direction changes for the bann/eann special. You could try to ask on the dvipdfmx mailing list: https://tug.org/pipermail/dvipdfmx/

eliadb commented 4 years ago

Is there a way to prevent line breaks in these situations? That could be a temporary fix.

davidcarlisle commented 4 years ago

\mbox{\cite{....}} ?

eliadb commented 4 years ago

\mbox{\cite{....}} ?

That is overkill and causes overfull lines. We just need to prevent line breaks between the names.

eliadb commented 4 years ago

As a temporary measure, I have defined \mbcite:

\newcommand{\mbcite}[1]{\mbox{\citeauthor{#1}} (\citeyear{#1}) }