Saturday, October 13, 2012

sd card reader on lenovo e430

This may no longer work with the new 3.5 kernel or 12.1 ubuntu... see UPDATE: below.
-----
So my sd card reader wasn't working out of the box with my Lenovo e430 and Ubuntu (currently 12.04 Precise). I googled a bit and found this blog post, which finds out the device name using lspci (RealTek 5229), references this archwiki article on the Lenovo E430, which gets you to this driver page on the RealTek website, so that finally you can extract the drivers and run (corrected type in the final line of the original blog post:
$make
$sudo make install
$sudo depmod
$sudo modprobe rts5229
And it works! You shouldn't need to reboot, mine worked straight away after modprobe.

UPDATE:
This just stopped working (maybe because of kernel upgrade? I'm now on the 3.5 kernel, 12.10 Quantal), modprobe retuning this error:
FATAL: Module rts5229 not found.
I found this thread, where a user had had the same problem, and they linked to a ppa for lenovo fixes! I added it to my software sources, sudo apt-get update and then sudo apt-get install rts-5229-dkms. It still didn't work when I plugged it in, but sudo modprobe rts5229 worked straight away.So in short:
sudo add-apt-repository ppa:jamesf/lenovofixessudo apt-get updatesudo apt-get install rts-5229-dkmssudo modprobe rts5229
should solve this problem, at this time...  

Saturday, September 22, 2012

redefining underscore in math mode to use rm font

So I use a lot of subscripts, and it annoyed me that they were in italics! I didn't want to call \textrm{} every time in math mode, and there had to be a better way!
I found this stackexchange post which described exactly what I wanted to do and this was their solution:
\catcode`_=\active
\newcommand_[1]{\ensuremath{\sb{\mathrm{#1}}}}
Unfortunately that redefines _ for ALL uses of it, including in file names etc. I had a lot of file names and folder that used that character, so that wasn't an option. Some more searching and I found:
\documentclass{article}
\usepackage{amsmath}

\let\sub_
\catcode`\_=12
\begingroup
\catcode`\_=\active
\gdef_#1{\sub{\text{#1}}}
\endgroup
\begin{document}
Which worked a charm! Now all my subscripts are automatically in roman font!


Friday, August 31, 2012

san serif math fonts

So I switched formatting in my thesis to a san serif font because I prefer it and my figures all had san serif fonts in them already and I wanted them to match so... but I have some equations and lots of in-text symbols, superscripts and subscripts using math mode and when I switched to san serif they stayed serif, unless I used \text{} in math mode.
 I stumbled upon this post in stack exchange:
Some (partial) solutions I found:
  • Use fontspec to change the math font
Like this:
\setmathrm{Arial}
\setmathsf{Arial}
\setmathtt{Arial}
\setboldmathrm[BoldFont={Optima ExtraBlack}]{Optima Bold}
However this does not change the italic math font for some reason (and there does not seem to be an option to do this(?)).
  • Use sfmath, which comes with a couple of pre-packaged fonts
\usepackage[cm]{sfmath}
\usepackage{cmbright}
This works fairly well, but the choice of fonts is limited.
For example:
\usepackage{unicode-math}
%\usepackage[math-style=ISO]{unicode-math}
\setmainfont{XITS}
\setmathfont{XITS Math}
%\setmathfont[range=\mathit/{latin,Latin}]{Adobe Garamond Pro}
Although this has the problem that \setmathfont{} gives a bug when used in combination withamsmath...
fontspec required more effort than the one minute I really wanted to spend on it. sfmath didn't work for me??? and cmbright worked first go with just \usepackage{cmbright}. Font blends well with my current (supposedly Arial) san serif font. 

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.
\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/