0

I'm completely new to LaTeX, and I'm just learning how to type math equations. Can someone tell me what I'm doing wrong here?

The position of an object is given by
$\textbf{r} = (\emph{ct - bt^3}) \textbf{\hat{i}}$ + 
$\emph{dt^2}/textbf${\hat{j}}$, with constants \emph{c} = 6.7 m/s,
\emph{b} = 0.81 m/s^3, and \emph{d} = 4.5 m/s^2.
4
  • Welcome to TeX.SX! In its current form, it's hard to tell what is being asked in the question. You can have a look at our starter guide to familiarize yourself further with our format.
    – T. Verron
    Oct 27, 2016 at 13:40
  • 3
    The environments like \textbf and \emph are not suited for being using inside of a math formula. Use \mathbf for the bolds inside your formulae, the characters inside of the formula are italic by default.
    – user17040
    Oct 27, 2016 at 13:49
  • 1
    Also, keep the plus sign within the math code, you don' t need to close and open again the math mode. $.... + ....$.
    – Sigur
    Oct 27, 2016 at 13:53
  • 1
    Also use an appropriate package for writing units, e.g., siunitx. You would write $b = 0.81 \si{\metre\per\cubic\second}$.
    – Denis
    Oct 27, 2016 at 14:06

2 Answers 2

7

Welcome, to the site and to LaTeX!

Well, the number one thing I cannot stress enough is not to skip in and out of math mode. This is a very common mistake, so don't feel bad about it, but math mode ($ ... $) doesn't mean 'mathify' this, and it isn't primarily a way of getting special characters (although many commands only work in math mode). It's designed for typesetting the entire mathmatical object. Thus all of this:

$\textbf{r} = (\emph{ct - bt^3}) \textbf{\hat{i}}$ + 
$\emph{dt^2}/textbf${\hat{j}}$

Should be within one pair of $ ... $. LaTeX's math mode is designed to give you the correct spacing around operators such as + and =, don't circumvent this.

I don't know if /textbf${\hat{j}} is a typo for \textbf${\hat{j}} (i.e. you have / but you meant \) or whether you left out the \: /\textbf${\hat{j}}

$ must not come between \textbf and {.

Using \textbf{} in math mode is not exactly wrong in this case, but it is a bit counter-intuitive. Try \mathbf{}

Using \emph within math mode is definitely wrong. \emph{} is used within text to emphasise it. By default, \emph{} italicises text, but it is not an all-purpose italicisation command. $ ... $ italicises characters by default and the usual problem people have is making things not italicised! It is also a text mode command, which means math mode commands like ^ will not work within \emph{} unless you enter math mode again, totally circumventing the \emph{} in this circumstance, i.e.: \emph{foo $bar^{baz}$}.

\hat{i} will give you an i with a hat over the tittle. Having it bold, and dotless, and with a hat, is a much more difficult task than it may look. Ordinarily, you'd want to use \hat{\imath}, but then it would not be bold. Using \mathbf{} won't make it bold, but loading the bm package and using \bm{\hat{\imath}} will make it bold, but then it won't be upright, it'll be italic.

So, I used this question:

Bold upright i-hat and j-hat for vector notation

As mentioned above, ^ must be used in math mode. \emph{b} = 0.81 m/s^3 will fail.

Also, avoid using \emph{} for variables, use math mode.

What I guess you want:

\documentclass{article}
\usepackage{amsmath}
\newcommand{\ihat}{\boldsymbol{\hat{\textbf{\i}}}}
\newcommand{\jhat}{\boldsymbol{\hat{\textbf{\j}}}}

\begin{document}

The position of an object is given by
$\mathbf{r} = (ct - bt^{3}) \ihat + dt^{2}\jhat$, with constants
$c = 6.7~\mathrm{m}/\mathrm{s}$, $b = 0.81~\mathrm{m}/\mathrm{s}^{3}$,
and $d = 4.5~\mathrm{m}/\mathrm{s}^{2}$

\end{document}

enter image description here

Although you should maybe look into the siunitx package for typesetting units more easily.

The siunitx way. Note the use of \usepackage[per-mode=symbol]{siunitx} in the preamble to give you the solidus for "per", as opposed to, e.g. m s-3

\documentclass{article}
\usepackage{amsmath}
\newcommand{\ihat}{\boldsymbol{\hat{\textbf{\i}}}}
\newcommand{\jhat}{\boldsymbol{\hat{\textbf{\j}}}}
\usepackage[per-mode=symbol]{siunitx}

\begin{document}

The position of an object is given by
$\mathbf{r} = (ct - bt^{3}) \ihat + dt^{2}\jhat$, with constants
$c = 6.7~\si{\metre\per\second}$,
$b = 0.81~\si{\metre\per\cubic\second}$, and
$d = 4.5~\si{\metre\per\square\second}$
4

As people are saying the in comments, for boldface symbols in mathematics use \mathbf and drop the \emph. Also, math-mode $...$ is designed for typesetting formulas, so keep the plus signs etc inside the dollar signs.

For units there is the really useful siunitx package. Using this I would typeset b, for example, as $b=\SI{0.81}{m/s^3}$.

If you are going to be using things like \mathbf{\hat{i}} a lot then it is worth defining a macro because this make the code both quicker to type and easier read and understand. The simplest macros are just substitutions:

\newcommand\bi{\mathbf{\hat{i}}}

but they can also take arguments (see, for example, defining-macros-with-arguments).

Putting this together, I would type your MWE as:

\documentclass{article}
\usepackage{siunitx}

\newcommand\bi{\mathbf{\hat{i}}}
\newcommand\bj{\mathbf{\hat{j}}}
\newcommand\br{\mathbf{r}}

\begin{document}\noindent
The position of an object is given by
$\br = (ct - bt^3)\bi + dt^2\bj$,
with constants $c=\SI{6.7}{m/s}$,
$b=\SI{0.81}{m/s^3}$, and $d=\SI{4.5}{m/s^2}$.

\end{document}

to give

enter image description here

1
  • A comma is missing after the definition of $c$.
    – Denis
    Oct 27, 2016 at 14:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .