Tuesday, July 17, 2012

Lenovo recovery after I wiped my windows partition

So I just got a new lenovo laptop, from the thinkpad edge range. And so I booted it up, did the set-up in windows 7, and then plugged in my Ubuntu live USB and rebooted. For some reason when i resized my partitions it decided to format them (I swear I've never had it do that before), leaving me without a windows installation! So I installed ubuntu and made several partitions, leaving me with a set-up like this:
Windows Boot Loader (about a 1G partition that was already there)
50GB ext4 for ubuntu
50GB NTFS for windows
300 GB NTFS for shared data
20GB Lenovo recovery drive

Presumably I could just boot with the boot loader and it would detect that I did not have a functioning windows system, right? Well, it did, but it couldn't really do anymore than that. It failed to find my recovery partition and I spent some time rebooting and trying every different option under the boot loader. I googled a bit and found various advice about changing GRUB, copying the recovery drive over to another computer and making recovery disks, etc. etc. I tried to change GRUB, but still the boot-loader would not recognise the recovery drive (the recovery drive itself is not bootable).

Alas, the internet was failing me. I tried to boot the recovery software with cross-over, but I didn't have any burning software so that ended there. I actually decided to have a look at my recovery drive, which had a giant .wim file on it (called cdrive or something, there's also an sdrive image which I assume is the system drive image). Having not dealt with windows in a while I googled that, discovered it was an image and extracted it with archive manager onto my windows partition.

 I added a boot flag to it in partition manager (I have no idea if this was required, I just did it anyway) and then ran sudo grub-update (definitely needed). Reboot, Windows appears under GRUB, I boot into it and it works fine! Well, except for some of the lenovo stuff is a bit wonky, but otherwise, perfect. So all you need to do is find your image on your recovery drive and extract it to a partition. Super simple stuff really.

Friday, July 6, 2012

hyperref, ToCs and incorrect page numbers and bookmarks

I was having trouble with page numbers in my table of contents and hyperref.Basically the page numbers would occasionally be the page before, or the section before, and the link in the ToC or in the document layout would take you to the wrong part of the document.

The culprit was probably most likely the lines I had in there that pushed sections and subsections onto right-hand (odd) pages.
If I add in a \phantomsection prior to the final \stdsection, problem (mostly!) solved:
I still can't get it to put my Glossary entry on the right page...

But finally, success ! Putting a \cleardoublepage between my \listoftables and my glossary \printglossaries for some reason fixed it... a \null\newpage or a \newpage, or \clearpage didn't work (despite putting it on the same page as a \cleardoublepage).

To add a bookmark to the location of the ToC but without actually adding a reference in the ToC,
\cleardoublepage \hypertarget{tocpage}{} \tableofcontents    \bookmark[dest=tocpage,level=1]{Table of Contents}
The cleardoublepage stopped the hypertarget from referring to the previous section, but actually does nothing in my document. the level of the bookmark defines the level in the bookmarks - I wanted it to be the same level as the sections.

EDIT: this also works if you have an unnumbered section that you have added manually to your ToC, ala:
this corrects the problem with hyperref not hyperlinking to the right page:
\phantomsection \subsection*{title}