2

I need do refactoring ugly equations.

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

$
  \sum_{l=1}^{n}
  \frac{x_{k}}{\left(\overset{n}{\underset{l=1}{\sum}}\vert
      x_{l}\vert^{p}\right)^{\frac{1}{p}}}\
  \frac{y_{k}}{\left(\overset{n}{\underset{l=1}{\sum}}\vert
      y_{l}\vert^{q}\right)^{\frac{1}{q}}} \text{ } \leq
  \overset{n}{\underset{l=1}{\sum}} \frac{x_{i}^{p}}{p
      \sum_{j=1}^n (x_{i}^{p})^{\frac{1}{p} p}} + \frac{y_{i}}{(q
      \sum_{j=1}^n y_{i}^{q})^{\frac{1}{q}q}}= \frac{1}{p} +
    \frac{1}{q} = 1
$
\end{document}

What is your experience to create more flexibility TeX?

I consider using command to underscore \sum. What is your opinion about this solution?

  • Welcome to TeX SX! What you would like to have is not very clear. Could you explain more? What do call ‘flexibility’? – Bernard Sep 20 at 21:06
  • I learn Latex, and I need more information how I should write code like this. I think prepare special commands for adjusting \sum. It is right idea? – Martin Inf1n1ty Sep 20 at 21:11
  • Is your equation inline or displayed on a line of its own? – Bernard Sep 20 at 21:12
  • For own script. It's similar proof of math.stackexchange.com/questions/2148138/… – Martin Inf1n1ty Sep 20 at 21:15
  • 1
    \overset{n}{\underset{l=1}{\sum}: How about \sum\limits_{l=1}^n? – Henri Menke Sep 20 at 21:34
4

The posted code is missing a \right so that it generates an error. Once that is fixed, the main stylistic error in the coding is using \underset and \overset rather than limits on the sum, and using textstyle rather than displaystyle for the expression.

I would use something more like the following although it is rather wide so perhaps use an amsmath multi-line display environment such as align rather than \[ \]

\documentclass[a4paper]{article}

\usepackage{amsmath}

\begin{document}

\[
  \sum_{l=1}^{n}
  \frac{x_{k}}{\left(\sum_{l=1}^{n}\lvert x_{l}\rvert^{p}\right)^{\frac{1}{p}}}
  \frac{y_{k}}{\left(\sum_{l=1}^{n}\lvert y_{l}\rvert^{q}\right)^{\frac{1}{q}}}
   \leq
  \left(\sum_{l=1}^{n} \frac{x_{i}^{p}}{p \sum_{j=1}^n (x_{i}^{p})^{\frac{1}{p} p}} +
                     \frac{y_{i}}{(q \sum_{j=1}^n y_{i}^{q})^{\frac{1}{q}q}}\right)
    = \frac{1}{p} +\frac{1}{q}
     = 1
\]
\end{document}

enter image description here

0

I also suggest that you define macros for often used expressions. Here is an adaptation of David Carlisle's answer using macros:

enter image description here

Below, I have defined two macros for the two expressions that are repeated. The only difference between them is one uses x/p and the other uses y/q. Of course, you should pick more meaningful names for the two macros.

Besides ensuring consistency, this makes the code a bit easier to read.

Code:

\documentclass[a4paper]{article}
\usepackage{amsmath}

\newcommand*{\AbsSumFraction}[2]{%
    % #1 = variable: x,y
    % #2 = exponent p, q
    \frac{#1_{k}}{\left(\sum_{l=1}^{n}\lvert #1_{l}\rvert^{#2}\right)^{\frac{1}{#2}}}%
}
\newcommand*{\SumFraction}[2]{%
    % #1 = variable: x,y
    % #2 = exponent p, q
    \frac{x_{i}^{p}}{p \sum_{j=1}^n (x_{i}^{p})^{\frac{1}{p} p}}
}

\begin{document}
\[
    \sum_{l=1}^{n} \AbsSumFraction{x}{p} \AbsSumFraction{y}{q}
    \le \left( \sum_{l=1}^{n}  \SumFraction{x}{p} + \SumFraction{y}{q} \right)
    = \frac{1}{p} + \frac{1}{q}
    = 1
\]
\end{document}

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.