Page 1 of 2 12 LastLast
Results 1 to 25 of 50
Like Tree7Likes

Thread: A Short Guide to LaTeX

  1. #1
    jet
    jet is offline
    Banned jet's Avatar
    Join Date
    Jan 2007
    HSC
    2009
    Gender
    Male
    Posts
    3,163
    Rep Power
    0

    A Short Guide to LaTeX

    Hi everyone,
    With the use of LaTeX becoming more widespread, I've decided to write a short guide to LaTeX. If you have any problems, post in this thread or message me somehow.
    jetblack2007.

    The graphical editor supplied to us is excellent, though I think at least a small amount of knowledge of how to work with LaTeX is helpful. All you do is combine normal text with commands to tell the editor how it should format something, for example turn an expression into a fraction.

    Maths Mode
    The LaTeX editor is in a mode known as maths mode, which is fine-tuned for mathematical typesetting. All spaces are ignored, and maths commands don't need to be wrapped by special tags in order to be interpreted by the engine.

    Numbers and Simple Operations
    For many characters, if it's on your keyboard, it works. Numbers are written as numbers, and the + and - signs do not require any special commands. Multiplication and Division, however, are expressed using the /times and /div commands.
    For example:
    Code:
    1 2 3 4 5 6 7 8 9 0 + - \times \div ( )
    becomes


    Text
    As spaces are ignored in maths mode, and text letters are treated as mathematics, writing something like this:
    Code:
    Hello world, how are you this fine morning?
    turns into


    The solution is simple. A command known as \text{} exists, which allows you to write all your text inside the parentheses, and it is treated as text.
    E.g.
    Code:
    \text{Hello world, how are you this fine morning?}
    becomes


    Another way, suggested by Trebla, is to wrap the text in $ tags, instead of the \text{} function. It does exactly the same thing.
    E.g
    Code:
    $Hello world, how are you this fine morning?$
    becomes:


    Starting a new line
    Simply pressing Enter and expecting a new line to be interpreted does not work in LaTeX. Instead, you have to use a double slash, \\. This signals to the engine that it should start a new line.
    E.g.
    Code:
    \text{Line 1} \\ \text{Line 2}
    becomes:


    (Suggested by kaz1)

    Fractions
    The command \frac{}{} is used for fractions, where the numerator goes in the first set of parentheses and the denominator in the second set.
    So,
    Code:
    \frac{x^3 - x^2}{5x - 1}
    becomes


    Brackets
    Sometimes mathematical expressions (like fractions) can be so big that they exceed the size of the brackets. In this case you can use the \left and \right commands before the bracket. They will then be automatically resized to the size of their contents.
    To compare:
    Code:
    ( \frac{1}{x}) \text{ versus }\left (\frac{1}{x} \right )
    become:


    You can do this with the following brackets: (), [], ||
    (Note that because maths mode ignores spacing, I had to include it within the text command to ensure the text wasn't sandwiched between expressions with no spacing)

    Square Roots
    The \sqrt{} command places a root sign over whatever is in the set of parentheses. It resizes according to the size of the radicand.
    So:
    Code:
    \sqrt{x\left (5x - 1\right )}
    is:


    Superscript and subscript
    Superscript and subscript formatting is indicated by the ^{} and _{} commands respectively. Whatever is in the parentheses is super/subscripted.
    Therefore:
    Code:
    x^{\frac{5}{3}}, M_{\text{AB}}
    become:


    Spacing:
    Sometimes you just need that little bit of extra space between characters. There is a set of inbuilt functions to do this.
    From smallest of bigger, they are: \! , \, , \: , \; , \quad and \qquad
    So
    Code:
    a \! a \, a \: a \; a \quad a \qquad a
    becomes:

    (Note: The first command, \! is actually 'negative' space, forcing characters closer together)

    Integrals
    The integral sign is given by the command \int which can be modified to include limits using super/subscripts. Normally I like to put a \, before the dx to make it look neat.
    E.g. The code
    Code:
    \int^{6}_{\frac{1}{2}} x^2 - 3x + 1 \, dx
    Becomes:


    Enclosing something in a box
    This is just like using a text command, though you use the \fbox{} command. Whatever you want in the box goes in the parentheses.
    E.g.
    Code:
    \fbox{1234567890}
    is:


    Other Symbols
    There are hundreds of other symbols available for you to use. Many of them are included in the graphical interface of the editor, so the commands can be learnt that way, though I think some of the more common ones can be placed here:

    Trig functions with built-in formatting and spacing:
    \sin:
    \cos:
    \tan:
    \sec:
    \csc:
    \cot:
    \arcsin:
    \arccos:
    \arctan:

    Greek letters (just their name preceded by a \. If capital letters have the first letter as a capital)
    \alpha:
    \beta:
    \gamma:
    \Gamma:
    \delta:
    \Delta:
    \theta:
    \Theta:
    etc.

    Miscellaneous symbols:
    \circ: (useful in superscript for degrees)
    \triangle:
    \angle:
    \equiv:
    \rightarrow:
    \Rightarrow:
    \infty:

    For a large amount of other symbols: http://tinyurl.com/y8elxfb

    The Align Environment
    When you want to align certain parts of a solution vertically, (e.g. equals under equals) you use what is called the align environment. You mark which part of each line you want aligned together with the & sign, and latex does all the work for you.
    For example, Casic posted:

    (this is missing the align environment). Clearly writing our equals under equals would be helpful. You start the align environment with the command \begin{align*} (the asterisk tells LaTeX you don't want the lines numbered) and end it with the \end{align*} command.
    So, the code for this is:
    Code:
    \begin{align*}5x &= 2x + 3x \\ 
    &= 3x + 2x & \text{(since } \mathbb{R} \text{ is commutative)} \\ 
    &= 5x \end{align*}
    Noting that the alignment symbol (&) is placed before the = signs, which is where we want them aligned.
    This becomes:


    Piecewise functions
    When you need to define piecewise functions, you use the cases environment. It works the same as the alignment environment, beginning through \begin{cases} and ending through \end{cases}. Each case is specified on a new line within the cases environment.
    So:
    Code:
    f(x) = \begin{cases}\text{Case } 1 \\ \text{Case } 2 \end{cases}
    is:
    Last edited by jet; 3 Oct 2010 at 3:23 PM. Reason: Formatting
    astroman and BenHowe like this.

  2. #2
    Super Moderator Trebla's Avatar
    Join Date
    Feb 2005
    HSC
    2006
    Gender
    Male
    Posts
    5,765
    Rep Power
    20

    Re: A Short Guide to LaTeX

    For texts I would use $ to surround the text (in this version anyway, it works oppositely in other versions).

    e.g. $Insert text$ becomes:

  3. #3
    Drover gurmies's Avatar
    Join Date
    Mar 2008
    HSC
    2009
    Gender
    Male
    Location
    North Bondi
    Posts
    1,239
    Rep Power
    7

    Re: A Short Guide to LaTeX

    Any idea how to put a solution in a box?
    Last edited by jet; 11 Jan 2010 at 4:23 PM.
    Commerce (Finance) / Science (Advanced Mathematics) (Quantitative Risk) @ UNSW

  4. #4
    et tu kaz1's Avatar
    Join Date
    Mar 2007
    HSC
    N/A
    Uni Grad
    2018
    Gender
    Undisclosed
    Location
    Vespucci Beach
    Posts
    7,009
    Rep Power
    12

    Re: A Short Guide to LaTeX

    Also you should put in how to start a new line.
    cracker

  5. #5
    jet
    jet is offline
    Banned jet's Avatar
    Join Date
    Jan 2007
    HSC
    2009
    Gender
    Male
    Posts
    3,163
    Rep Power
    0

    Re: A Short Guide to LaTeX

    Quote Originally Posted by gurmies View Post
    Any idea how to put a solution in a box?
    Do you have an example you can show me?

  6. #6
    et tu kaz1's Avatar
    Join Date
    Mar 2007
    HSC
    N/A
    Uni Grad
    2018
    Gender
    Undisclosed
    Location
    Vespucci Beach
    Posts
    7,009
    Rep Power
    12

    Re: A Short Guide to LaTeX

    Quote Originally Posted by gurmies View Post
    Any idea how to put a solution in a box?
    Spoiler (rollover to view):
    you mean this?
    cracker

  7. #7
    Executive Member untouchablecuz's Avatar
    Join Date
    Mar 2008
    HSC
    2009
    Gender
    Male
    Posts
    1,709
    Rep Power
    8

    Re: A Short Guide to LaTeX

    Quote Originally Posted by kaz1 View Post
    Spoiler (rollover to view):
    you mean this?
    nah

    like the [k=n-m-1] which has a box around it

    (i think this is what he means)

    (this is just Q ive done for someone)

  8. #8
    Drover gurmies's Avatar
    Join Date
    Mar 2008
    HSC
    2009
    Gender
    Male
    Location
    North Bondi
    Posts
    1,239
    Rep Power
    7

    Re: A Short Guide to LaTeX

    Quote Originally Posted by untouchablecuz View Post
    nah



    like the [k=n-m-1] which has a box around it



    (i think this is what he means)



    (this is just Q ive done for someone)

    Exactly this.
    Commerce (Finance) / Science (Advanced Mathematics) (Quantitative Risk) @ UNSW

  9. #9
    jet
    jet is offline
    Banned jet's Avatar
    Join Date
    Jan 2007
    HSC
    2009
    Gender
    Male
    Posts
    3,163
    Rep Power
    0

    Re: A Short Guide to LaTeX

    I'll update the guide tonight. Dinner calls

  10. #10
    Drover gurmies's Avatar
    Join Date
    Mar 2008
    HSC
    2009
    Gender
    Male
    Location
    North Bondi
    Posts
    1,239
    Rep Power
    7

    Re: A Short Guide to LaTeX

    Ty Sir =]
    Commerce (Finance) / Science (Advanced Mathematics) (Quantitative Risk) @ UNSW

  11. #11
    Junior Member
    Join Date
    Aug 2009
    HSC
    2011
    Gender
    Male
    Posts
    171
    Rep Power
    6

    Re: A Short Guide to LaTeX

    Last edited by jet; 12 Jan 2010 at 12:05 AM.

    God: This multipurpose tool has allowed billions to soothe their mortal fears while easily excusing a wide variety of unconscionable actions such as war and homophobia --Some of Man's Most Important Inventions

  12. #12
    New Member
    Join Date
    Jul 2012
    HSC
    2013
    Gender
    Undisclosed
    Posts
    10
    Rep Power
    4

    Re: A Short Guide to LaTeX

    Test post.

    Can someone tell me how you enable it? None of the commands are working for me (I must be forgetting something critical).

    Edit: Never mind, I forgot you needed the [tex] tag (I didn't see that in your guide :P).
    Last edited by Fakeuser; 13 Nov 2012 at 4:18 PM.

  13. #13
    Cadet
    Join Date
    Apr 2014
    HSC
    2016
    Gender
    Male
    Posts
    39
    Rep Power
    3

    Re: A Short Guide to LaTeX

    \fbox{12345}
    astroman likes this.

  14. #14
    Loquacious One turntaker's Avatar
    Join Date
    May 2013
    HSC
    2015
    Gender
    Undisclosed
    Posts
    3,967
    Rep Power
    5

    Re: A Short Guide to LaTeX

    lel, op is banned

  15. #15
    Rambling Spirit astroman's Avatar
    Join Date
    May 2014
    HSC
    2015
    Gender
    Male
    Location
    UTS
    Posts
    7,083
    Rep Power
    7

    Re: A Short Guide to LaTeX

    Quote Originally Posted by turntaker View Post
    lel, op is banned

  16. #16
    Loquacious One turntaker's Avatar
    Join Date
    May 2013
    HSC
    2015
    Gender
    Undisclosed
    Posts
    3,967
    Rep Power
    5

    Re: A Short Guide to LaTeX

    Quote Originally Posted by astroman View Post
    nah mate

  17. #17
    Rambling Spirit astroman's Avatar
    Join Date
    May 2014
    HSC
    2015
    Gender
    Male
    Location
    UTS
    Posts
    7,083
    Rep Power
    7

    Re: A Short Guide to LaTeX


  18. #18
    Rambling Spirit astroman's Avatar
    Join Date
    May 2014
    HSC
    2015
    Gender
    Male
    Location
    UTS
    Posts
    7,083
    Rep Power
    7

    Re: A Short Guide to LaTeX

    Quote Originally Posted by Chlee1998 View Post
    $x^{\frac{5}{3}}, M_{\text{AB}}$

  19. #19
    Pharaoh b0b101's Avatar
    Join Date
    Sep 2013
    HSC
    2015
    Gender
    Male
    Location
    Sydney
    Posts
    143
    Rep Power
    3

    Re: A Short Guide to LaTeX

    astroman likes this.
    Quote Originally Posted by RishBonjour99 View Post
    Just because you feel at home with asian people doesn't make unsw 'da best'
    ANU B FINANCE / B SOFTWARE ENGINEERING (2016) -> UNSW B Data Science (2017+)

  20. #20
    Moderator
    Join Date
    Jun 2014
    HSC
    2014
    Uni Grad
    2018
    Gender
    Male
    Location
    Wollongong
    Posts
    2,069
    Rep Power
    4

    Re: A Short Guide to LaTeX

    For teachers and students:
    - If you don't have a LATEX or Mathtype software. Here is a little tip.
    Open a blank/new Microsoft Word document, separate to the file you are working on.
    Insert new equation into a blank document. Write what you want.

    Copy the equation in a program called Wordpad (should be installed on Windows computers).
    or even better paste in Excel (right click select Paste Special and select Picture)

    This will convert it automatically to a picture, with the correct scaling for fractions/exponentials etc.
    (make sure to do this for components rather than text, add text separately).
    Copy to your other Word document, and there you are a better scaled fraction for example.
    (I would recommend doing this for integrals as normally in Word to render them an appropriate size requires them to be on a line by themselves, which is problematic for dot-point style questions)
    Last edited by dan964; 13 Sep 2015 at 4:40 PM.
    2014 HSC - E4 in MX1 (90) / 2015 Gap Year (Youthworks) / 2016-2017 UOW - B. Maths Adv. (done math110, 201, 202, 203, 204)

    Links:
    Papers & Links for the HSC 2017 students
    thsconline Github Projects
    thsconline v8.0 for DET Laptops
    View English Notes (no download)

    Oo, a moderator...

  21. #21
    -insert title here- Paradoxica's Avatar
    Join Date
    Jun 2014
    HSC
    2016
    Gender
    Male
    Location
    Outside reality
    Posts
    2,335
    Rep Power
    4

    Re: A Short Guide to LaTeX

    How does one prevent automated indentation? It really destroys the elegance of the typesetting.
    If I am a conic section, then my e = ∞

    Just so we don't have this discussion in the future, my definition of the natural numbers includes 0.

  22. #22
    Executive Member
    Join Date
    Jun 2014
    HSC
    N/A
    Gender
    Male
    Location
    Sydney, New South Wales
    Posts
    1,827
    Rep Power
    3

    Re: A Short Guide to LaTeX

    Any idea on how to type latex code in the Bored of Studies forum?


    Most of my work is done by copying and pasting it from an External site and then uploading via photobucket.
    | B Eng (Hons) | IB Mathematics SL | IB Mathematics HL | Scorchers BBL | Australian Cricket | Casual University Statistics Tutor

  23. #23
    Executive Member
    Join Date
    Jun 2014
    HSC
    N/A
    Gender
    Male
    Location
    Sydney, New South Wales
    Posts
    1,827
    Rep Power
    3

    Re: A Short Guide to LaTeX

    $\frac{3}{7}
    | B Eng (Hons) | IB Mathematics SL | IB Mathematics HL | Scorchers BBL | Australian Cricket | Casual University Statistics Tutor

  24. #24
    Executive Member
    Join Date
    Jun 2014
    HSC
    N/A
    Gender
    Male
    Location
    Sydney, New South Wales
    Posts
    1,827
    Rep Power
    3

    Re: A Short Guide to LaTeX

    $Hello world, how are you this fine morning?$
    | B Eng (Hons) | IB Mathematics SL | IB Mathematics HL | Scorchers BBL | Australian Cricket | Casual University Statistics Tutor

  25. #25
    Ancient Orator
    Join Date
    Dec 2014
    HSC
    N/A
    Gender
    Male
    Posts
    5,590
    Rep Power
    5

    Re: A Short Guide to LaTeX

    Quote Originally Posted by davidgoes4wce View Post
    $\frac{3}{7}
    Enclose in tex tags, i.e. [ tex] [ /tex]

    (Without any spaces in those brackets; I just put spaces there so the tags are visible.)

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •