Thursday, September 24, 2015

Using TexStudio on UoM windows image

A Simple Latex File
Tex is a computer program that can typeset text and mathematical formulae. Latex is a markup language that uses tex as its typesetting engine. Basically this allows the user to embed commands within a text file that can be interpreted by latex to produce a high quality typeset documents. TexStudio is a cross-platform latex integrated development environment (IDE) for windows, OSX and linux that means that you can both edit text files and produce typeset documents all in one program. Best of all the program is free and available to download, click here for my guide on setting it up on Windows.

Click on the start menu at the bottom of the page and enter 'texstudio' in the search bar, then click on the application. Now select File->New from Template... and choose to create an article.
Now press the funny green arrow (the one to the left of the two green arrows) and this should build and open up a window to view your created document inside TeXstudio.
Now you're ready to go!

Thursday, June 11, 2015

School Of Maths - Thesis Template - getting started on TeXstudio

Here we are going to describe how to open up the thesis template on the School of Maths website and get it running on TeXstudio. First go the page on the School's website where the templates are held (click here).

Installing MiKTeX and TeXstudio on windows

In this blog we will introduce how to install MiKTeX and TeXstudio on windows. It is very easy! You just have to accept all the default conditions.

Go to the MiKTeX downloads page (click here) and select the basic installer.

Wednesday, October 30, 2013

Using bibtex for referencing

I am going to give a quick description of bibtex here, but there is already a good guide on bibtex available on the university pages here. Using bibtex is fast and easy way to keep track of referencing within a document. It uses a plain text file containing a database of all your references, each of which must be given a unique keyword. A bibtex database entry looks something like this:

@article{myFirstBibItem,
  title={The Paper Title},
  author={Joe Black and Mary White},
  journal={The Journal of Something},
  pages={1--2},
  year={2000}
}

The syntax is quite straight forward, the @keyword is used to indicate the type of entry, be it an article, a book or an entry in a conference proceedings. Next you give the entry a unique keyword so that you can cite the entry in the text. Then follows a list of items found in your reference, each separated by a comma. If you are having problems check that all items in the list have a comma following them as this is quite easy to forget. In fact you don't even need to know this as most websites (such as google scholar) give the option to export a citation in this format (see later on).

Now we shall start assuming you have a working tex document. Go to the menu and open a new file. Now go to the menu and select the save as option, making sure the directory is the same as where you have saved your tex document, then enter the name myBib.bib for the filename and BibTeX for the file type. Click save.

Now open google scholar in your web browser and click on the settings option in the top banner of the web page. You should now see an option near the bottom of the screen to Show links to import citations into. Select this option and make sure the bibtex option is selected. Save your settings.
Now enter a search for famous reference, such as "Black Scholes option pricing". Underneath the listed items you should now see a link on each item to Import into Bibtex, click on the link. You should now see something like
Copy and paste the text into your bibtex file and save it.

Now we can cite the reference in our text. Add the following line in your text

My first citation is \cite{black1973pricing}.
where the keyword is the same as the one in your bib file entry. Finally add the lines
\bibliographystyle{plain}
\bibliography{myBib}
at the end of your document. Run pdfLatex, bibtex (the button with a B on it in winedt) and then pdfLatex again two or three times. It should look something like this:
There are many different styles of referencing that can be used and it is very easy to switch between the different styles simply by changing the bibliographystyle command.

One package included in latex that can make your referencing very nice is the natbib package. To use this package instead of the standard one include the line

\usepackage{natbib}.
at the top of your document and change your style to
\bibliographystyle{dcu}
and recompile your document.
Now we get a reference list without the numbers and the name and year quoted in the text. The style of your bibliography is optional but I feel that this is much cleaner and neater.

Tuesday, October 29, 2013

Installing and Running Gnuplot on Ubuntu

Gnuplot is simple to install and use on Ubuntu systems as the latest version is included in the Ubuntu repositories. One part that is not included by default is auto complete at the gnuplot command line. In order to install gnuplot and enable auto complete, simply open a terminal, and type the following command

sudo apt-get install gnuplot rlwrap

UPDATE On Ubuntu 12.04 and later you need to specify what version of gnuplot to install (qt or x11), so change the command above to

sudo apt-get install gnuplot-qt rlwrap

Then open your bash configuration file (if using the default bash shell)

gedit ~/.bashrc &

and add the following lines to the file somewhere near the bottom

