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{}.

  • 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 7 '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 7 '15 at 17:13
  • @UlrikeFischer no, it is still problematic. Cf my new version. – Maïeul Dec 9 '15 at 16:36
  • Why are you using two \Hy@raisedlink{}? And why has it an empty argument? – Ulrike Fischer Dec 9 '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 tex.stackexchange.com/a/17138/7712 – Maïeul Dec 9 '15 at 20:04
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

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.