Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When typesetting the following (using pdfTeX or luaTeX) the rightmost bracket of the cross reference in the marginal note is colored as if part of the hyperlink (though not actually part of the link), which I believe it should not be. The left bracket is black and not part of the link:

\input opmac

% Enable hyperlinks
\hyperlinks\Red\Red

\newcount\somecounter \somecounter 1

\label[test]\wlabel{T.\the\somecounter} This is a test

More Text and now we put a cross reference in a marginal note: \mnote{[\ref[test]]}

\bye

screenshot

So far I've only seen this behaviour in marginal notes via \mnote.

share|improve this question
1  
It seems that everything after \ref[...] in the \mnote is considered part of the link. A bug, undoubtedly. But the text after T.1 is not part of the link. –  egreg Jun 17 at 17:30
    
@egreg, as you and Heiko both noticed, the "link" part wasn't affected, just the colour of text after it. I updated the question to reflect that. –  acarlow Jun 17 at 19:02

2 Answers 2

up vote 3 down vote accepted

This problem is dicussed in OPmac trick 0037 from March 2014. I'll try to transtate it:

If you need to switch the colors in paragraph with usage of \mnotes, probably color puzzlement occurs. The \mnote is processed by macros in its occurrence but it is inserted after current paragraph line by \vadjust primitive. The \mnote have the color as the current line at its end. The version OPmac Mar2014 or latter solves the problem by possibility to add the color by \mnotehook. This color has "global" validity "locally" in each \mnote and it doesn't affect the color of lines in the main paragraph. For example you need to have all \mnotes blue:

\def\mnotehook{\noindent\Blue}

The \noindent is needed here becuase the color mark in vertical mode breaks the right placement of the \mnote text.

Why OPmac doesn't declare \def\mnotehook{\noindent\Black} by default? Because the default behavior is to inherit the color from the current text of main paragraph for \mnotes.

More colors can be in the \mnote text (in groups declared by \localcolor, for example). If the \localcolor isn't used here, the color ends at the end of the \mnote text.

share|improve this answer
    
@acarlow Thank you for this report. I've added the following sentence to the mentioned OPmac trick: Warning: If the color isn't initialized by \mnotehook or at the beginning of the \mnote text then the "local colorstack" in \mnote text doesn't work correctly. –  wipet Jun 17 at 19:34
    
Thanks for the explanation and updating the "trick" documentation. Unfortunately, the only way I can read the tricks is with the Google translator and often the meaning doesn't translate well or at all. Hopefully this exchange will offer English speakers another resource. –  acarlow Jun 17 at 20:13
    
As an aside, there still seems to be a problem with the implementation if the color of text after the link is supposed to be the same as the color of the paragraph to which the mnote is attached, no? –  acarlow Jun 17 at 20:16
    
@acarlow Yes, the problem is that there is an asynchronous color processing: the macro expansion is processed at different time than the color marks are stored in PDF via \vadjust. Macros in \mnote are unable to know the current color in the parahraph (exactly at the end of the current line of the paragraph). Thus the base mnote color is unknown by macros. I'm considering to change the behavior of \restorecolor to base mnote color from the current "do nothing" to "return to Black". Both are not 100% right. If user needs color manipulation in mnotes he/she has to set colors explicitly. –  wipet Jun 18 at 4:41
    
I understand. In my opinion, simply defaulting \mnotes to black makes the most sense. If I hadn't known anything about this issue, I wouldn't have been surprised that \mnotes defaulted to black instead of the color of the \mnote's source paragraph. –  acarlow Jun 18 at 5:56

\mnote clears the color, in \mnoteC:

\def\currcolork{}
\def\currcolorK{}

Then the link sets the color \Red inside a group:

{\localcolor \Red}

\localcolor restores the color after the group via \restorecolor. But because the current color at the start of \mnote is empty, nothing is restored and the color remains red.

Workaround:

\mnote{[\Black\ref[test]]}

Then the color can be restored after the link to black.

share|improve this answer
    
Thanks for figuring out that it was just the colour and not the actual hyperlink that was affected (I mistakenly thought it was the link). Also, the workaround works perfect. –  acarlow Jun 17 at 18:54
    
@wipet has given more specifics about the implementation below. Either a global \mnotehook or a local color color change in the \mnote itself as shown by Heiko can be used to fix the issue. –  acarlow Jun 17 at 20:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.