# Making your own e-book from websites using Grabmybooks

Added: 30th October 2013: The failure of the LaTeX rendering mentioned below is because I have been using the mark-up $$Latex code$$ instead of using the tags  $Latex code$ .

Yesterday I came across Grabmybooks, a free Firefox plugin that enables the webuser to create ebooks from webpages.

The resulting output is a .epub file which should be useable on most e-readers (This can be converted to .mobi to use on a kindle).

As an experiment I attempted to covert the statistics for humanities website into an ebook. I was very impressed with the plugins rendering of text and tables. The images have not come out that well, but its main drawback from my point of view is that is doesn’t seem to cope with the more complex math code very well, which limits its use ‘out of the box’ for my purposes. However for purely text conversion it is excellent.

It is possible to edit the hard code whilst putting the e-book together. I haven’t tried this out yet.

Conversion to text and tables works well

Varying success with images, but these have undergone numerous conversions and reformatting over the past few months.

The conversion from the LaTex plugin in Mediawiki has not worked out.

# The Joy of LaTeX

Over the past year I discovered LaTeX.

As in latex gloves?

No. It’s pronounced “Lah-tech” or “Lay-tech”. For the uninitiated LaTeX is a programming language used to produce documents. It can be used for books, articles, posters, presentation and many more things.

So a bit like Word then?

Nothing like word or any other word processing programming. Word processing programmes are great when you have nothing but text. However, I’m sure that everyone has experienced the annoyance of trying to put an image into a word document then finding it disappears onto another page or behind your text. Word and similar programmes are “What you see to what you get” (WYWISYG). LaTeX is “What you mean is what you get”.

Anscombe’s quartet: Output in LaTeX

What do you mean?

Clip from the LaTeX file for my book.

If in Word I want to put an image 2.54cm from the right hand edge of the paper and 5.53cm from the top I may succeed to start with. However, once I add another image or some text there is no knowing whether it will stay there or not. In LaTeX it will stay exactly where I told it to.

Who should use LaTeX?

The great thing about LaTeX is that you can add packages to the basic installation. Packages can deal with mathematics, make graphs, posters, define colours, make books. If you use equations, graphs etc. you may find it worthwhile. also great for phonetics, ancient languages and languages using less commonly used alphabets.

Sounds a bit complicated…

Yes it is. I had a few false starts. There is quite a good introduction on wikibooks. At some point I plan to write a very basic introduction myself. The LaTeX project page is also a good place to start.

So everyone loves it then?

No, but I think its beautiful.

Show me an example.

See my online statistics book (preview).

How much does it cost?

Nothing

# Why you should graph data

Click to enlarge

I came across Anscombe’s Quartet on Wikipedia recently. I must confess to not having seen it before and don’t recall seeing it in any introductory statistics books.

The Anscombe’s Quartet is a conceptually and graphically clear way of showing the importance of graphs in statistical analysis. Each of the 11 pairs of observations have the same, x mean, y mean, x variance, y variance, correlation co-efficient and regression equation, though each have very different distributions. They clearly demonstrate the impact of outliers and how non-linear relationships can be identified.

Citation:

F. J. Anscombe (1973) Graphs in Statistical Analysis The American Statistician , Vol. 27, No. 1 (Feb., 1973), pp. 17-21

Article Stable URL: http://www.jstor.org/stable/2682899 (Not open access)

LaTeX code below.

