[OS X TeX] hyperref problem

Nitecki, Zbigniew H. Zbigniew.Nitecki at tufts.edu
Sun Jun 21 22:26:49 EDT 2020


Ross:
Thank you for taking the time to write all this very useful and thoughtful advice.

I am properly chastened for my sinful shortcut with the \c macro—and I should have realized its use in the context of foreign languages.
My current project doesn’t involve any references, but I used the foreign language packages extensively when writing my earlier book(s), particularly for foreign names.  I will try to go back and figure out what is going wrong a little more carefully and patiently.

I have a question about the pdfx package you mention at the end of your email.  I had not heard of it;  what exactly does it do?  Is it part of MacTex or TeX Live—in other words do I need to download it separately?  Do I call it with a \usepackage command?  I’m not quite sure what the whole validation process is about.  I gather it has to do with making one’s source code compatible with global standards, which I am happy to try to do.
(One of my worst publication experiences was with an article for the American Mathematical Monthly—my macros, even when I supplied the macro files, just wouldn’t cooperate with the MAA style file;  the editor at one point threatened, even though he liked the paper, to reject it on technical grounds.
I ended up going through a 20-page paper and replacing every one of my macro occurrences with its definition.  BTW, that would be a very useful kind
of script, if someone who knows these things were to write it.)

Thanks again for your advice.  I really appreciate it.

Best regards
Ziggy Nitecki

Zbigniew Nitecki
Department of Mathematics
Tufts University
Medford, MA 02155

telephones:
Office    (617)627-3843
Dept.    (617)627-3234
Dept. fax    (617)627-3966
http://www.tufts.edu/~znitecki/




On Jun 21, 2020, at 21:27, Ross Moore <ross.moore at mq.edu.au<mailto:ross.moore at mq.edu.au>> wrote:

Hi Zbigniew,

On 22 Jun 2020, at 6:58 am, Nitecki, Zbigniew H. <Zbigniew.Nitecki at tufts.edu<mailto:Zbigniew.Nitecki at tufts.edu>> wrote:

I just finished writing up a longish (50pp) set of notes using TeXShop; in the process I ran into two sets of problems, one involving hyperref, the  other a problem with the TeXShop editor.  I’m separating my questions into two emails.  This one concerns hyperref, for which I can provide a reasonably minimal example.  I’ll address my editor problems in a subsequent email.

