Wednesday, September 20, 2017

MATHS7000: Using WinEdt on UoM clusters


Creating a New Article


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. For a free (and in my opinion better) IDE I recommend TeXStudio which is available on all platforms (including Mac and Linux). The program should be available in the clusters but after a recent install it has stopped working.
In this short article I will outline how to open up your first LATEXfile and produce a pdf output. First select ”WinEdt” from the start menu by searching for the item.




Once you have clicked on the program you will be presented with an empty window. You now want to open a new document (NOT a new file), see below

After clicking on a new document you will be presented with a variety of different templates that can be used to create a new document. In this example we want to try the ”LaTeX:AMS Article”, since it comes with Maths and graphics packages preloaded.

After opening up your new document you will see a template document with stars (i.e. *) in the places where you should enter informations. Most of the commands are self explanatory, so put your title in square and curly brackets following \title, the author in the curly brackets following \author and so on. You can try filling in your own information or copy mine...

IMPORTANT:- Until you have saved your document it will not appear on the system and you will not be able to view the output. Click on the save button and you will be presented with the save dialog. You MUST save the file with the correct file ending, this means that you have to put “.tex” on the end of the filename, for instance I
use
myNewArticle.tex

in the picture below.

Once your file has been successfully saved you are ready to create a new pdf document by compiling your tex file. WinEdt has a button

that does this it has a little lightning strike in it! Once you have pressed the button a new document should appear on screen.








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.

Wednesday, September 29, 2010

School Of Maths - Thesis Template

The school of maths provides a class file and thesis template which can be found on the school website (restricted access):-
Templates

Open both files with the editor/IDE of your choice. Notice that the muthesis.cls contains information both about how the file works, and the required structure of your thesis. Build and view the file, you should have the beginnings of a thesis! In this short tutorial, we shall go through how to create a table, import graphics and use bibtex for your bibliography.

Tables

Your thesis is likely to include tables of one sort or another. A table in latex is a float, that means it can have a caption, a label, can appear in the table of contents, and will be placed by latex within the text in order to make the document look nice.

In order to create a table, we need to know about the tabular environment. An example of a simple tabular environment is:

\begin{tabular}{c|r}
1  &  2  \\
\hline
three  & four
\end{tabular}

and the output is:


The arguments after \begin{tabular} specifies the number of columns, the justification, and any vertical lines between columns. For instance writing {c||rrr} makes one centered column, two vertical lines followed by three right justified columns. Inside the environment individual cells are separated with an ampersand (&) and the row is ended with the end line command double backslash. We can use the command \hline to give a horizontal line.

Now to make a table, we must include the tabular environment inside the table environment. An example follows:
\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:
Including Graphics

In latex documents there are two ways to import graphics into your documents, depending on your required needs. If you are to be including technical plots, then encapsulated postscript graphics give the best looking results, and also allow latex to substitute text in your figures for typeset text. This can be particularly useful when you want equations or greek text in your figures. In order to use eps graphics and produce pdf's, you need to enable your IDE to run "LaTex -> DVI -> PS -> PDF". There are instructions on how to do this with kile or teXnicCenter elsewhere on this blog.

First let us try to import some simple graphics in png or jpg format. Go to the web and download a picture in jpg or png format, and save it in the same folder as your tex file. Now change your build profile to "LaTex => PDF", and include the following line after documentclass but before begin document:
\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.

Next we wish to make a figure. Like the table environment, a figure environment is a float, which means that latex will choose exactly where the figure will appear in the document, although you do have some control. Now try to place your picture inside a figure, with a caption and a label.
\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:
Notice that because I have included the figure in chapter 2, the reference number for the figure gives the chapter number then the position in that chapter. It is possible to change this behaviour if you wanted to.

EPS Graphics and PSFrag

Now let us give an example of including eps graphics. Remove any statements that reference any jpg or png pictures. Now download the eps example figure from my website:
http://www.maths.manchester.ac.uk/~pjohnson/Latex/Figures/
Include the following line after documentclass but before begin document:
\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:




Bibliography

You may wish to use bibtex to cite articles in your thesis. This is useful because it generates your bibliography automatically. To do this, create a new file called "myBibFile.bib" and save it in the same directory as your thesis file. Open the file and enter:

@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.

Tuesday, September 28, 2010

Texnic Center:- Latex -> Ps -> Pdf

To get TeXnicCenter to create pdf documents via ps files (required for psfrag, pstricks, eps graphics), you need to edit the profiles. From the main toolbar select "Build->Define Output Profiles...". Now select the profile "LaTex => PS", and press "copy", at the dialog change the name to "LaTex => PS => PDF".

Select the newly created profile, and click the tab "PostProcessor". Press the "new" button (a dashed square) to create a new postprocessor and call it ps2pdf. For the executable option, press the search box to the right and find the executable named ps2pdf on your system. You should find it in the directory
"C:\Program Files\MiKTeX 2.8\miktex\bin\ps2pdf"
or somewhere like that (depending on where program files are stored).

