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.
\newcommand*\stdsection{}
\let\stdsection\section
\renewcommand*\section{%
\clearpage\ifodd\value{page}\else\mbox{}\clearpage\fi
\stdsection}
If I add in a \phantomsection prior to the final \stdsection, problem (mostly!) solved:
\newcommand*\stdsection{}
\let\stdsection\section
\renewcommand*\section{%
\clearpage\ifodd\value{page}\else\mbox{}\clearpage\fi
\phantomsection\stdsection}
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:
\subsection*{title}
\addcontentsline{toc}{subsection}{title}
this corrects the problem with hyperref not hyperlinking to the right page:
\phantomsection \subsection*{title}
\addcontentsline{toc}{subsection}{title}

Wednesday, January 18, 2012

Rosetta 3.3 and gcc version incompatibility

I was trying to install Rosetta 3.3 on my current system but kept on getting:

``KeyError: "Unknown version number 4.6 for compiler 'gcc'"

Obviously I'm not going to roll back my gcc somehow to get it to install. The solution is pretty damned simple.
From http://www.rosettacommons.org/content/invalid-value-option-cxx#comment-3211

OK, try editing the line of tools/build/options.settings that says:
"gcc" : [ "3.3", "3.4", "4.0", "4.1", "4.2", "4.3","4.4","4.5", "*" ],
to instead have 4.6 as well:
"gcc" : [ "3.3", "3.4", "4.0", "4.1", "4.2", "4.3","4.4","4.5", "4.6", "*" ],

Success! Almost...
then there was:

collect2: ld returned 1 exit status
scons: *** [build/src/debug/linux/3.0/64/x86/gcc/libutility.so] Error 1
scons: building terminated because of errors.
which required me to install zlib1g-dev.

Thursday, January 5, 2012

Right-hand page opening for article class in LateX

So I like to use article documentclass for a variety of reasons, though mostly because I'm used to it. But what if you want your article to be formatted such that each new section opens on an odd (right-hand) page?

Looking around got me to this solution, in the preamble:

\documentclass[a4paper,12pt,twoside]{article}
twoside allows you to have different even and odd headers and margins.

\usepackage[bindingoffset=1cm,margin=2cm, includeheadfoot]{geometry}
 This sets up the margins such that there is a bigger margin to allow for binding.

\newcommand*\stdsection{}
\let\stdsection\section
\renewcommand*\section{%
\clearpage\ifodd\value{page}\else\mbox{}\clearpage\fi
\stdsection}
This does a clearpage whenever a section is on an even page. It works a treat and you can also use it for subsections etc. This does mean that your list of figures and tables also start on a new, odd, page, which is no great change, really.

