2

the \Hy@raisedlink (used because of what explaned in this answer: https://tex.stackexchange.com/a/17138/7712) seems make trouble with hyphenations.

Cf this MWE

 \documentclass[a4paper]{book}
\usepackage[a4paper]{geometry}
\usepackage{polyglossia,fontspec,hyperref}
\setmainfont{Linux Libertine O}
\setmainlanguage{greek}

\makeatletter
\newcommand\test{6. Καὶ δὴ τῷ κράτει
    \edtext{τοῦ} \edtext{συγγενέος} \edtext{ἐπιθαρσήσας}, \edtext{οὐμενοῦν}
    \edtext{εἴ τι}
καὶ \edtext{δέοι}
παθεῖν
δείσας
καλὴν ἑαυτῷ
τῆς εἰς Χριστὸν πίστεως, τὴν ἐν
    \edtext{Γράμματι}
νομοθεσίαν,
ὑποβάθραν
    \edtext{προύθηκεν}.
    \edtext{Περιτυχὼν}
γὰρ
    \edtext{τῶν}, \edtext{Μωσαικῶν}
    \edtext{βιβλίων},
καὶ
    \edtext{τῆς Ἐβραίων ἁπάσης Γραφῆς},
καὶ τούτοις ὡς μάλιστα φιλομαθῶς
    \edtext{ἐναπασχολήσας}τὸν νοῦν, καὶ
    \edtext{ὅλος}
    \edtext{ὅλῳ}
στοιχειωθεὶς,}


\begin{document}


\section{Good}
\def\edtext#1{#1}
\test


\section{Bad}
\def\edtext#1{\Hy@raisedlink{}#1\Hy@raisedlink{}}


\test

\section{Better}
\def\edtext#1{\Hy@raisedlink{}\hspace{0pt}#1\Hy@raisedlink{}\hspace{0pt}}

\test

\section{Ok?}
\def\edtext#1{\Hy@raisedlink{}\hspace{0pt}#1\Hy@raisedlink{}}


\test


\end{document}

The \edtext without \Hy@raisedlink produce good hyphen / , not with \Hy@raisedlink. The version suggested by @Ulrike Fischer are better, but not so good. Idealy, all line should be as in example 1, without \Hy@raisedlink{}.

Maïeul
  • 10,984
  • 1
    You can insert \hspace{0pt} to allow hyphenation in the "rest of the word": \def\edtext#1{\Hy@raisedlink{}\hspace{0pt}#1} – Ulrike Fischer Dec 07 '15 at 17:05
  • oh, yes. it seems to work. Thank. But maybe it should be signaled to the author of the package, do you think? – Maïeul Dec 07 '15 at 17:13
  • @UlrikeFischer no, it is still problematic. Cf my new version. – Maïeul Dec 09 '15 at 16:36
  • Why are you using two \Hy@raisedlink{}? And why has it an empty argument? – Ulrike Fischer Dec 09 '15 at 17:01
  • \Hy@raisedlink allow to add an anchor linked to the top of the line, and not the bottom. The argument is empty because it is a MWE, but normally it contain a \hypertarget{anchorname}{}. Cf http://tex.stackexchange.com/a/17138/7712 – Maïeul Dec 09 '15 at 20:04
  • And why do you add a second anchor behind your text? The hspace behind this second raisedlink doesn't make much sense too, if a hspace is needed, it should be before to separate the anchor box from the text. – Ulrike Fischer Dec 09 '15 at 20:56
  • because I need to add two anchor: one to refer to the begining of a passage the other one to refer to the end of passage. – Maïeul Dec 09 '15 at 21:07
  • here the passage are only one word, but it could be more, and one more line. – Maïeul Dec 09 '15 at 21:08
  • cf also, if you read french the question asked on http://texnique.fr/osqa/questions/781 – Maïeul Dec 09 '15 at 21:32

1 Answers1

1

I have asked the same question on a french website, http://texnique.fr.

One user (@unbonpetit) provides me a good answer. I recopy it here.

The problem comes with the penalties added by \Hy@raisedlink. The solution of adding \hspace{0pt} as proposed by @UlrikeFischer is not good, as it creates new node for line breaking, and can produce thing bad like horizontal space after a comma at the end of line.

So, the only solution see by @unbonpetit is too create a new macro \Hy@raisedlink@left, similar to \Hy@raisedlink but to be called at the begin (left) of a word. It use \llap to not perturbate spacing and breaking.

\documentclass[a4paper]{book}
\usepackage[a4paper]{geometry}
\usepackage{polyglossia,fontspec,hyperref,xcolor}
\setmainfont{Linux Libertine O}
\setmainlanguage{greek}

\makeatletter
\def\Hy@raisedlink@left#1{%
    \ifvmode
        #1%
    \else
        \Hy@SaveSpaceFactor
        \llap{\smash{% \llap{ added
        \begingroup
            \let\HyperRaiseLinkLength\@tempdima
            \setlength\HyperRaiseLinkLength\HyperRaiseLinkDefault
            \HyperRaiseLinkHook
        \expandafter\endgroup
        \expandafter\raise\the\HyperRaiseLinkLength\hbox{%
            \Hy@RestoreSpaceFactor
            #1%
            \Hy@SaveSpaceFactor
        }%
        }}% } to close \llap
        \Hy@RestoreSpaceFactor
        \penalty\@M\hskip\z@ 
    \fi
}

\newcommand\test{6. Καὶ δὴ τῷ κράτει
    \edtext{τοῦ} \edtext{συγγενέος} \edtext{ἐπιθαρσήσας}, \edtext{οὐμενοῦν}
    \edtext{εἴ τι} καὶ \edtext{δέοι} παθεῖν δείσας καλὴν ἑαυτῷ
    τῆς εἰς Χριστὸν πίστεως, τὴν ἐν \edtext{Γράμματι} νομοθεσίαν,
    ὑποβάθραν \edtext{προύθηκεν}. \edtext{Περιτυχὼν} γὰρ \edtext{τῶν},
    \edtext{Μωσαικῶν} \edtext{βιβλίων}, καὶ \edtext{τῆς Ἐβραίων ἁπάσης Γραφῆς},
    καὶ τούτοις ὡς μάλιστα φιλομαθῶς \edtext{ἐναπασχολήσας}τὸν νοῦν, καὶ
    \edtext{ὅλος} \edtext{ὅλῳ}
στοιχειωθεὶς,}

\begin{document}

\section{Good}
\def\edtext#1{#1}
\test

\section{Bad}
\def\edtext#1{\Hy@raisedlink@left{}#1\Hy@raisedlink{}}
\test

\end{document}

See the original answer

Maïeul
  • 10,984