0

I am a newbie to LaTeX and LaTeXiT.

In the attached complete code below, the following line works:

\[\boldsymbol { 1 \si{N} = 1 \si{kg} \cdot \si{m} \cdot \si{s}^{\num{-2}}}\]

However, the following line returns "Missing $ inserted." error:

1 \si{N} = 1 \si{kg} \cdot \si{m} \cdot \si{s}^{\num{-2}}}

How can I fix the problem?

\documentclass[10pt]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\begin{document}
\[\boldsymbol { 1 \si{N} = 1 \si{kg} \cdot \si{m} \cdot \si{s}^{\num{-2}}}\]
1 \si{N} = 1 \si{kg} \cdot \si{m} \cdot \si{s}^{\num{-2}}}
\end{document}

The following is the complete output of the console when executing Typeset:

This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./ako_Terminology-_1_Newton.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24>
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/inputenc.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/siunitx/siunitx.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/translations/translations.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pdftexcmds/./ako_Terminology-_1_Newton.tex:8: Extra }, or forgotten $.
l.8 ...i{kg} \cdot \si{m} \cdot \si{s}^{\num{-2}}}

? ocal/texlive/2022/texmf-dist/tex/latex/tools/array.sty)) (./ako_Terminology-_1_Newton.aux) (/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/color.sty (/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-cfg/color.cfg) (/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-def/pdftex.def (/usr/local/texlive/2022/texmf-dist/tex/context/base/mkii/supp-pdf.mkii [Loading MPS to PDF converter (version 2006.09.02).] ))) (/usr/local/texlive/2022/texmf-dist/tex/latex/translations/translations-basic-d ictionary-english.trsl) (/usr/local/texlive/2022/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/local/texlive/2022/texmf-dist/tex/latex/amsfonts/umsb.fd) ./ako_Terminology-_1_Newton.tex:8: Missing $ inserted. <inserted text> $ l.8 1 \si{N} = 1 \si{kg} \cdot \si{m} \cdot \si{s}^{\num{-2}}} ?

prko
  • 5

2 Answers2

2

As others already mentioned in the comments, the reason is that certain things (in the case of your example \cdot and ^) only work in math mode.

However, in the special case of siunitx I'd suggest to use its inter-unit-product option to get the desired output, also instead of using <num> \si{<unit>} you really should use \qty{<num>}{<unit>}:

\documentclass[10pt]{article}
\usepackage{siunitx}
\begin{document}
$\qty{1}{N} = \qty[inter-unit-product=\ensuremath{{}\cdot{}}]{1}{kg.m.s^{-2}}$
\end{document}

enter image description here

You can even use this as a global setting, and instead of the literal unit-abbreviations you can also use macros to have something like a natural-language input:

\documentclass[10pt]{article}
\usepackage{siunitx}
\sisetup{inter-unit-product=\ensuremath{{}\cdot{}}}
\begin{document}
$\qty{1}{\newton} = \qty{1}{\kilogram\metre\per\square\second}$
\end{document}

Result looks identical to the one above.

Skillmon
  • 60,462
1

You don't want to do \boldsymbol{<complicated equation>}, which does nothing at all.

And you're using the wrong tools: the purpose of siunitx is to easy typing of quantities and units.

If you want that units that are multiplied are separated by a centered dot, tell it as a general option to siunitx.

For embolding a whole formula, you can do as suggested in the code below.

\documentclass[10pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{siunitx}

\sisetup{inter-unit-product=\ensuremath{{}\cdot{}}}

\newenvironment{makebold}{\boldmath\sisetup{detect-all}}{\ignorespacesafterend}

\begin{document}

[ \qty{1}{N} = \qty{1}{kg.m.s^{-2}} ]

\begin{makebold} [ \qty{1}{N} = \qty{1}{kg.m.s^{-2}} ] \end{makebold}

\end{document}

enter image description here

egreg
  • 1,121,712