Skip to main content

Writing basic math in LaTeX - inline math and math environment

Internet abounds with LaTex tutorials on how to write mathematics equations and simple symbols in LaTeX. It is sometimes not clear as to how the math environment works in general and how to differntiate between inline math equations and how to write them on a line of their own.

I earlier did a tutorial on how to write mathematical equations using Latex which covered the "equation" environment in LaTeX. Math environment is equally important and in this tutorial I am going to talk about how to use basic math environment in LaTeX.

Specifically, I am going to discuss how to do the following in LaTeX:
  1. How to initiate Math environment
  2. Writing inline math equations and writing equations in a separate line
  3. How to use frac for equations
  4. How to use paranthesis and brackets to enclose mathematical symbols and equations
  5. How to type powers and indices
  6. How to write matrices
Following video illustrates the step by step instructions to use math in LaTeX

 
The code used in this tutorial is here:
\documentclass{article}
\usepackage{amsmath}

\usepackage{amssymb}

\begin{document}

\title{Basic Mathematics with Latex by http://QuickLatex.blogspot.com}

\maketitle

This is inline \[n\] math symbol.

For inline $n$ or \(n\) is used and for displayed math we can use $$n$$ or \[n\].

We start with $n$ elements and we continue to divide them in half leaving $\frac{n}{2}$ elements.

The power can be written using caret symbol, for instance $n^n$ results in n to the power n written nicely.

The indices could be written using underscore, for instance $n_i$ makes i an index of n.

$(\frac{n}{2})$

$\left( \frac{n}{2} \right)$\\

$[\frac{n}{2}]$

$\left[ \frac{n}{2} \right]$\\

$

\left(

\begin{array} {c c c}

1 & 2 & 3\\

4 & 5 & 6\\

7 & 8 & 9

\end{array}

\right)

$

\end{document}

Comments

  1. Hi. I was wondering that is it possible to integrate LaTex with HTML? I mean I intend to write some complex mathematical equations on my blog so what will you suggest? Is HTML enough for that or shall I use some other equations producing software?

    ReplyDelete
  2. Such kind of errors are generated. :(

    "C:/Users/user/Desktop/latex files/art.tex"
    LaTeX2e <2009/09/24>
    Babel and hyphenation patterns for english, dumylang, nohyphenation, ge
    rman, ngerman, german-x-2009-06-19, ngerman-x-2009-06-19, french, loaded.
    ("C:\Program Files\MiKTeX 2.8\tex\latex\base\article.cls"
    Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
    ("C:\Program Files\MiKTeX 2.8\tex\latex\base\size10.clo"))

    LaTeX Warning: Unused global option(s):
    [12].

    No file art.aux.
    ! Undefined control sequence.
    l.4 \make
    title

    ReplyDelete
  3. I am beginner of this amazing tool, but I am currently having some challenges writing optimization problems in LaTeX.

    How do you write a systems of linear optimization equations and inequalities such as the following using LaTeX on separate lines and also indented to the right hand side with the terms aligned? I am not used to all the commands and packages yet. I shall be glad with your solution. Thank You!

    Maximize 5x1 + 4x2
    subject to x1 + x2 2
    −2x1 − 2x2 −9
    x1, x2 >= 0.

    ReplyDelete
  4. how to write equation in next line

    ReplyDelete

Post a Comment

Comments on QuickLatex are strictly moderated. As much as I hate moderation, I must fight spam. Please rest assured that if your comment is relevant I will approve it and answer.

Popular posts from this blog

Latex Tutorial: How to Create Images, Diagrams, and Flow Charts Using Latex

This tutorial is an extension of previous video tutorial on how to use tikz for image creation in Latex . In this video I explain how to set up your document for flow chat design. This equally applies to any other image that uses similar structure. Specifically, in this video I talk about following things: How to create a flow chart How to setup styles for reusable components of an image How to draw arrows from one component to other How to change the styles of components How to change the arrowhead for Latex arrows How to align components left, right, top, and below of each other The code use:d in the video is here: \documentclass{article} \usepackage{tikz} \usetikzlibrary{shapes,shadows,arrows} \begin{document} \tikzstyle{decision} = [diamond, draw, fill=blue!50] \tikzstyle{line} = [draw, -stealth, thick] \tikzstyle{elli}=[draw, ellipse, fill=red!50,minimum height=8mm, text width=5em, text centered] \tikzstyle{block} = [draw, rectangle, fill=blue!50, text width...

LaTeX Video Tutorial: How to Create a Resume or CV (Curriculum Vitae) using LaTeX

One of the most frequent questions my colleagues ask me is how to create a Resume or Curriculum Vitae (CV), if you will, in LaTeX . I have a style file that was passed to me by a friend who found it on Internet. Since this looked good I used it and, thanks to the original contributor, I am going to share it with you all today. You will be able to download these files and create a professional Resume for yourself.  The files can be download from the linked locations: The Resume.tex file (main document) The Class file res.cls (for page setting) In the video tutorial , attached below, I have explained how to change the text for your needs. The structure of the Resume (or CV) is highly flexible and once you get hold of the basics it will be pretty straight forward for you to tweak it for your own use.  I have tried to add the basic sections that are present in most of the Resumes but you will most probably add more depending on your requirements. I am prett...

How to draw Reddit Alien in LaTeX using Tikz - Video tutorial and code

If you are not a Redditor you are a lucky person. It's a one way traffic scenario with no dead end. Once you subscribe to Reddit there is no way back and it is no good being there. I am expecting my colleagues to have an intervention for my Reddit addiction soon but till then I am all here to invest (read:waste) my precious time. Since we got that out of our way, let us get back to business. Today, we are going to see how to draw a cartoon figure using LaTeX. The motivation behind this post is /r/latex on Reddit as I wanted that subreddit to have its logo drawn in LaTeX. I did not know it already was in LaTeX but it seems my work is appreciated there so I am going to contribute my 2 cents to the community. Specifically, we will learn following things in this tutorial: How to work with Colors - defining RGB colors in LaTeX. How to use multiple layers to set order of document objects (send to back, bring forward like functionality). How to use Arcs in an effective way....