Archive

Monthly Archives: April 2013

This isn’t really a specific question, but I needed to make a bibliography in latex with the following requirements:

  • The citations take up as little space as possible, so should probably be superscript
  • The citations should be correctly grouped (i.e. 1-3, 6 not 6, 2, 3, 1)
  • The bibliography can take up any amount of space
  • The citations should be linked to their bibliography entry (i.e. hyperref compatible)
  • bib entries contain unicode characters
  • I want the entries to look like the Elsevier standard, though Nature is also fine
  • I want DOIs, properly displayed and hyperlinked, not monospaced

The style=nature option supplied to biblatex in the preamble (see http://ctan.org/pkg/biblatex-nature) achieves most of this but you don’t get DOIs, there seemed to be some problems with unicode characters (particularly Polish names, see http://www.terminally-incoherent.com/blog/reference/latex-reference/) and there were some problems displaying URLs well

Rather than trying to hack together a biblatex.cfg based on the nature style which I didn’t understand/couldn’t be bothered to read through I instead was able to use a standard biblatex style with some options when loading the package:

\usepackage[style=numeric-comp,
maxcitenames=2,
maxnames = 5,
firstinits=true,
uniquename=init,
sorting=none,
url=false,
isbn=false,
eprint=false,
texencoding=utf8,
bibencoding=utf8,
autocite=superscript,
backend=biber
]{biblatex}

This gets pretty close, but I also needed to use the following biblatex.cfg (create this file in the same directory as the .tex file):

% Number in parenthesis
\renewbibmacro*{volume+number+eid}{%
%  \setunit*{\addcomma\space}% NEW
  \printfield{volume}%
%  \setunit*{\adddot}% DELETED
%  \setunit*{\addcomma\space}% NEW
  \iffieldundef{number}
    {}
    {\bibopenparen
     \printfield{number}%
     \bibcloseparen}
  \setunit{\addcomma\space}%
  \printfield{eid}}

% Field formats for the bibliography environment (get rid of square brackets)
\DeclareFieldFormat{labelnumberwidth}{#1\adddot}

%Get rid of in:
\renewbibmacro{in:}{}

%Get rid of pp.
\DeclareFieldFormat[article,inproceedings,incollection]{pages}{#1}

%Make volume number emboldened
\DeclareFieldFormat[article,inproceedings,incollection]{volume}{\textbf{#1}}

%Journal name in non-italics
%\DeclareFieldFormat[article,inbook,incollection,inproceedings,patent,thesis,unpublished]{journaltitle}{#1}

%No quotes around article name
\DeclareFieldFormat
  [article,inbook,incollection,inproceedings,patent,thesis,unpublished]
  {title}{#1\isdot}

%Bibliography in smaller font size, and unjustified
\renewcommand{\bibfont}{\normalfont\small\raggedright}

%Hyperlinks in serif font
\def\UrlFont{\normalfont}

%DOI lower case, normal font
\renewcommand*{\mkbibacro}[1]{%
  \ifcsundef{\f@encoding/\f@family/\f@series/sc}
    {#1}
    {\MakeLowercase{#1}}}

%Colon after author names
\renewcommand{\labelnamepunct}{\addcolon\space}

Which got me what I wanted:

bibliography

Advertisements

Using chemfig I was able to represent DPPC (Dipalmitoylphosphatidylcholine) and other lipids in Latex by using the following code

\newcommand\setpolymerdelim[2]{\def\delimleft{#1}\def\delimright{#2}}
\def\makebraces[#1,#2]#3#4#5{%
\edef\delimhalfdim{\the\dimexpr(#1+#2)/2}%
\edef\delimvshift{\the\dimexpr(#1-#2)/2}%
\chemmove{%
\node[at=(#4),yshift=(\delimvshift)]
{$\left\delimleft\vrule height\delimhalfdim depth\delimhalfdim
width0pt\right.$};%
\node[at=(#5),yshift=(\delimvshift)]
{$\left.\vrule height\delimhalfdim depth\delimhalfdim
width0pt\right\delimright_{\rlap{$\scriptstyle#3$}}$};}}
\setpolymerdelim[]


\begin{figure}
\small
\setatomsep{1.5em}
\chemfig{N^+(-[:180,1.1]H_3C)(-[:90,1.3]CH_3)(-[:270,1.3]CH_3)(-[:-30]-[:30]-[:-30]O-[:30,1.3]P^+(<[:50,1.5]O\rlap{${}^-$})(<:[:130,1.5]O\rlap{${}^-$})(-#(1pt,)[:330,1.3]O-[:30]-[:-30](-[:270]O-[:-30](=[:270]O)(-[@{downleft,0.8}:30]CH_2-#(1pt,1pt)[@{downright,0.3}:-30,1.2]CH_3))(-[:30]-[:-30]O-[:30](=[:90]O)(-[@{upleft,0.8}:-30]CH_2-#(1pt,1pt)[@{upright,0.3}:30,1.2]CH_3))))}
\makebraces[10pt,13pt]{n}{downleft}{downright}
\makebraces[6pt,15pt]{n}{upleft}{upright}
\label{fig:lipids}
\end{figure}

The crucial line is:
\chemfig{N^+(-[:180,1.1]H_3C)(-[:90,1.3]CH_3)(-[:270,1.3]CH_3)(-[:-30]-[:30]-[:-30]O-[:30,1.3]P^+(<[:50,1.5]O\rlap{${}^-$})(<:[:130,1.5]O\rlap{${}^-$})(-#(1pt,)[:330,1.3]O-[:30]-[:-30](-[:270]O-[:-30](=[:270]O)(-[@{downleft,0.8}:30]CH_2-#(1pt,1pt)[@{downright,0.3}:-30,1.2]CH_3))(-[:30]-[:-30]O-[:30](=[:90]O)(-[@{upleft,0.8}:-30]CH_2-#(1pt,1pt)[@{upright,0.3}:30,1.2]CH_3))))}

You’ll also need to include the following in the preamble

\usepackage{chemfig}

Which produces something that looks like this:

Image

The new Android phones no longer work as USB mass storage devices, and instead use MTP. Not that I really know what this is, or its advantages over the previous system.

Fortunately a very helpful blog post at http://tacticalvim.wordpress.com/2012/12/08/mounting-nexus-4-via-mtp-in-fedora-17/ guided me most of the way (the nexus 4 and galaxy S3 are very similar)
I had to make a couple of changes as the device ids were different, but it’s essentially the same instructions so have a look there first

Firstly install simple-mtpfs:

sudo yum -y install fuse fuse-libs libmtp simple-mtpfs

Check it’s worked with:

ls -l /dev/libmtp*

Which should return a link between libmtp and somewhere in bus/usb. Then create /etc/udev/rules.d/99-galaxyS3.rules, with the following content:

ACTION!="add", GOTO="galaxyS3_rules_end"
ENV{MAJOR}!="?*", GOTO="galaxyS3_rules_end"
SUBSYSTEM=="usb", GOTO="galaxyS3_usb_rules"
GOTO="galaxyS3_rules_end"

LABEL="galaxyS3_usb_rules"

# Galaxy SIII I-9300
ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

LABEL="galaxyS3_rules_end"

Get the correct idVendor (VID) and idProduct (PID) by running simple-mtpfs -l

You can then set commands to mount and unmount by adding the following to your /.bashrc, where ~/mnt/galaxyS3 is the directory your phone’s storage will be mounted to:

alias S3mount="simple-mtpfs ~/mnt/galaxyS3"
alias S3umount="fusermount -u ~/mnt/galaxyS3"

The commands on the right of course can be used to mount and unmount

You’ll need to reboot to get it to work. I had to unplug and plug the phone too. troyengel reports on his tacticalvim blog that he had to run the S3mount command 2-3 times to get it to work

If you’re having trouble I’d recommend looking at the simple-mtpfs documentation