Creating a New Article
use
that does this it has a little lightning strike in it! Once you have pressed the button a new document should appear on screen.
File->New from Template... and choose to create an article.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 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: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.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:
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
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 ".
\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. \begin{tabular}{c|r}
1 & 2 \\
\hline
three & four
\end{tabular}
\begin{table} % start table environment
\begin{center} % center the table and caption
% build the table
\begin{tabular}{c|ccc}
& \multicolumn{3}{c}{Attendance at Course} \\
Week & MATH10121 & MATH10212 & MATH10222 \\
\hline
1 & 234 & 157 & 153 \\
2 & 223 & 167 & 148 \\
3 & 227 & 129 & 133 \\
4 & 236 & 134 & 113 \\
5 & 212 & 127 & 101
\end{tabular}
\caption{My table showing preparations times} % caption for the table (gives it a number)
\label{tab:myTable}
\end{center}
\end{table}
and the output is:\usepackage{graphicx}
Somewhere inside the document, maybe inside the introduction, include the line\includegraphics[width=0.5\textwidth]{filename.jpg}
Now build and view the file, the picture should appear in the document. If you are having problems check that you have the usepackage command in the right place, and that you have the correct build profile.\begin{figure} % start the figure environment
\begin{center} % center the graphics and caption
% include the graphics
\includegraphics[width=0.5\textwidth]{help-my-dogs-as-fat-as-me.jpg}
\caption{A fat dog} % caption for the picture
\label{fig:fatDog}
\end{center}
\end{figure}
the output from this is:\usepackage{psfrag}
and change your build profile to "Latex -> PS -> PDF". Now enter the following:\begin{figure} % start the figure environment
\begin{center} % center the graphics and caption
% setup psfrag
\psfrag{x}[][]{$\eta$}
\psfrag{y}[][]{$f(\eta)$}
\psfrag{f(x)=sin(x)/x}[][]{$f(\eta) = \frac{\sin(\eta)}{\eta}$}
% include the graphics
\includegraphics[width=0.75\textwidth]{example-figure.eps}
\caption{A figure using psfrag.} % caption for the picture
\label{fig:sinxoverx}
\end{center}
\end{figure} and the output is:@article{einstein1935can,
title={{Can quantum-mechanical description of physical reality be considered complete?}},
author={Einstein, A. and Podolsky, B. and Rosen, N. and others},
journal={Physical review},
volume={47},
number={10},
pages={777--780},
year={1935},
publisher={APS}
}
Note that from google scholar you can set it up to import citations into bibtex format. Here einstein1935can is the reference keyword for this citation. First place the following underneath your package list: \bibliographystyle{plain}
and then edit the part for the bibliography to read \bibliography{myBibFile}
%
% \begin{thebibliography}{999}
% \bibitem{ANO} A.N.~Other, ....
% \end{thebibliography}
This should enable the bib file in your document. Now you just need to cite the text so that it will be included in your text: Einstein showed in his paper \cite{einstein1935can} that ...
You can add as many reference as you like to your bib file, only those that are referenced within the text of your thesis will show up in the bibliography.
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. Kile is a latex integrated development environment (IDE), that means that you can both edit text files and produce typeset documents all in one program, it is available for free as part of any linux distribution. As it is written in Qt it is also available on windows. The interface is similar to that found on windows based IDEs, so learning latex on unix should be the same as learning it on windows.
Open up the program 'kile' from the menu bar. If you cannot find it open a terminal and type 'kile' followed by a return carriage. Once the program has opened, go the file menu and select new. At first select empty document, you can try using the wizard or standard templates at a later date.
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}
Some text...
\end{document}
and then save the file in a new directory. Call the file something like "test.tex", with the file ending ".tex".
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 at least 2 ways to generate a pdf, one is to go directly from the latex file to a pdf (using the latexpdf command) or and another is by converting from tex->dvi->ps->pdf. Obviously the second method sounds more cumbersome but if you want to use packages such as pstricks or psfrag to make your document look nice you must use the second method. Luckily kile has a "QuickBuild" option that can run multiple latex commands in one go. Go to Settings->Configure kile and select Tools->Build->QuickBuild, then select Latex->DVItoPS->PStoPDF->ViewPDF from the configuration options. You may need to change the configuration of ViewPDF to acroread.
Now press quick build to preview your latex document...
The NIS password has been changed on babbage.ma.man.ac.uk
mkdir public_htmlCheck that the folder has been created in the correct place, by entering the command
ls ~The directory "public_html" should be listed on screen.
emacs ~/public_html/index.html
<html> <body> <h1> My webpage works!!! </h1> <p> I can hardly believe it!?!</p> </body> </html>Save the file and exit. Now open a web browser and enter the following address into the navigation bar (adjusting username for your unix username):
http://www.maths.manchester.ac.uk/~usernameand you should see something like the following...
HTML, or HyperText Markup Language, is the language used on the web. It is a markup language, which basically means that the structure and appearance of a page can be encoded into a simple text file using tags (text surrounded by angle brackets). These tags may take the form of simple commands such as 'put a hyper link here', or 'put an image here', but can also be used to call scripting languages such as javascript. In this tutorial we shall just go the most basic commands, those for hyper links and images, and general structure of a web page.
Previous example
In the last entry we went through setting up a simple index file for your website. But what did each of the parts mean? Let us look through each line in turn.
Another Web Page
The 'index.html' page is used as the default page for a website. You can have as many separate webpages as you like inside your website, as long as you can present links to them!
Open a terminal and enter the following:
emacs ~/public_html/anotherpage.htmland copy the HTML code from the index.html file across to this new file. Edit it slightly so that you can tell it is different from the original, then save and exit.
Now reopen the original index.html file. Add the following line within the body of the text:
<a href="anotherpage"> Link to another page </a>
Reload your webpage and the link should appear underlined. Check that it is working.
Upload An Image
Now we may want to include a picture on our website. First we need to get a picture, then we need to place it somewhere that the world wide web can find it. Download a picture off the web, and save it to your hard disk. Locate the file and copy it to the public_html directory. Reopen the original index.html file and add the following line within the body of the text (changing for the appropriate file name, my example is 'dog.jpg')
<img src="dog.jpg" class="picture">Reload your webpage and the image should appear.
Using Directories
You can also use directories to store files inside your web space. Try making a directory and store the your picture inside it using the terminal.
mkdir ~/public_html/myPicturesNow change the line containing the img tag to now be the path to the file. For my example it would be:
mv ~/public_html/dog.jpg ~/public_html/myPictures
<img src="myPictures/dog.jpg" class="picture">Reload your webpage and check the image still appears. If you have lot's of directories and files things can get confusing since the src must define the path from your current directory to the directory containing the file. One way to circumvent this is to use the absolute path, much in the same way all of the terminal commands use ~/pathToFile so that they work regardless of your current directory. For my example on my website I would enter:
<img src="http://www.maths.manchester.ac.uk/~pjohnson/myPictures/dog.jpg" class="picture">
Restricting Access
As discussed in the lecture the unix filesystem provides a restrictions on the access of a file. Any file placed inside your public_html directory shall be open for the general public to view by default. The way to restrict access is by changing the file permissions. Try restricting access to the picture that you have created. First, from the terminal, navigate to the directory containing your picture. The commands will look like:
cdThen change the rwx access for 'other' users with the command:
cd public_html
cd myPictures
chmod o-rwx dog.jpgReload your webpage and check the image should not load anymore. You may need to reload the page to refresh the cache. See if you can use the terminal to restore access to the file.
Using Dynamic Links
There may be instances where you want not to copy a file into your webspace, but access a file from somewhere else on your system. Rather than having multiple copies of the same file, we can get round this by using dynamic links (much like shortcuts on windows) to 'point' to a file in a different directory. Say I have a presentation file pres.pdf in the directory /home/pjohnson/presentations/pres.pdf. I want the latest version available on the web, and I will be updating the file regularly so don't want to copy it. I can create a 'link' to the file using the command:
ln -s ~/presentations/pres.pdf ~/public_html/pres.pdfThe '-s' denotes a soft link. This means that because it is not a copy, nor is it a hard link, deleting the link will not delete the original file. Download a presentation off my website and store it on your filesystem. Create a link to the file in your public_html directory and create a hyper reference to the file on your webpage. PDF files can be linked using the code:
<a href="pres.pdf" class="pdf">A Presentation</a>