LaTeX forum ⇒ LyXProblems Using Hyperref Topic is solved

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Posts: 7
Joined: Mon Mar 24, 2014 3:48 am

Problems Using Hyperref

Postby crgonzalez4611 » Tue Jun 10, 2014 12:04 am


I am working on my thesis using LyX. I am running into trouble with the hyperref support. Without it, the thesis outputs just fine but when I turn hyperref on in Document > Settings > PDF Properties it does not work. It gives me the following error:

  1. Undefined Control Sequence.
  3. \begin{acknowledgments}
  5. The control sequence at the end of the top line
  6. of your error message was never \def'ed. If you have
  7. misspelled it (e.g., `\hobx'), type `I' and the correct
  8. spelling (e.g., `I\hbox'). Otherwise just continue,
  9. and I'll forget about whatever was undefined.

And identical errors for the following (instead of \begin{acknowledgments}: \listoftables, \listoffigures, \begin{abstract}.

I have no idea what is going on. I am no expert in LaTeX or LyX but I know you would want the files to help me so they are attached. Useful information follows below the signature line.

Thanks for your help,


Windows 7 Enterprise (64-bit)

LyX 2.1.0
MiKTeX 2.9

No content (paragraphs, figures, tables, bibliography entries) included.

Document Class:
Another student gave me customized .cls and .layout files (based on report class) for the requirements of my school. Both files are in the attachment. I am currently running them as a local layout (i.e. the class is not installed in MiKTeX or LyX system folders).

.bib file made using Jabref 2.10. I am using jfm.bst as my style. I have it installed in the MiKTeX system folder but I have also included it in the attachment.
(23.08 KiB) Downloaded 116 times
Last edited by cgnieder on Tue Jun 17, 2014 12:09 pm, edited 1 time in total.
Reason: added code markup


Posts: 89
Joined: Fri Jan 24, 2014 12:42 am

Postby StarValkyrie » Tue Jun 10, 2014 4:42 pm

Your cls file is not a local layout. Layout files talk to LyX about what to put on the screen as you're typing. It doesn't know what to do with the cls code when you put it there. Either paste the contents of the cls file into the Preamble or put the file in the same folder as your document and call it from the Preamble.

Posts: 7
Joined: Mon Mar 24, 2014 3:48 am

Postby crgonzalez4611 » Tue Jun 10, 2014 7:37 pm

Poor choice of words on my part. I meant I have both .cls and .layout files on the same folder as the thesis .lyx files. What I did was that I went to Document > Settings > Document Class and selected the .layout file using the "Local Layout" button. Like I said, the document output just fine without the hyperref. Just as I turned the hyperref on, it did not work.

Posts: 89
Joined: Fri Jan 24, 2014 12:42 am

Postby StarValkyrie » Thu Jun 12, 2014 6:30 am

Ok, I understand now. Well your layout file looks fine. You call natbib three times and nomencl twice in your preamble, but that won't cause what's happening. Those error messages aren't very helpful. I'd blame the cls file because there's not a whole lot else in these minimal examples, but a cursory glance at it didn't spot anything that stood out (other than my personal pet peeve of not changing the first line of frankensteined code to the name of the new cls file). It is totally possible that if someone who knows writing cls files better than me takes a look, they might find something. However...

I then took all your LyX documents and exported them to TeX, opened them in TeXWorks and fixed the input strings to point to the TeX documents (remember - no spaces in your file names/paths for your actual documents!) and hit compile. It worked with no errors and no other changes to your test documents so its possible this is A) a problem with the input of files via LyX (I tried adding the lyx files via Insert, File, Child Document though and that didn't help), or B) a LyX bug of some sort - it has always had problems with hyperref so I wouldn't be surprised and there's not much that can be done about that if it is. I'd suggest talking to your fellow students and professors to see if anyone else is having this problem and what they're doing about it. If this is a LyX bug, I'd expect someone else to be having this problem too. Sorry I can't be of much help. Worst case scenario, you might have to A) work in TeX for real without LyX in between you and the code, or B) work in LyX and then export it to LaTeX and do the compiling in a TeX processor (if you choose this option, make frequent backup copies and do a test export and compile often to make sure you catch any errors as soon as possible so you don't have to troubleshoot a whole thesis document up against your deadline).

Posts: 7
Joined: Mon Mar 24, 2014 3:48 am

Postby crgonzalez4611 » Thu Jun 12, 2014 4:40 pm

Thanks for your trying. I know it was a lot of files so thanks for taking a look. If I can't find a solution for this, I might have to learn LaTeX and work in TeXworks instead, like you suggested.

Since I posted the topic, I tried exporting a blank file (no preamble, no math packages, no modules, only natbib citation style selected) with the class and it worked just fine... as long as hyperref is off.

I also tried using the thesis files and commenting out the preamble one line at a time. Still no luck with getting hyperref to work or finding any conflicts with the packages I am using.

I now think (especially after your response) it is something in the .cls and/or .layout file(s). Like I said, I got the class files from another student so I have not touched them. It is very possible that whoever coded the class files made a mistake.

Posts: 89
Joined: Fri Jan 24, 2014 12:42 am

Postby StarValkyrie » Thu Jun 12, 2014 7:30 pm

I don't know what I had going last night but I couldn't recreate it this morning which is probably just as well because I went back and fixed the errors in the cls instead and now it seems to be working correctly within LyX. The problem was with the MakeUppercase in just the sections throwing up error messages so I hard-coded the titles in all caps instead which is bad form but at least it does compile. Cls file attached. Just swap it for the one you have in your document folder and continue using LyX as usual.
(27.67 KiB) Downloaded 158 times

Posts: 7
Joined: Mon Mar 24, 2014 3:48 am

Postby crgonzalez4611 » Fri Jun 13, 2014 6:43 pm

Thanks so much for your help. It worked. Just needed to add a few phantom sections in the front matter and in the back matter.

I could not have submitted my thesis as it was before. I am required to submit a PDF file with bookmarks and cross references and now I have everything I need to start writing. Thanks.

Return to “LyX”

Who is online

Users browsing this forum: No registered users and 4 guests