3

I have an equation and added a legend beneath it to explain the variables (the syntax is copied from another duscussion here somewhere). MWE below:

\documentclass[a4paper,oneside,abstracton]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}                     %Schriftsatz Dokument
\usepackage[english]{babel}                  %ngerman for German
\usepackage{csquotes}                        %[babel,quotes=english]
\usepackage{caption}
\addto\captionsenglish{\renewcommand{\contentsname}{Table of Contents}}
\usepackage{array}
\usepackage{tabularx}                    %more customisable tables (used also for eq legend)
\newenvironment{conditions*}
{\par\vspace{\abovedisplayskip}\noindent\tabularx{\columnwidth}{>{$}l<{$} @{\ : } >{\raggedright\arraybackslash}X}}{\endtabularx\par\vspace{\belowdisplayskip}}

\begin{document}
\begin{conditions*}
    N\textsubscript{*}  &\hspace{0.5cm} the total number of collected object photons during the exposure time\\
    n\textsubscript{pix}   &\hspace{0.5cm} number of pixels that are taken into account for \\
    n\textsubscript{B}   &\hspace{0.5cm} speed of light\\
    N\textsubscript{S}   &\hspace{0.5cm} \\
    N\textsubscript{D}   &\hspace{0.5cm} \\
    N\textsubscript{R}   &\hspace{0.5cm} \\
    G   &\hspace{0.5cm} \\
    $\sigma$\textsubscript{f}   &\hspace{0.5cm} 
\end{conditions*}
\end{document}

TeXStudio marks the following syntax in red and when moving over it tells me that the command is not recognized. How can I make it recognize the command? In the newenvironment-preamble definition the following \tabularx and a line farther \endtabularx

Inside the document and the condition environment I have the following: The & signs are marked red and cursor-over it tells me that "tabular command outside tabular env". Moreover, I get the error message for this condition environment Missing $ inserted. \end{conditions*} . I don't see why.

1 Answer 1

4

The first column is already declared in math mode with >{$} and <{$}, so what you have in the last row is, after all substitutions

$ $\sigma$\textsubscript{f} $

which causes \sigma to be outside of math mode. So just omit $.

You shouldn't use \textsubscript. Here's a better version that avoids specifying \hspace{0.5cm} every time.

\documentclass[a4paper,oneside,abstracton]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}                     %Schriftsatz Dokument
\usepackage[english]{babel}                  %ngerman for German
\usepackage{csquotes}                        %[babel,quotes=english]
\usepackage{caption}
\addto\captionsenglish{\renewcommand{\contentsname}{Table of Contents}}
\usepackage{array}
\usepackage{tabularx}                    %more customisable tables (used also for eq legend)
\newenvironment{conditions*}
 {\par\nopagebreak
  \vspace{\abovedisplayskip}
  \noindent
  \tabularx{\columnwidth}{
    >{$}l<{$}
    @{\ :\hspace{0.5cm}}
    >{\raggedright\arraybackslash}X
  }
 }
 {\endtabularx\par\vspace{\belowdisplayskip}}

\begin{document}
\begin{conditions*}
N_{*}               & the total number of collected object photons during the exposure time \\
n_{\mathrm{pix}}    & number of pixels that are taken into account for \\
n_{\mathrm{B}}      & speed of light\\
N_{\mathrm{S}}      & \\
N_{\mathrm{D}}      & \\
N_{\mathrm{R}}      & \\
G                   & \\
\sigma_{\mathrm{f}} &
\end{conditions*}
\end{document}

enter image description here

7
  • Thanks for the $ solution. But now \sigma is labelled all red just like the tabularx preamble syntax. Can this completely be ignorred? Also, what about the tabularx which are not recognized?
    – Lucas
    Feb 26, 2015 at 23:24
  • @Lucas I never use TeXStudio. And its habit of considering wrong what's good is very annoying.
    – egreg
    Feb 26, 2015 at 23:25
  • By the way, \captionsenglish in the preamble is also labelled red and not recognized.
    – Lucas
    Feb 26, 2015 at 23:33
  • 1
    So basically, your message is that whenever the pdf looks right, no warnings and error messages or whatsoever is shown in the Log, then such unrecognized command labels can safely be ignored? By the way, why should I replace \textsubscript by \mathrm? It looks just the same and works?
    – Lucas
    Feb 26, 2015 at 23:36
  • 2
    @Lucas TeXStudio doesn't do a lexical analysis: it just matches control sequences against a predefined list. About \mathrm and \textsubscript: the former is right, the latter is wrong. Trust me. ;-)
    – egreg
    Feb 26, 2015 at 23:36

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.