3

The below snippet is supposed to show a list of items and some associated values which I've stored as new commands. Unfortunately, what happens instead is a mess. I've included everything I think might be relevant, though I'm not sure how to actually display the resulting garble. Maybe it's something to do with using math mode for subscripts?

What I get is nothing like what I was expecting: enter image description here

I want the descriptions to be inline with the \paragraph{} block. I'm not sure why R1 and the garble of R1 and R2 are like they are, or why the values appear to have situated themselves as a jumble after R1 in "Actual Component Values."

I'm a complete beginner to LaTeX and I don't even know where to begin ... what's happening here and how do I fix it?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}   %https://en.wikibooks.org/wiki/LaTeX/Mathematics
\usepackage{siunitx} % Provides the \SI{}{} and \si{} command for typesetting SI units
\usepackage{graphicx} % Required for the inclusion of images
\usepackage{cite}
.
.
.
\newcommand{\cOneTrue}{.875 nF}
\newcommand{\rOneCalc}{18.189 k\Omega}
\newcommand{\rOneTrue}{6.187 k\Omega}
\newcommand{\rTwoTrue}{12.079 k\Omega}
\newcommand{\rNetTrue}{18.266 k\Omega}
.
.
.
\subsection{Low Pass Filter}
\paragraph{Calculated Necessary Resistance:}
    \begin{description}
        \item[\(R_1\)]      \rOneCalc
    \end{description}
\paragraph{Actual Component Values: }
    \begin{description}
        \item[\(C_1\)]      \cOneTrue
        \item[\(R_1\)]      \rOneTrue
        \item[\(R_2\)]      \rTwoTrue
        \item[\(R_{net}\)]  \rNetTrue
    \end{description}
  • 1
    Further to @Gonzalo's answer, I can only reproduce the result you show by putting TeX into nonstop mode, so that it ploughs on through errors. Don't do this! – Ian Thompson Sep 1 '15 at 19:44
  • I'm using sharelatex ... I'm not sure how to turn nonstop mode off? – Daniel B. Sep 1 '15 at 22:08
5

When you process your document (after suitable completion) you get an eeror message:

! Missing $ inserted.
<inserted text> 
                $
l.18         \item[\(R_1\)]      \rOneCalc

which gives you a hint about the problem. With your current definitions, you need math-mode for your \cOneCalc, \rOneTrue,... commands (and probably will need to add spaces, and fix the font for the "k" also). However, the best thing to do here is to use siunitx, which you are already loading, to get the proper spacing and fonts:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}   %https://en.wikibooks.org/wiki/LaTeX/Mathematics
\usepackage{siunitx} % Provides the \SI{}{} and \si{} command for typesetting SI units
\usepackage{graphicx} % Required for the inclusion of images
\usepackage{cite}

\newcommand{\cOneTrue}{\SI{.875}{\nano\farad}}
\newcommand{\rOneCalc}{\SI{18.189}{\kilo\ohm}}
\newcommand{\rOneTrue}{\SI{6.187}{\kilo\ohm}}
\newcommand{\rTwoTrue}{\SI{12.079}{\kilo\ohm}}
\newcommand{\rNetTrue}{\SI{18.266}{\kilo\ohm}}

\begin{document}

\subsection{Low Pass Filter}
\paragraph{Calculated Necessary Resistance:}
\begin{description}
\item[\(R_1\)] \rOneCalc
\end{description}

\paragraph{Actual Component Values: }
\begin{description}
\item[\(C_1\)] \cOneTrue
\item[\(R_1\)] \rOneTrue
\item[\(R_2\)] \rTwoTrue
\item[\(R_{\text{net}}\)] \rNetTrue
\end{description}

\end{document}

enter image description here

As a side note, instead of defining a dedicated command for each specific value

\newcommand{\rOneCalc}{\SI{18.189}{\kilo\ohm}}
\newcommand{\rOneTrue}{\SI{6.187}{\kilo\ohm}}
\newcommand{\rTwoTrue}{\SI{12.079}{\kilo\ohm}}
\newcommand{\rNetTrue}{\SI{18.266}{\kilo\ohm}}

perhaps you would be better off (I'm not sure and it depends on the actual document needs) defining a command, such as in the following example:

\documentclass{article}
\usepackage{siunitx}

\newcommand{\MyKO}[1]{\SI{#1}{\kilo\ohm}}

\begin{document}

\MyKO{18.189}
\MyKO{6.187}
\MyKO{12.079}
\MyKO{18.266}

\end{document}
  • Because of the \Omega? – Daniel B. Sep 1 '15 at 19:41
  • 1
    @DanielB. Yes, because of the \Omega. Alternately, you could place delimiters around the \Omega directly in the definitions, and then not need them in the \items. – Steven B. Segletes Sep 1 '15 at 19:43
  • Shouldn't it be \kilo\ohm or \kohm? – egreg Sep 1 '15 at 19:47
  • 1
    @DanielB. Yes, with your current definitions you'll need math-mode for the \Omega; however, since you are loading siunitx, the best approach here use its features for your units (see code at the bottom of my answer). – Gonzalo Medina Sep 1 '15 at 19:53
  • 1
    I suggest \nano\farad – egreg Sep 1 '15 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.