For the arguments box, enter
"%bm.ps"
including the quotes (very important).

Now select the "Viewer" tab. Under "Path of Executable" you can enter the path to adobe acrobat reader, if it is installed on your system and you can find it. On mine it is
"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32"

For the arguments box, enter
"%bm.pdf"
including the quotes (very important).


Now select the profile from the main toolbar, build from "Build->Current File->build", and view the file from "Build->View Output"


Installing MikTex and TexnicCenter on windows

This is a simple guide on how to install MikTex and TexnicCenter on windows machines to create beautiful typeset documents. First go to the MikTex homepage:
http://miktex.org/2.8/setup
and select to download the basic MikTex system.

Once the file has downloaded, run it and accept all of the default conditions. The program should begin installing...

Once MikTex is installed, we can move on to installing TeXnicCenter. Go to
http://www.texniccenter.org/
and download and run the installer. Again, just accept the default conditions.

Now when you start TeXnic for the first time you will be presented with setup wizard. In order for it to work you MUST tell texnic WHERE on your computer latex is installed.

Press on the box to search for the correct directory on your system. If you accepted the default settings on your MikTex installation the directory should be something like:
"C:\Program Files\MikTex 2.8\miktex\bin"
Once you have found the correct directory press next. It will not allow you to continue unless you have found the correct directory.

At the next screen you may choose a viewer for postscript files. You will need to install ghostscript if you want to view ps files. You can skip this step.

At the next screen you have the option to specify a pdf viewer. If you have adobe acrobat installed on your system you may choose it by searching for it. On my system I can find the executable at:
"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32"
Accept your settings and you should now be good to go! Open a new fie and try to compile and view the document.

If you need to convert to pdf via ps see the next turorial.


Tuesday, September 21, 2010

Using kile On School/Faculty Unix Machines

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

Monday, September 20, 2010

Unix - Changing Your Password

Logging in for the first time

At the login  screen there is a session menu that allows one to choose the desktop environment. Popular choices for the linux desktop are the 'gnome' or 'kde' desktop environments. If you are familiar with windows 'kde' probably offers an experience most similar to what you are used to. The university linux image has both available, there is not much difference between them (they both have the same set of applications available) but you might prefer the look and feel of one over the other.

Once you have chosen your favourite desktop environment, simply enter your username and password into the appropriate boxes.


Changing your default password

The first task you must complete in order to use the school unix system is to change your default password. The first task is to open a terminal. In the gnome environment (default) there should be a icon in the panel at the top or the bottom. Otherwise it can be found in the menu under 'system tools'.


Now you must enter the command to change your password into the terminal. Simply click onto the terminal and type 'passwd'. You will now be asked to enter your old password (for security reasons), followed by your new password twice. Do not worry if you do not see characters appearing as you type the passwords, they are not meant to appear! If you have entered your new password correctly you will see
 The NIS password has been changed on babbage.ma.man.ac.uk

If there have been any problems, such as the passwords not matching, you will be notified. Once you have changed your password why not try to set up your webpage? Follow the instructions here.

School of Mathematics - Making Your Webpage

Creating a simple webpage

The idea of this tutorial is to make a simple web page using the terminal and some simple unix commands (most of which could also be done through a GUI). You should at the end be able to post links to your academic works, photo's and other files. Since the school website (along many other websites) runs on unix, you will need to know something about unix filesystems to run your website. It is assumed that you have already logged into the the school unix system and changed your password.

Creating an "index.html" file

The first task is to create a folder in which to store your website files. Open a terminal, and enter the following command to create a folder:
mkdir public_html
Check that the folder has been created in the correct place, by entering the command
ls ~
The directory "public_html" should be listed on screen.

Next we need to create an "index.html" file for our webpage. This file will describe the main page of your website. Enter the following command into a terminal:
emacs ~/public_html/index.html

This will open an empty file that can be edited. Enter the following code into the editor:
<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/~username
and you should see something like the following...


See further posts for more about "html" and how to post links and images.

Making Your webpage - Part II

Simple html commands

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.

  • Line 1: <html> This basically tells the computer that what follows is an HTML file.
  • Line 2: <body> What follows is the main body of the text, i.e. not header or footer.
  • Line 3: <h1> My Webpage Works!!!</h1> Text enclosed inside h1 tags will be displayed as a title, appearing in a font much larger that normal text.
  • Line 5: <p> I can... </p> Text enclosed inside p tags shall denote a paragraph.
  • Line 7: </body> The main body of the text has finished.
  • Line 8: </html> The HTML file has finished. Ignore subsequent text.
Note that every time a <tag> is started, it must be finished with </tag>.

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.html
and 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/myPictures
mv ~/public_html/dog.jpg ~/public_html/myPictures
Now change the line containing the img tag to now be the path to the file. For my example it would be:
<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:

cd
cd public_html
cd myPictures
Then change the rwx access for 'other' users with the command:
chmod o-rwx dog.jpg
Reload 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.pdf
The '-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>