9

I am actually new to latex, so this is very basic and ridiculous question. However, I cannot eliminate the blank between f(e) and the summation symbol. Besides, the equal sign is so far from the summation symbol. How can I solve these ?

Latex Code:

\sum_{e \, into \, node \, v} f(e) = \sum_{e \, out \, of \, node \, v} f(e)

Result of Latex Code

6
  • You are welcome to TeX.SE. For my opinion it is all to remake the code. What is your complete code where the preamble is? What packages do you use, etc.
    – Sebastiano
    Commented May 30, 2018 at 20:28
  • 1
    You could try something like \sum_{\mathclap{\text{$e$ into node $v$}}} f(e) = \sum_{\mathclap{\text{$e$ into node $v$}}} f(e) with mathtools. But then you might end up with the text running into the summands or the equal sign. Edit OK, I just checked this and it looks absolutely terrible.
    – moewe
    Commented May 30, 2018 at 20:28
  • 4
    never use math italic for words: e \, into \, node \, v the font is designed to make adjacent letters not look like a word but like a product of variables. Commented May 30, 2018 at 20:30
  • As I write these latex codes in os-x application "pages", most of packages and math functions do not exist unfortunately.
    – Goktug
    Commented May 30, 2018 at 20:39
  • 1
    When using text I would vote for \textnormal rather than \text.
    – Manuel
    Commented May 30, 2018 at 23:07

4 Answers 4

17

You can use \smashoperator from mathtools (I don't recommend it) or split the subscript across two lines. Or, probably better, use suitable notation.

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\[
\smashoperator[r]{\sum_{\text{$e$ into node $v$}}} f(e) =
\smashoperator[r]{\sum_{\text{$e$ out of node $v$}}} f(e)
\]

\[
\sum_{\substack{\text{$e$ into}\\\text{node $v$}}} f(e) =
\sum_{\substack{\text{$e$ out of}\\\text{node $v$}}} f(e)
\]

\[
\sum_{e\in v^{\leftarrow}} f(e) =
\sum_{e\in v^{\rightarrow}} f(e)
\]

\end{document}

enter image description here

3
  • "+1" sure. :-) Best best answer.
    – Sebastiano
    Commented May 30, 2018 at 21:04
  • 2
    Is there any specific reason why you say smashoperator is not recommended?
    – JAD
    Commented May 31, 2018 at 6:31
  • @JAD I mean, look at the output! ;-)
    – egreg
    Commented May 31, 2018 at 6:46
7

I was elaborating over my idea about visual formatting, when @Sebastiano’s use of \substack suggested a better alternative…

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
\usepackage[utf8]{inputenc}      % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{mathtools}



\begin{document}

Some text before the equation.
\begin{align}
    \sum_{\mathclap{\text{$e$ into node $v$}}} f(e)
        \mspace{9mu}&=\mspace{9mu}
        \sum_{\mathclap{\text{$e$ out of node $v$}}} f(e) 
    \\[\medskipamount]
    \sum_{\mathclap{\substack{\text{$e$ into}\\\text{node $v$}}}} f(e) &=
        \sum_{\mathclap{\substack{\text{$e$ out of}\\\text{node $v$}}}} f(e)
\end{align}
Some text after the equation.

\end{document}

The output:

Output of the code

3
  • I want upvoted all. +1 :-)
    – Sebastiano
    Commented May 30, 2018 at 21:03
  • This is what I was gonna do! +1 :)
    – Au101
    Commented May 30, 2018 at 21:04
  • 1
    @Au101: Yes, it's pretty obvious… But the most comprehensive answer is—as (almost) always—egreg’s (indeed, \smashoperator is the way to go here!).
    – GuM
    Commented May 30, 2018 at 21:11
6

Here's a solution that uses the \smashoperator macro of the mathtools package. Note that there's now no gap between the summation symbols and f(e). However, there's still a gap between the = symbol and the second summation symbol, to keep the longish material below the summation symbols from getting entangled.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for '\smashoperator' macro
\begin{document}
\[
\smashoperator{\sum_{\text{$r$ into node $v$}}}      f(e) =
\smashoperator[r]{\sum_{\text{$e$ out of node $v$}}} f(e)
\]
\end{document}
1
  • Sure that is the best. +1.
    – Sebastiano
    Commented May 30, 2018 at 21:02
3

This could be one of many solutions but it is not the best.

enter image description here

\documentclass{article}
\usepackage{amsmath} 
\begin{document}
\[
\sum _{e \text{ into node }v} \hspace{-.5cm}  f(e)=\sum _{e\,\, \text{out of node }v}
\hspace{-.5cm} f(e)
\]


\end{document}
0

You must log in to answer this question.

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