# enable autocomplete in gnuplot
alias gnuplot="rlwrap -a -c -b\"\\\"\\\"\\\'\\\'\" gnuplot"

save the file and exit.

First we need some data for plotting, for instance the file

http://www.maths.manchester.ac.uk/~pjohnson/Gnuplot/testResults.dat

may be downloaded from my website.

Now open a new terminal and type gnuplot into the command line. You should see the following:

Now enter the following:

p 'te

and press the tab key. The filename should auto complete. If it does not appear press the tab key again as there might be multiple files beginning `te', and you might need to enter more letters to allow it to complete. If it is still not working, enter !ls and check that the file is present in your current working directory. Complete the gnuplot command to plot the file with lines and press return

p 'testResults.dat' w l

If it all works you should see:

Tuesday, September 25, 2012

Introduction to Gnuplot

Simple Plotting with Gnuplot

Gnuplot is a powerful command line driven plotting program that is available for Windows, Mac and linux (and others). It is freely available to install and use. The application has two main features: it allows us to interactively plot mathematical functions and data at the command line; and also to create scripts that can analyse data or just create hundreds of figure plots simultaneously.

The big advantage for scientists is the ability to quickly review results from numerical calculations. Rather than waiting minutes to load up a spreadsheet program and create a plot results can be viewed almost instantly.

Please see other posts [1] for how to install and use on different operating systems. In this tutorial we shall use a terminal on the linux based Ubuntu DE to demonstrate the commands. The commands themselves are the same regardless of which operating system we work on. For a full list of commands and a more indepth look at the program you can find the official docs here

Gnuplot Official Guide (pdf)

Open a new terminal and type gnuplot into the command line. You should see the following:


Now enter the following command, press return

plot sin(x) with lines

and you should see


Inputting other functions is relatively simple, the syntax is similar to that found on other popular mathematical programs such as matlab. You can also store parameters, create functions and change them interactively, for instance enter the following code

a = 1.4
b = 0.13
f(x) = a * exp(-b*x*x)
plot f(x) with lines

which appears on screen as


Now we can add labels, change the distance between tics, the range/domain, and add rename the key with the following


set xlabel "x"
set ylabel "y"
set xtics 4
set ytics 0.25
set xrange [-8:8]
set yrange [0:1.5]
plot f(x) title "My Function" with lines


Try experimenting with different functions and changing the properties of the plot. Next try plotting 2D and 3D data from files in the post " Plotting 2D and 3D data with Gnuplot ".

Thursday, September 20, 2012

Using WinEdt on UoM windows image

A Simple Latex File
Tex is a computer program that can typeset text and mathematical formulae. Latex is a markup language that uses tex as its typesetting engine. Basically this allows the user to embed commands within a text file that can be interpreted by latex to produce a high quality typeset documents. WinEdt is a latex integrated development environment (IDE) for windows, that means that you can both edit text files and produce typeset documents all in one program, it is available to download for free but only on a trial basis.
Click on the start menu at the bottom of the page and enter 'winedt' in the search bar, then click on the application.
Once the program has opened, go the file menu and select new.
Now you must save the file before you start editing, so go to save as in the main menu, move to a directory in which you wish to save the document.
Call the file something like "test.tex" or "helloworld.tex", with the file ending ".tex".
Now we can start writing our latex file. Latex commands are always preceded by a backslash, there are predefined commands and the user may also specify their own. There is also a certain structure that must be adhered to. Two of the most common commands are \begin{} and \end{}, that signify the start and end of an environment. Like a good story all latex files need a start and an end, and the document environment signifies the start and end of a document, so all files require \begin{document} and \end{document}. The other requirement is some information about the structure of the document that you are creating. This information must be presented in the preamble (before \begin{document}) with the \documentclass{} command. There are certain default options that can be used, article is a popular choice. For the most simple of latex files enter the following text:
\documentclass{article}

\begin{document}
test
\end{document}
Once the "tex" has been written, it must be compiled in order to generate a file that can be printed or viewed on screen. A standard file type to convert to is pdf. There are lots of ways to generate a pdf, one is to go directly from the latex file to a pdf (using the pdflatex command) or and another is by converting from tex->dvi->ps->pdf.
Select the pdflatex option for the menu bar:
Click on the pdflatex button to compile the document, and now you should be able to view the pdf you have created by
clicking on the adobe acroread symbol in the menu bar.