documentclass{article}
usepackage{pgfplots}
usepackage{pgfplotstable}
pgfplotsset{compat=1.7}
usepackage{amssymb, amsmath}
usepackage{subcaption}
begin{document}
begin{figure}
caption{Anscombe's quartet is a good demonstration why a scatterplot is so valuable, prior to calculating regression equations and correlation co-efficients. In all four cases the $x's$ have a mean of 9, and variance of 11. The mean of all the $y's$ is 7.5, and a variance 4.125. The correlation co-efficient of each is 0.816 and the linear regression line is $y=3+0.5x$}
begin{subfigure}{.45textwidth}
centering
caption{Normal linear relationship}
begin{tikzpicture}
begin{axis} [width=5cm, height=5cm, xlabel=X1, ylabel=Y1]
addplot[scatter, only marks, mark=x, mark size=4pt]
coordinates
{
(10, 8.04)
(8.0, 6.95)
(13, 7.58)
(9, 8.81)
(11, 8.33)
(14, 9.96)
(6, 7.24)
(4, 4.26)
(12, 10.84)
(7, 4.82)
(5, 5.68)
};
coordinates
{
(0, 4.1)
(20, 12.5)
};
end{axis}
end{tikzpicture}
end{subfigure}
begin{subfigure}{.45textwidth}
centering
caption{Relationship clear, but not linear}
begin{tikzpicture}
begin{axis}[width=5cm, height=5cm, xlabel=X2, ylabel=Y2]
addplot[scatter, only marks, mark=x, mark size=4pt]
coordinates
{
(10, 9.14)
(8.0, 8.14)
(13, 8.74)
(9, 8.77)
(11, 9.26)
(14, 8.10)
(6, 6.13)
(4, 3.1)
(12, 9.13)
(7, 7.26)
(5, 4.74)
};
coordinates
{
(0, 4.1)
(20, 12.5)
};
end{axis}
end{tikzpicture}
end{subfigure}
\
begin{subfigure}{.45textwidth}
centering
caption{Clear linear relationship, but one outlier offsets the regression line}
begin{tikzpicture}
begin{axis} [width=5cm, height=5cm, xlabel=X3, ylabel=Y3]
addplot[scatter, only marks, mark=x, mark size=4pt]
coordinates
{
(10, 7.46)
(8.0, 6.77)
(13, 12.74)
(9, 7.11)
(11, 7.81)
(14, 8.84)
(6, 6.08)
(4, 5.39)
(12, 8.15)
(7, 6.42)
(5, 5.73)
};
coordinates
{
(0, 4.1)
(20, 12.5)
};
end{axis}
end{tikzpicture}
end{subfigure}
begin{subfigure}{.45textwidth}
centering
caption{Clear relationship, but one outlier puts the regression line at 45 degrees to the other 10 observations}
begin{tikzpicture}
begin{axis} [width=5cm, height=5cm, xlabel=X4, ylabel=Y4]
addplot[scatter, only marks, mark=x, mark size=4pt]
coordinates
{
(8, 6.58)
(8.0, 5.76)
(8, 7.71)
(8, 8.84)
(8, 7.04)
(8, 5.26)
(19, 12.5)
(8, 5.56)
(8, 7.91)
(8, 6.89)
(8, 6.89)
};
coordinates
{
(0, 4.1)
(20, 12.5)
};
end{axis}
end{tikzpicture}
end{subfigure}
end{figure}
end{document}


# Normal distribution curve in LaTeX

I have been searching the internet on how to produce a normal distribution curve in LaTeX with the standard deviations marked. I wasn’t able to find exactly what I wanted, but got some good clues here.  This code uses the pgfplots package. The code should work ‘as is’.

documentclass{article}

usepackage{pgfplots}
usepackage{pgfplotstable}
usepackage{amssymb, amsmath}
pgfplotsset{compat=1.7}

begin{document}pgfmathdeclarefunction{gauss}{2}{%
pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
begin{figure}
centering
caption{The normal distribution}
begin{tikzpicture}
begin{axis}[
no markers, domain=0:10, samples=100,
axis lines*=left, xlabel=Standard deviations, ylabel=Frequency,,
height=6cm, width=10cm,
xtick={-3, -2, -1, 0, 1, 2, 3}, ytick=empty,
enlargelimits=false, clip=false, axis on top,
grid = major
]
addplot [fill=cyan!20, draw=none, domain=-3:3] {gauss(0,1)} closedcycle;
addplot [fill=orange!20, draw=none, domain=-3:-2] {gauss(0,1)} closedcycle;
addplot [fill=orange!20, draw=none, domain=2:3] {gauss(0,1)} closedcycle;
addplot [fill=blue!20, draw=none, domain=-2:-1] {gauss(0,1)} closedcycle;
addplot [fill=blue!20, draw=none, domain=1:2] {gauss(0,1)} closedcycle;
node[coordinate, pin={68.2%}] at (axis cs: 0, 0.4){};
node[coordinate, pin={95%}] at (axis cs: 0, 0.3){};
node[coordinate, pin={99.7%}] at (axis cs: 0, 0.2){};
node[coordinate, pin={34.1%}] at (axis cs: -0.5, 0){};
node[coordinate, pin={34.1%}] at (axis cs: 0.5, 0){};
node[coordinate, pin={13.6%}] at (axis cs: 1.5, 0){};
node[coordinate, pin={13.6%}] at (axis cs: -1.5, 0){};
node[coordinate, pin={2.1%}] at (axis cs: 2.5, 0){};
node[coordinate, pin={2.1%}] at (axis cs: -2.5, 0){};
end{axis}
end{tikzpicture}
end{figure}

end{document}


# Debut Volume 3, number 2 in preparation

Just putting the finishing touches to the latest edition of Début.Making use of my new LaTeX skills here.

Contents

 Guest Editorial: Lessons I Have Learnt from Writing and Publishing in Début 83 Vlad Mackevic Uptalk in Context 85 Emily Moline Replicating Oliphant’s Saussurean Simulations 101 Richard Littauer Instructions for authors 119

# Using pgfplot LaTeX package for basic dotplots.

I wanted to produce a basic dotplot using the LaTeX pgfplot package. I looked for guidance in the extensive manual but didn’t find what I wanted (that is not to say it’s not there). I managed to find a workaround, which I have shared here. The results are not perfect, but will do for now.

This is the table containing my data:

 Subject Marks out of ten Mean Average Median average French 2, 4, 5, 7, 7 5 5 Religious Studies 0, 5, 10, 7, 3 5 5 History 5, 5, 4, 6, 5 5 5

I used the scatterplot as the basis for the dotplot and worked out this code.

I did three of these. Here are the results. Not too bad.

begin{document}
usepackage{pgfplot}
begin{figure}
centering
caption{Dotplot: French}
begin{tikzpicture}
begin{axis}[height=4cm,
xlabel=Marks out of ten,
ylabel={},%no label for the y axis
yticklabels={},%no numbers displayed on the y
ymin=0,
ymax=10,
xline,
xmin=0, %sets the minimum of the x axis
xmax=10, %sets the max of the x axis.
%As the test was out of ten I have set max to 10.
]
scatter src=explicit symbolic]
coordinates
{
(2,0) %the first number is the marks out of ten (the x axis).
% Use 0 for the y axis until the second occurrence.
(4,0)
(5,0)
(7,0)
(7,1) %the second number here is 1 because we have already used 7,0.
%This is because 2 people got 7 out of 10.
};
end{axis}
end{tikzpicture}
end{figure}
end{document}


# Converting tables from Excel 2010 to LaTeX using excel2latex add-in

Orginal Excel 2010 table

Building all but the simplest tables in LaTeX is not a particularly intuitive process. I’ve just been trying out the Excel2Latex add-in for converting tables from Excel (2010) into LaTeX. I eventually got it to work, but it look a lot of on-line detective work to work it all out. It appears that it was easier to use in Excel 2003.

1. First of all you need to download the add in file  The file has the extension .xla
2. It will tell you to open the file in excel. When I tried to open the file in Excel nothing happened, but the file got saved under username/temp rather than in username/downloads. (as I was opening it up online).
3. In early versions of excel this might have been enough and the Excel2Latex add-in would appear under the tools menu. This was not the case in Excel 2010.
4. I then opened Excel and clocked on “File”, then “Options”.
5. I then selected Add-ins from the left hand side.
6. A list of available Add-ins came up, but Excel2Latex did not appear.
7. At the bottom of the dialogue box you should find the word ‘Manage’. Select Add-ins from the drop down menu and click ‘Go’
8. A list of available add-ins will appear. If Excel2Latex is there select it, but in my case it was not there. If this is the case click ‘Browse’ and find the file excel2Latex.xla. Select it and it should be added to your list of add-ins.
9. Now close Excel down.
10. When excel is re-opened a new heading will appear at the top of the Excel window labelled ‘add-ins’ . Click on this menu item and you should see two new buttons. “Convert table to LaTeX” and “Convert all stored tables to LaTeX”.
11. Open up an excel file (if you have not already done so) and Click on “add-ins”, then “Convert table to LaTeX”.
12. Excel will then generate the LaTeX code for your table.
13. Export or copy+paste into your usual .tex/ LaTeX editor

Code pasted into my LaTeX editor

14. The final result in my .pdf file! Looks nice I think.

PDF screenshot

Notes

Excel2latex can cope with formats such as italic and bold,but not colour at present.

# Displaying equations online without using images

This is an “additional information” page I have written for the forthcoming humanities statistics resource. I was going to use images, but was unsatisfied with the results. This solution took me a while to work out, but I thought I would share it here as well.

1. The easiest way to display an equation online is to use an image. If you create your equation in MS Word or Open Office you can use the snipping tool (In Windows 7) to make it into an image for website display.

2. The better (though much harder) way is to use LaTeX Math and it  requires some web development knowledge. This is not a comprehensive guide, but hopefully provides a good starting point.

LaTeX is used for preparing academic articles, mainly in the sciences. LaTeX is actually a language which can be understood with practice. If you plan to use a lot of equations online is probably worth investing some time in becoming familiar with LaTeX.

For example The LaTeX code for the correlation co-efficient is:

r=frac{{1}/{n}{(x_1-bar{x})(y_1-bar{y})+(x_2-bar{x})(y_2-bar{y}) ... + .... (x_n-bar{x})(y_n-bar{y})}}{SD_x SD_y}


Which rendered in LaTeX produces:

[ r=frac{{1}/{n}{(x_1-bar{x})(y_1-bar{y})+(x_2-bar{x})(y_2-bar{y}) ... + .... (x_n-bar{x})(y_n-bar{y})}}{SD_x SD_y}].

LaTeX looks complicated, but is actually surprising logical once you start to get the hang of it. A number of free open source LaTeX editors are available and the results can be exported into .pdf format. However, the editors are not needed when displaying equations online.

Unfortunately understanding LaTeX is not the only necessary step to publishing equations online. LaTeX is not html and will not work on a website without additional plugins.* The statistics website I am developing is built in Drupal and uses the add-on module MathJax to render the LaTeX online. It can be also used in WordPress (which I am using for this blog) and a variety of other applications.  See the MathJax, Drupal or WordPress websites to find details of the installation process. *[Added 23/10/2012] I’ve since learnt that wordpress.com supports LaTeX natively, but I have not checked this.

Short Math Guide for LaTex by Michael Downes (American Mathematical society website).

Mathjax

Mathjax drupal module

Mathjax WordPress.org plugin

As life would have it MathJax seems to have stopped working on my Drupal site. (It worked fine a couple of days back)  However, this code at the top of any page where you wish to use LaTex does seem to be working now.

I am grateful to the author of this website  for the code to place on the page.

<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js" type="text/javascript">
MathJax.Hub.Config({
extensions: ["tex2jax.js","TeX/AmsMath.js","TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["$$","$$"] ],
displayMath: [ ['$$','$$'], ["$","$"] ],
processEscapes: true,
},
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script>

# The expanding ‘middle space’ between technological innovation and innovation in using technology

The expanding ‘middle space’ between technological innovation and innovation in using technology.
Part of my learning journey over the past year has been learning Drupal and WordPress.org. A couple of years ago one of my web developer colleagues showed me a cartoon of the Drupal learning curve. The Drupal learning ‘curve’ is actually a cliff-face which is shown to claim many victims. Images of crosses and a runaway train have the potential to destroy even skilled and experienced developers. I understand that Drupal 7 is somewhat more user-friendly than its predecessor versions, but nevertheless there have been some false starts and issues continue to arise from time to time.

That said I consider myself something of a ‘Route 1′ learner. I learn what I want to know in order to achieve a specific outcome. I am actually proud of the fact I managed to build YazikOpen in my own time using Drupal. It wasn’t that I set out to use Drupal from the beginning but attempts to use Joomla and WordPress (which I use for this blog) were unsuccessful. Most importantly an add-on biblio module is available in Drupal. It is this module which forms the backbone of my site.
I am not a web developer, at least not a professional one. Developing a website is not without its problems, but there is enormous potential for non-specialists to innovate in web development.

This innovation does not relate to the software itself, but the way it is used. Innovation is much about the content itself of course, but Drupal offers a half-way house between developing new software and applications on one hand and making innovative use of new technologies on the other.

Put simply Drupal is made up of two types of modules: core modules, the majority of which need to be activated to build any sort of website and optional modules which are being developed all the time. If there is anything you would like a website to do, the chances are that a module is available. This gives the opportunity for people like me who know little about programming build websites in ways that would have been very difficult for even the most talented web developers a few years ago. You might say that you can use the same pile of bricks in different ways to build a garden wall, a house or a cathedral. Behind the scenes it is unlikely that any two Drupal-built websites are the same.

Of course we will always need web developers, web designers and software developers of course and innovations in these areas will not stop. Just because we amateurs can do something does not always mean we should. Just because I can get something work does not mean I have found the best way to make it work.  It is ideal to have a website which looks good and is easy to navigate, though on some occasions this is more important than others. There is also the small matter of online security.

However I see a number of opportunities for see for those interested in this expanding ‘middle space’.

• When I started to build YazikOpen I knew more or less what I wanted to achieve. Through learning online and buying a book or two I have more or less got where I what to go.
• As an individual I have a high level of control over the technology as well as the content. If things are not working or I find a way to make it work better I can change things at the first point of convenience. I don’t need to wait until another person’s time becomes available and I don’t have to explain to other what I want to do.
• I am currently putting together a website introducing humanities students to statistics. One of the technical challenges I have overcome is rendering LaTaX online* for the equations. I am able to make sure both the maths and appearance are working out.
• Drupal, and many other packages are open source and free to the use. Premium services are available, but I don’t have to spend any money just to try something out.
• Following on from above, if I want to buy a premium professional theme I can.
• There is a strong online community of support for those new to Drupal, as well as more experienced developers.
• New modules are being developed all the time. Although I don’t have the skills to build my own modules (at least not yet), finding another person asking the same question is only a google search away. And usually there is a module which can achieve it.

* I have written a section on this for the statistics website which I will make available on here as well.