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 '19 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 '19 at 21:11
  • Is your equation inline or displayed on a line of its own? – Bernard Sep 20 '19 at 21:12
  • For own script. It's similar proof of https://math.stackexchange.com/questions/2148138/proving-holders-inequality-for-sums – Martin Inf1n1ty Sep 20 '19 at 21:15
  • please provide a test file, your output looks odd, why is the outer sum in inline mode and the inner sum in display? – David Carlisle Sep 20 '19 at 21:15
  • It's issue of this solution, When I tried preparing the standard of inner sum, I decided wrote, because the code of LateX was too long. – Martin Inf1n1ty Sep 20 '19 at 21:19
  • it is impossible to understand your question in its current form, the fragment you have provided can not be run on its own, it also appears to be in error missing \right ? but hard to tell as it can not be run, but also what is your actual question – David Carlisle Sep 20 '19 at 21:21
  • First things first please understand in-line and display math mode and the differences between them: https://tex.stackexchange.com/questions/301672/making-the-product-operator-pi-caps-with-the-extremes-above-and-below-the-symb/301677#301677 – Au101 Sep 20 '19 at 21:23
  • I edited your question so the code can be run but note that it generates an error. If you get any error do not even look at the output PDF, fix or ask a question about the error, copying the error message from the log file. TeX makes no attempt to make sensible typeset output after an error. – David Carlisle Sep 20 '19 at 21:26
  • @DavidCarlisle I fixed problem with \left, many thanks for your suggestions. – Martin Inf1n1ty Sep 20 '19 at 21:31
  • 1
    \overset{n}{\underset{l=1}{\sum}: How about \sum\limits_{l=1}^n? – Henri Menke Sep 20 '19 at 21:34
  • @HenriMenke I suggested result of https://math.stackexchange.com/questions/2148138/proving-holders-inequality-for-sums. – Martin Inf1n1ty Sep 20 '19 at 21:36

2 Answers2

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

David Carlisle
  • 757,742
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}

Peter Grill
  • 223,288