I have for quite some time used a modification of the \ref macro in latex, which works as follows: labels are always in the format \label{#1:#2}, where #1
identifies a descriptive term like ’Section”  or “Theorem” and #2 identifies which one it is;  then when I want to refer back to the labeled item, I write \refer{#1}{#2}
and what gets printed is the descriptive term followd by the number.  I found this very useful, particularly in writing a book, to make the spelling and capitalization of cross references uniform.
Here is the style file whose main content is that macro:

All has gone well, and as I recall (it’s been a few years) it seemed to work well with hyperref on my book project as well.  But this time something went wrong.  There are two problems, but I think only the first can be addressed in this forum.
Here are a short sourcefile and pdf output, as well as a log file:

I find that when I compile this, if I immediately click on one of the (red) hyperlinked items, I am taken to the appropriate page (there are only two pages in this example).  However, any subsequent click on a hyperlinked item gives me only a little window showing what the text referred to looks like—it doesn’t go to the appropriate page.  I should clarify that this behavior is when I am in view in TeXShop.When I open just the pdf (so it opens in Preview, not in TeXShop, the hyperlinks seem to work.
I don’t know if there is something about the \refer macro that is conflcting with \hyperref, and if so, is there a workaround?

No. This will not have anything to do with the (back-end) macros that you use.

The small (Prelink) window is a feature added quite recently (say within 3 years).
It was used in Skim for awhile before it came into TeXshop’s Preview.
Someone else might be able to say exactly when (and why) this feature has been added to the TeXshop front-end.
It should show up simply by hovering your mouse over the active rectangle which is associated with the hyperlink.
Then actually clicking within that rectangle should activate the link as previously.
It may be that once the small Prelink window comes up, you cannot tell where the active rectangle is anymore,
or it may be completely obscured.
Is there a setting to shift where the Prelink window is located, w.r.t. the active rectangle?
Again, someone else may be able to answer this question.


The second hyperref problem is harder to pin down.  I actually have a lot of self-defined macros, mostly formatting notation, so in my actual source file,
there were both a number of \usepackage commands in the preamble which referred to my  macro packages—as well as pstricks and other packages—and a lot of \newcommands specific to the notes.

Not at all uncommon.

I initially had the call to \hperref in the middle of my preamble, and then I was experiencing the problem described by the example.  But then I looked at the hyperref manual and it said that the call should come after all the other calls.  So I moved it, and all hell broke loose.

Yes.
That recommendation in the hyperref manual was made roughly 20 years ago.
The reasoning is that quite a few macros need to be patched to support automatic creation
of advanced PDF features, such as Bookmarks, hyperlinked cross-references to sections,
citations, etc. as well as external hyperlinking.
It was then thought that it was best to delay Hyperref until as late as possible, so that when it does
its patching, it will build on top of whatever other packages may have done themselves, earlier
within the preamble.

Such advice is now grossly out-dated.
There are better ways to delay the patching until other packages have been loaded.
Nowadays I find it best to load hyperref as early as possible, so that you know what
you have and can build on top of that (using the better methods).



Another thing that is very important is that you don’t define home-grown macros
with names that will be altered by Hyperref, because they are standard in many
ways although you do not actually use them yourself.

This next problem is an example of exactly this.

 For example, I had at one point decided to use fraktur in one place in the notes, so put in a short sequence of macros for typing a,b,c, d, and A in fraktur.  Most of them were ok, except
\newcommand{\c}{\ensuremath{\mathfrak{c}}} led to an “unknown command” error once the hyperref command was moved to immediately precede the
\begin{document}.

I’m surprised that  \newcommand{\c}{… }  doesn’t throw an error immediately.
 \c  is the accent command for a cedilla, as is rather common in French and other languages.
By making this definition, you will never be able to properly typeset a co-author or citation-author’s name
such as   Fran\c{c}ois .

This affects hyperref, because in the advanced features it supports, it is necessary to declare
such macro names for encodings other than ones directed at specific font characters.
Hence all macros in commonly-used language encodings also become defined whenever hyperref is required.


In my mind, having single-letter user-defined macros is a real no-no.
Very many letters are used this way already for various languages and encodings.
Thus you are just asking for trouble when using hyperref, unless you are very careful
in how you choose macro names.

Trying to find single-letter names that are not already used, and remembering what you defined them for
is just a fool’s game. Better is to be more descriptive: e.g.  \frakc  in your case.
Yes, it’s more typing, at first; but with copy/paste and/or command completion it really is not so.
Furthermore, your LaTeX sources become easier to read and understand/proofread  than when every
3rd or 4th letter is a backslash.


Even 2-letter names commonly have another use.   (\it, \rm, \tt, \sc, \sf, \ij, \dj, \dz , … )
The only 2-letter combinations that I use are ones that clearly jolt the mind as to
their intended meaning; e.g. \RR , \QQ, \CC  etc. for  \mathbb  letters, or bold-face symbols.
Using \bb, \cc, \xx, \yy etc.  for vectors is generally acceptable, but beware \tt  and that  \aa  and \AA
already have a meaning.   (think the symbol for Angstrøm units, or in Swedish names).


Also, one of the pstricks routines I used (pst-ode) defined some parameters via the statement
                \pstVerb{
                /A -1 def
                /B 0 def
                /C 0 def
                /D -2 def
                }
and this led to unknown command errors.  (They disappeared if I moved the \hyperref call earlier).
Again, I don’t know what is going on, but this one is harder to correct because there are a lot of possible conflicts spread over many files.
However, I found it strange that this problem only occurred when I moved the hyperref call to the end of the preamble.

Not so strange, when you realise that  hyperref  is encountering a macro name that it is trying to declare
for a standard meaning, but it has been usurped by something already defined.

So for now, I am not using hyperref in these notes, but would like to.

My advice is to go back to loading it early,
and take great care about resolving any errors that you may encounter.

If you have lots of foreign names in your References, check them to make sure
 a.  that they are actually typeset correctly;
 b.  try to Copy/Paste your whole reference section into a text-file; check
      for errors in the spellings that may result.

Also, I recommend doing:

 c.  load the  pdfx  package to generate PDF/A-2u output, to attempt to conform to
      a published standard for Archivability.

There is a lot of stuff in there specifically to allow you to detect and fix the kinds of
errors that are discussed above.
But you’ll need to check your PDFs with validation software.
There are a number of online PDF/A validators, so you don’t need to have purchased
a licence for Acrobat Pro, or other costly software.
(But if your institution gives you cheap access to Acrobat Pro, then it is well worth having.)


Hope this helps.

Ross


Zbigniew Nitecki
Department of Mathematics
Tufts University
Medford, MA 02155

telephones:
Office    (617)627-3843
Dept.    (617)627-3234
Dept. fax    (617)627-3966
http://www.tufts.edu/~znitecki/<https://protect-au.mimecast.com/s/70g7Cvl1g2Sv3J4gsQiUiV?domain=tufts.edu/>




<refmacros.sty><TestofHyperref.tex><TestofHyperref.log><TestofHyperref.pdf>----------- Please Consult the Following Before Posting -----------
TeX FAQ: https://protect-au.mimecast.com/s/haBqCwV1jpSoW5PQSqKkVT?domain=tex.ac.uk
List Reminders and Etiquette: https://protect-au.mimecast.com/s/-dmXCxngGkfZ3pB0SY9yff?domain=sites.esm.psu.edu
List Archives: https://protect-au.mimecast.com/s/uahlCyoj8PuYRGJWSR9OPu?domain=dir.gmane.org
               https://protect-au.mimecast.com/s/1KPVCzvkmpfKAXnBto1_x6?domain=email.esm.psu.edu
TeX on Mac OS X Website: https://protect-au.mimecast.com/s/w7VKCANpnDCjzxVofMkjBJ?domain=mactex-wiki.tug.org
List Info: https://protect-au.mimecast.com/s/u3O0CBNqgBCvOxAmsv1q37?domain=email.esm.psu.edu


Dr Ross Moore
Department of Mathematics and Statistics
12 Wally’s Walk, Level 7, Room 734
Macquarie University, NSW 2109, Australia
T: +61 2 9850 8955  |  F: +61 2 9850 8114
M:+61 407 288 255  |  E: ross.moore at mq.edu.au<mailto:ross.moore at mq.edu.au>
http://www.maths.mq.edu.au<http://www.maths.mq.edu.au/>
<http://mq.edu.au/>

----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
               https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://email.esm.psu.edu/pipermail/macosx-tex/attachments/20200622/c8ce119b/attachment.htm>


More information about the MacOSX-TeX mailing list