Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Latex examples and instructions for the group project

Math Finance, and intro to option pricing

This document contains instructions on how to write in Latex specific things which you will need for your project.  I suggest you read it carefully, as it could save you lots of time.  To understand how things work, you need to read not just the resulting PDF, or the underlying .tex code, but to see both at the sametime.  Thus, you should copy-paste the contents of this file into an Overleaf Project, after opening this .tex file with any text editor. Alternatively, you can open and compile this file with you local Latex editor.

1    Debugging in Latex

First,  a word of advice regarding  compilation errors in Latex,  of which your completed project should contain none (or you will be penalised for them).  Latex compilers tend to be extremely bad at describing coding errors and telling you their location; sometimes all it takes is one unmatched brace (meaning { or }) for the compiler to tell you there are a Godzillion errors in your code. This makes it hard to catch errors.

The best approach then is to work on an editor which compiles automatically (sometimes this is called live Preview), so that you find out that there is an error almost immediately after introducing it, which makes it easy to catch.  This you can achieved using Overleaf, selecting the appropriate settings for the compilation.  To change such settings, first click on the down-facing arrow on the right of the green button on top of the page (on which it is written ‘Recompile ’). Then select:

1. Auto Compile: On

2.  Compile Mode: Fast [draft]

3.  Syntax Checks:  Check syntax before compile

4. compile error handling: Stop on first error

If you have an error somewhere and you cannot find it, the best way to catch it is to comment out parts of the code and then recompile:  if this time you get no errors, it means the lines you have not commented out contain no mistakes, so you can now try uncommenting a larger portion of your code and see what happens.

To easily comment (/uncomment) part of your code, you could simply write (/delete) % somewhere, which will affect the text that follows until the end of the paragraph. However, this approach is inconvenient if you need to handle several lines; if you want handle  quickly a group of lines, there are two ways:

1. select the lines in question and then click the appropriate shortcut on your computer (on MacOS it is CMD+/). This will automatically write (/delete) a % to the beginning of the first line of every new paragraph containing the selected lines

2.  write \begin{comment}text to be commented out\end{comment}

2    Questions

In your project you will create one exercise (a.k.a.  question), or maybe more.  To enumerate questions and answers, and to be able to either display or hide the solutions, please use the following syntax  (instead of the enumerate environment).   Please, when copy-pasting the paragraphs that follow, include also the code which I have left commented out (and leave it commented out).

1.  This is your first exercise. To break it up into parts, do not use the enumerate environ-ment: instead do this

(a)  question 1

(b) question 2

Important:  When you create your exercise with the \begin{questions} construct, please make sure to include the text \begin{defproblem}{}\begin{onlyproblem} and later the text \end{defproblem} commands (at the proper location), and to comment them out, and to include the long lines of % commands, exactly as I have done before.

2.  If you need create more than one exercise, just add another \question command like I did here

(a) First part

i. This is how you split up a part into subparts

ii.  Here the 2nd subpart

(b)  Second part

3    Multiple Choice Questions

To generate in Latex a MCQ environment, write this commands:

A.  a correct answer

B. is this one

C.  here a wrong answer

D. Notice that there can be multiple correct answers

If all answers are brief, you can use this command instead

A. yes     B.  no     C.  -01 exp(x)dx     D.  maybe

To add some vertical or horizontal empty spacing, you can use the commands \vspace , \hspace, like this

Make sure to randomise the order of the correct answer.

You will obviously need to add an MCQ environment after every question, so for example you ’d write:


1.  This is an exercise

(a)  question 1

A.  answer one

B. answer two

(b) question 2

A.  Y     B. N

4    Currency

To write currency symbols, do this:  $3, 3 and  £3.  If you want no number to follow the currency symbol, write $, and £ , do not just write $,and £because otherwise the spacing does not work properly.

5    Aligned text: systems of (in)equalities, matrices, ta- bles, linear programs

What to do if you want to easily write a good-looking (properly aligned) text, e.g. a ma- trix, array, set of (in)equalities, using Latex?   If you want to  display a system of linear (in)equalities, the simplest way is to write

where you have to be very careful with the spacing (e.g. write 4y+, do not write 4y+) This way does not work if on the right hand side you have several terms, e.g.

Here a more versatile way of writing aligned text:

notice how much more cumbersome it is to type things this way, however.

More versatile still, and just slightly more cumbersome, are tables.  To display the values taken by some random variables, it can be convenient to use a table, like this:

Notice how the commands c||r|r|l| and \hline determine the lines in the table, and the alignment (c = center, r = right, l = left).  Watch out, you will get an error if you do not specify enough columns, e.g. if above you wrote c||r|l| instead of c||r|r|l|. Tables also work very well to display linear programs, as follow


To quickly generate a different table of the size you want, you can use this website, and then copy-paste the resulting code in your tex file.