1
\begin{equation}
my_list = [1, 2, 3, 4, 5], then new_list = [(2\cdot3\cdot4\cdot5), (1\cdot3\cdot4\cdot5), (1\cdot2\cdot4\cdot5), (1\cdot2\cdot3\cdot5), (1\cdot2\cdot3\cdot4)] = [120, 60, 40, 30, 24]
\end{eqution}

If \(my_list = [25,5,4,15,3], then new_list = [(5*4*15*3), (25*4*15*3),(25*5*15*3), (25*5*4*3), (25*5*4*15)] = [900, 4500, 5625, 1500, 7500]\)

I am trying to make a school report in Latex for the first time, and I'm finding myself on using more time on the latex programming than the Python and R code in the assignment. I have tried using both \begin and \end equation and ( and ) without success. I also tried to write it as normal text, but then i got some error due to the *.

Would appreciate any tips, would really like to get good in latex, but I won't have time for that before the due date of this report, so I am strongly considering to just use word.

EDIT: Tried to fix the spelling error, but now I get a error concerning the subsection under the equation.

 \section*{Problem 1.1}
    \lstinputlisting{problem_1.1.py}

    \subsection*{Explanation}
   blablalblalbalblalbalblalbal a list my\_list, produce a \_list where all the integers, new\list[i], are the product of all the integers in my\_list, except my\_list[i]. Let’s try two examples to illustrate the problem. 
    \begin{equation}
    my_list = [1, 2, 3, 4, 5], then new_list = [(2\cdot3\cdot4\cdot5), (1\cdot3\cdot4\cdot5), (1\cdot2\cdot4\cdot5), (1\cdot2\cdot3\cdot5), (1\cdot2\cdot3\cdot4)] = [120, 60, 40, 30, 24]
    \end{equation}


    %If \{my_list = [25,5,4,15,3], then new_list = [(5*4*15*3), (25*4*15*3),(25*5*15*3), (25*5*4*3), (25*5*4*15)] = [900, 4500, 5625, 1500, 7500]\)


    \subsection*{Result}
    \begin{figure}[H]
            \centering 
            \includegraphics[scale=0.4]{out1.png} 
            \caption{Output of PyCharm console.}
            %Label gjør det enkelt å referere til ulike bilder.

    \end{figure}

    \section*{Problem 1.2}

    \lstinputlisting[language=R]{assig1R.r}

    \subsection*{Explanation}
    "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"

    \subsection*{Result}

    \begin{figure}[H]
            \centering 
            %Scale angir størrelsen på bildet. Bildefilen må ligge i samme mappe som tex-filen. 
            \includegraphics[scale=0.7]{out2.png} 
            \caption{Output of R consolel.}
            %Label gjør det enkelt å referere til ulike bilder.
            \label{fig:test}
    \end{figure}
  • 5
    Welcome to TEX S.E.! There is a typo. Type \end{equation} – sztruks Nov 2 '18 at 14:20
  • Welcome! I really think you need to at least skim over some introductory material... If you don't have the time to do it, it's not a good idea to switch to LaTeX now. It's like learning a new programming language; you need time to understand the basic philosophy and then build over it. Your code is really far away to what an equation in LaTeX should be... – Rmano Nov 2 '18 at 14:23
  • Also you should use align. \begin{align} ... \end{align} – Sid Nov 2 '18 at 14:25
  • Thanks sztruks! Take a look at my edited question. – AndersF94 Nov 2 '18 at 14:26
  • Hi Rmano, I fully agree with you, but this is the only problem I have. Everything else works well. – AndersF94 Nov 2 '18 at 14:29
2

I propose this:

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{equation}
\begin{aligned}[b]
\texttt{my\_list} & = [1, 2, 3, 4, 5] , \text{ then}\\
 \texttt{new\_list}& = [(2\cdot3\cdot4\cdot5), (1\cdot3\cdot4\cdot5), (1\cdot2\cdot4\cdot5), (1\cdot2\cdot3\cdot5), (1\cdot2\cdot3\cdot4)\mathrlap{]} \\[0.5ex]
 & = [120, 60, 40, 30, 24]
\end{aligned}
\end{equation}

If $\texttt{my\_list} = [25,5,4,15,3]$, then $\texttt{new\_list} = [(5*4*15*3), (25*4*15*3),(25*5*15*3), (25*5*4*3), (25*5*4*15)] = [900, 4500, 5625, 1500, 7500]\)

\end{document} 

enter image description here

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.