2

I have to write the "Where" text about an equation as shown the given picture. The "Where" text appears to the left side which seems a little awkward as per the standards. Please suggest me, how can I move it below the equation or other standard options.

enter image description here

My code:

\begin{gather}
\text{spatial, } d_p(s^i,n^{jk}) = \sqrt{           (   s_x^i - n_x^{jk}    )^2         } \\
\text{and color distance component, } d_c(s^i,n^{jk}) = \sqrt{          (   s_L^i - n_L^{jk}    )^2 }
\end{gather}

$
\text{Where,}\\
\text{$\mathit{s^i = }$ the center of $\mathit{i^{th}}$ graph, }\\
\text{$\mathit{n^{jk} = }$ the $\mathit{j^{th}}$ node of $\mathit{k^{th}}$ graph}
$
  • don't leave a blank line after gather (where... is part of the same paragraph) and don't put $ around it, it's not math, so then you don't need the \text) that will reduce some of the vertical space most likely, but otherwise that would be the setting I would expect. – David Carlisle May 12 '15 at 13:19
  • don't use \mathit{s^i = } that makes the s and i come from a different font to that used in the main equation. \mathit uses the text italic font not math italic. – David Carlisle May 12 '15 at 13:21
  • @DavidCarlisle: Which one should I use instead of '\mathit{}'. I can't understand the suitable option for me. – skm May 12 '15 at 13:24
  • just $s^i={}$ you do not want to change fonts here. (the {} is needed to get the correct space around =) – David Carlisle May 12 '15 at 13:47
  • Related question that could be adjusted to your needs: tex.stackexchange.com/questions/244575/… – Steven B. Segletes May 12 '15 at 18:31
2

Another solution:

\documentclass{article}
\usepackage{mathtools}
\usepackage{array}

\begin{document}

\begin{align}
  \text{Spatial,}\quad d_p(s^i,n^{jk}) & = √{(s_x^{\vphantom{j}i} - n_x^{jk})^2} \\ %
  \text{and color distance component,}\quad
  d_c(s^i,n^{jk}) & = √{(s_L^i - n_L^{\smash jk})^2 } \\[-1ex] % with smashed j
  \intertext{where\enspace \begin{tabular}[t]{|@{\ }>{$}r<{={} $}@{}l}
  s^i & the center of $i$th graph,\tabularnewline
  n^{jk} & the $j$-th node of $k$\textsuperscript{th} graph.
  \end{tabular}\vskip-1.5\baselineskip}%
  \notag
\end{align} %
Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
\end{document} 

enter image description here

| improve this answer | |
1

I adapted my recent answer at Create itemize-like command, and actually prefer its look to what the OP asks here. Nonetheless, I have adapted it to look more in a manner the OP has specified. The default \leftmargin is .4\textwidth, but that can be overridden with an optional length argument to the explanation environment.

Other changes from the referenced answer, in addition to the default left margin: I use = instead of ---; I place "where" on its own separate line.

\documentclass{article}
\usepackage{lipsum,amsmath}
\let\svitem\item
\newenvironment{explanation}[1][.4\textwidth]
{\newcommand\itemB[1][]{\svitem[##1${}={}$]}%
 \let\item\itemB%
 where
 \begin{list}{}{\leftmargin=#1\labelwidth=\dimexpr1in+#1\relax%
                \itemsep=0pt\parsep=0pt\labelsep=0pt}%
}
{\end{list}}
\begin{document}
\lipsum[1]
And now for my equation.
\begin{gather}
\text{spatial, } d_p(s^i,n^{jk}) = \sqrt{           (   s_x^i - n_x^{jk}    )^2         } \\
\text{and color distance component, } d_c(s^i,n^{jk}) = \sqrt{          (   s_L^i - n_L^{jk}    )^2 }
\end{gather}
\begin{explanation}
    \item[$s^i$] the center of $\mathit{i^{th}}$ graph,
    \item[$n^{jk}$] the $\mathit{j^{th}}$ node of $\mathit{k^{th}}$ graph
\end{explanation}
\lipsum[2]
\end{document}

enter image description here

| improve this answer | |
1

Maybe like this?

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}
\usepackage{blindtext}

\begin{document}
    \blindtext Something spatial,   
    \begin{align}
    d_p(s^i,n^{jk}) &= \sqrt{(s_x^{\vphantom{j}i} - n_x^{jk})^2} \\ % with phantom j
    \intertext{and color distance component,}
    d_c(s^i,n^{jk}) &= \sqrt{(s_L^i - n_L^{\smash jk})^2 }\\ % with smashed j
    \shortintertext{where}
    s^i &=  \text{the center of $i$th graph,}\notag\\
    n^{jk} &=  \text{the $j$-th node of $k$\textsuperscript{th} graph.}\notag
    \end{align}
    or as Manuel suggests:
    \begin{align*}
        s^i &=  \text{the center of $i$th graph,}\\
        n^{jk} &=  \text{the $j$-th node of $k$\textsuperscript{th} graph.}
    \end{align*}
    \blindtext
\end{document}

I have added three different versions for the "th". Of course, you should chose one.

enter image description here

| improve this answer | |
  • When I try to use it, I am getting the confliction error because I have already defined \usepackage{amsmath}. – skm May 12 '15 at 13:56
  • 1
    @skm just replace amsmath by mathtools. This should be safe. – LaRiFaRi May 12 '15 at 14:21
  • 1
    I wouldn't align them all. The last two are not on the “same level” as the first two lines, and I see no reason for their alignment. I would probably use {align} with \intertext for the first two lines, then where \[ \begin{aligned} .. \end{aligned} \]. – Manuel May 12 '15 at 18:57
  • @Manuel Thanks for the idea. I added that. Some reason why to use \[\begin{aligned}... instead of \begin{align*}...? I noticed a minimal difference in horizontal position which I would not have expected. – LaRiFaRi May 13 '15 at 6:45
  • 1
    With \[\!\begin{aligned} .. \end{aligned}\] (notice the \! which I forgot, due to some —unnecessary— space added by the environment) you get the spacing of \[ .. \] which is tighter if the line before is short (in this case, just “where”). In any case, the thing is that I wouldn't align the four lines, the first two and the last two only. – Manuel May 13 '15 at 9:18

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.