Tuesday, December 4, 2012

How I got two-sided printing and scanning working on my brother MFC7860DW over wireless

the packages came from:

make sure the pre-reqs are installed:
sudo apt-get install ia32-libs
sudo aptitude install lib32stdc++ 
[I got an error with the stdc++ install with apt-get but it worked fine with aptitude ('Unable to correct problems, you have held broken packages')]

Download the debs from the brother  printer drivers page . For me, would not install through the software center (and according to the instructions you're meant to run it from the terminal), so I ran
sudo dpkg  -i  --force-all 'mfc7860dwlpr-2.1.0-1.i386.deb'
sudo dpkg  -i  --force-all 'cupswrapperMFC7860DW-2.0.4-2.i386.deb'

For network setup (for usb see this page)
go to:
in your browser
click MFC-7860DW and then from the dropdown menu under administration - "Modify Printer" and set following parameters*

Device: "LPD/LPR Host or Printer" or "AppSocket/HP JetDirect" (I selected "LPD/LPR Host or Printer")
URI: lpd://(Your printer's IP address)/binary_p1
note that your printer's IP address needs to be fixed in some way so that you can continue printing to it. I can fix IP addresses with my router so that's how I did it.

My device wasn't listed under drivers, and there's no available ppd so I just selected 7840DW Foomatic - note: when I selected the brother driver, I actually couldn't print two-sided, which is bizarre.

It added a device on localhost to my printers list at some point, but this one didn't work.

Still no booklet option, but it does now print two-sided.

First of all:
sudo apt-get install sane-utils xsane
Downloaded the debs from here. They installed with the software center, though you do have to click 'Ignore and install'.
scan-key-tool 64bit (or 32bit obviously if you're running 32 bit)
brscan4 64bit 

then in the terminal
brsaneconfig4 -a name=MFC-7860DW model=MFC-7860DW ip=
with the IP address you are using substituted at the end.

and then it worked fine for me with the default scanning application!

hat-tip to: http://ubuntuforums.org/archive/index.php/t-1854483.html

*if you get a password prompt, and you haven't set a password, then from the terminal:
sudo lppasswd -a
then you'll get a prompt asking you for a password. Your username is your current ubuntu username.

Saturday, December 1, 2012

davmail not starting

So, attempting to install davmail on pretty much a new install - ran the deb, tried to run it, didn't open but appeared to be running. Did have java installed (only have openjdk installed, unlike my other install where sunjava causes the problems with davmail), and when I ran it from the command line I get:
Exception in thread "SWT" java.lang.UnsatisfiedLinkError: Could not load SWT library.
Which led me to this bug report (under DavMail, even though it's a openjdk bug?), which solved it with:
sudo apt-get install libswt-cairo-gtk-3-jni
which worked a treat.

Monday, November 26, 2012

changing colour of citations in-text

So I had a figure where a certain colour represented data from a certain citation and I didn't want to put the name beside every single datapoint - it would be better in the figure legend. But I came across an issue - \textcolor{} just changes the text colour but the not the colour of the citation itself if you're using hyperref, so for instance:
shows up as
Smith (2011) 
which is not what I want. The easiest way to do it with hyperref is by using the citecolor of hypersetup:
shows up as:
Smith (2011) 
obviously, this is cumbersome, and that brackets are still black and you still need to revert the link colour back to black, so just create a newcommand:
This generates a citation in-text and then converts the colour set-up back to black each time. As the brackets would still be black, you have to use the textcolor command to change them as well.
So now I can just use:
to generate
Smith (2011) 

Saturday, November 24, 2012

glossaries entry too long

So I realised at some point that I had glossary entries that weren't showing up in my glossary, and were referencing back to pg. 1. The output from Kile was telling me:
[entry] has been referenced but does not exist 
which was weird because it was showing up in text with the right acronym so obviously it did exist! It wasn't a helpful error, but thankfully, some germans figured it out:
Zu Lang ist --> hier gibt eine kleinen Hack: 
\newcommand{\MeinZuLangerGlossarEintrag}{Super Langer Text, der einfach}
   name=Name des Modells im Singular,
   plural=Name des Modells im Plural,
   description={ \protect\MeinZuLangerGlossarEintrag
so basically, my glossary items it wasn't defining were because the description is too long (potentially the limit is 1024 characters). So you can either use \def\xxxxDescription of \newcommand{\xxxxDescription} and use that to define your description, and then use that in the glossary entry:
\def\wordDescription{This is a really long description}
\newglossaryentry{word}{name=word,description={\protect \wordDescription}
and clean your files and re-run makeglossaries and ta-da! 

Thursday, November 22, 2012

davmail crashing on startup

so, I finally updated davmail (4.1.0-2042 ) after it asking me to for literally years. But when it started up startup, it immediately crashed. At the same time, I got an error relating to the jre. A quick google got me to some information about how sometimes the open jdk is better than the sun java. So I checked which one I was running with:
sudo update-alternatives --config java
 which gives me:
There are 3 choices for the alternative java (providing /usr/bin/java).
  Selection    Path                                            Priority   Status
  0            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      auto mode
  *1            /usr/lib/jvm/java-6-sun/jre/bin/java             63        manual mode
 2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1051      manual mode
Press enter to keep the current choice[*], or type selection number:
I switched to  [2], and now it runs!

Saturday, November 17, 2012

upgrading to Windows 8 with less than 20GB free space.

Ok, so I got the upgrade to windows 8 for $15. My win 7 wasn't exactly working properly after flashing from the iso and I hadn't really used it anyway, just booted into it occasionally. So I downloaded the iso during the install and burnt it to a dvd. Would have thought that I could just proceed with the install on my 50GB partition for windows - wrong, you need at least 20GB free space on c:/. I had to set-up my partitions such that the windows partition was prior to the linux partition, and it wasn't possible to extend it without wiping the linux partition (which I didn't want to do).

So here's how I upgraded to Windows 8 with less than 20GB of free space (I started with 2GB). For this you will need to have chosen the option to install of a DVD and you will not be importing any of your old Windows 7 stuff during install. If you want to keep all of your applications and settings etc and import them, this is not the method for you. First of all, I got rid of hiberfil.sys which was taking up 6-8GB on my hard drive. If your pagefile is running off c:/ you can get rid of that too. All you need is 8.5GB free if you do the install straight off the DVD.

Boot onto the install DVD. During the install, choose the option that does not import any of your settings (the other option takes you back to windows and requires 20GB). I didn't need any of my applications or settings so this was fine for me. From here you can choose to install on any hard drive, however, as I'm upgrading, the installer fails on a hard drive that does not have Windows. Install onto your current Windows 7 partition. It backs up your old set-up as Windows.old, which you can delete to free up 20+GB when you're in Windows 8 later using disk cleanup. Though for some reason it still shows up on the windows splash screen as an option. Good one Windows.

Now for the Ubuntu part:
Now, to get grub back up and running (the Windows install deletes it). If you've got a reasonably new livecd around (new enough to have grub2 on it) then just boot onto that and follow these instructions:
First, open the Terminal.
Mount the partition you Ubuntu Installation is on. If you are not sure which it is, launch GParted (included in the Live CD) and find out. It is Usually a EXT4 Partition. Replace the XY with the drive letter, and partition number. Example: sudo mount/dev/sda5 /mnt. Then bind the directories, you need, like so:
sudo mount /dev/sdXY /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
Now we jump into that using chroot.
sudo chroot /mnt
Now install, check, and update grub. This time you only need to add the partition letter (usually a) to replace X. Example:grub-install /dev/sdagrub-install –recheck /dev/sda
grub-install /dev/sdX
grub-install --recheck /dev/sdX
Now you can exit you mounted hard disk, and unmount.
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt
and then sudo reboot

and then when you get back into ubuntu you're going to need to sudo update-grub to get your windows partition back, or alternately I guess you could mount it with your ubuntu drive earlier on the livecd, but that would require way more than a single command!

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:
$sudo make install
$sudo depmod
$sudo modprobe rts5229
And it works! You shouldn't need to reboot, mine worked straight away after modprobe.

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:
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:

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:
\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
This works fairly well, but the choice of fonts is limited.
For example:
\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.
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}

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:

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.

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:
[whatever you don't want on a new page]

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.