hat-tip to: http://www.latex-community.org/forum/viewtopic.php?f=5&t=2813&start=0&st=0&sk=t&sd=a
UPDATE: If you don't want to have a section starting on a new page, then just put:
\begingroup
\let\clearpage\relax
[whatever you don't want on a new page]
\endgroup 

hanging at splash screen

So this morning I logged onto my computer only to find that it hung at the splash screen, particularly at the world/network icon. This was a red herring though, because if you left it long enough it said:
"No write access to /home/user/.ICEauthority" and then "could not start ksmserver". After trawling the internet, I came across this solution, which worked for me:
sudo chown group:user /home/user/.ICEauthority 
- where group is your group (for me that was the same name as my user) and user is your username.
Then run
sudo /etc/init.d/kdm restart 
and you should be back in business!

Tuesday, January 3, 2012

could not start process unable to create io-slave klauncher said unknown protocol 'file'

Started getting this error as a pop-up every 10 minutes or so after the recent update: "could not start process unable to create io-slave klauncher said unknown protocol 'file'" with the title of some of my google calendars.

At first I assumed it was a thunderbird problem because I had to delete those calendars from thunderbird because they had stopped working completely with a thunderbird upgrade. However, a quick check of my System Activity showed some akondai resources that when killed caused the same pop-up box to show up. Lo and behold, I had attempted to use akonadi to sync them once upon a time and on the recent update this had started working again. Deleted those from the resources list via Settings->Personal information->Akonadi and we are now annoying pop-up free.

Sunday, July 3, 2011

KPackageKit trouble

For some reason every week or so in Kubuntu I get this error in KPackageKit when I open it after I notice I am not having automatic updates:
The package list needs to be rebuilt.
This should have been done by the backend automatically.
Also, if you try to run apt-get you get:
E: Encountered a section with no Package: header

I am not quite certain why it happens yet, but the following fix works:
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update
Which I got from Ubuntu forums/

Sunday, April 10, 2011

nVidia screen flicker

So a couple of days ago I started to get a very annoying screen flicker in kubuntu. Every 30 seconds or go the screen would flash black and occasionally there would be a white line in between flashes or flashes of the screen. It could be stopped by alt-tabbing a couple of times. I gathered the problemw as with nVidia (I have a GT220) or something, so I went to nvidia-settings and turned PowerMizer to "Prefer Maximum Performance" from "Adaptive performance". I have the 260.19.06 drivers.

I haven't had a problem since.

Saturday, April 2, 2011

UQ soefile access

So this post is mac-related. So I have a several year old mac at home (PPC! running 10.4.11) and even with my University's VPN I still couldn't access myFiles using the network address that usually works locally on linux and windows on campus.
Normally the addresses are (works for both staff and students with a substitution of s1234567 with your my.UQ username):
All Campuses except Ipswich students - \\soefile\s1234567
Ipswich Campus students - \\uqistudent\s1234567
Gatton campus students - \\UQGfile\s1234567$
But that wouldn't work in the Go->Connect to Server Dialog. What does work (at least for St. Lucia, I'm not an Ipswich or Gatton student so I can't confirm it for those campuses) is:
smb://soefile.uq.edu.au/uqxxxxx or smb://soefile.uq.edu.au/s1234567

But you can't browse the "local" network that you are VPNed into for some peculiar reason. Also, you can then save that connection as a shortcut to your desktop by dragging the network icon and name from the top of the finder window to the desktop (or any folder for that matter), but for some reason not to the sidebar.

Monday, March 28, 2011

Flash-plugin

Finally updated to the new Chrome (10.0.648.204) a couple of days ago. KPackageKit had been trying for a while, but apparently not succeeding (not that there were any errors, just that every time I logged in it would say it still needed to update) which I assume is due to me having chrome being open at the time.

So the other day I update chrome and today I try to go to something with Flash. Uh-oh! Broken!
I tried to use reKonq, but that too is broken (I have all the konqueror plugins installed via kpackagekit)?

This indicates that probably something went wrong with flash and not Chrome and I just didn't notice.
I did this:
sudo dpkg-reconfigure flashplugin-installer
ta-da! works in everything now! I run 64-bit kubuntu, if it matters.

Wednesday, December 15, 2010

LateX, glossaries, first use and figures

If you use LateX like I do, then you might have tried the glossaries package. It's a bit of a bitch to set up, but once it is it's no more trouble than a bibliography and it'll save you a lot of time with standardising your acronyms. But I just spent the last 2 days pulling out my hair because it was behaving rather peculiarly.

The normal behaviour is thus:

You refer to an item in your glossary list
\newglossaryentry{LOL}{name={LOL},description={Laugh out loud.},first={Laugh Out Loud (LOL)}, firstplural= {Laugh Out Loud (LOLs)},text{LOL}}
and then reference it in text:
When I saw my mistake I did many \glspl{LOL}. People heard my \gls{LOL}.
which would turn out to be:
"When I saw my mistake I did many Laugh Out Loud (LOLs). People heard my LOL."
You run makeglossaries and voila you have a glossary and all of your terms are defined in text and expanded for their first use.

But instead I would get:
"When I saw my mistake I did many LOLs. People heard my LOL."

So, my first reference was never correct and was simply the acronym. First use never worked for any of the acronyms in any part of the document, but everything else was fine. Massive fail for glossaries, that's kind of what it needs to do. I made a minimal example and that worked fine, I tried copying in all of my document after this example and it worked find. But when I replaced my minimal example with my text and compiled, it never worked properly. I tried \glsresetall and resetting specific acronyms, nothing worked.

So what was it? My first acronym was in a figure caption - shift the figure to after another term was defined in-text and voila, problem solved.