1

I want to export my Mathematica code to Latex, so I saved the mathematica notebook as LaTeX document. Copying this latex code to overleaf, I get the attention message "\hbox too wide" and the text crosses the page borders. How could I fix this?

My code is the following:

\documentclass{article}
\usepackage{amsmath, amssymb, graphics, setspace}

\newcommand{\mathsym}[1]{{}}
\newcommand{\unicode}[1]{{}}

\newcounter{mathematicapage}
\begin{document}

\begin{doublespace}
\noindent\(\pmb{w[2]\text{:=}3*(\text{Pi}{}^{\wedge}2)/2;}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{w[3]\text{:=}4*(\text{Pi}{}^{\wedge}2);}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{k222}[\text{x$\_$},\text{t$\_$}]\text{:=}- 
\text{Sqrt}[2/3]*\text{Pi}{}^{\wedge}2*(\text{Sin} 
[\text{Pi}*x]+4*\text{Sin}[2*x*\text{Pi}]*\text{Exp} 
[I*w[2]*t]+9*\text{Sin}[3*x*\text{Pi}]*\text{Exp}[I*w[3]*t])}\)
\end{doublespace}

\end{document}
7
  • By adding new lines at appropriate places? Commented Jan 28, 2022 at 10:30
  • I personally think Mathematica code should be better put inside code environment like lstlisting where auto newline can be easily done. Commented Jan 28, 2022 at 10:33
  • @user202729 \newline does not work. Commented Jan 28, 2022 at 10:59
  • There should be some way. See where the command \pmb comes from and read its documentation to see if it supports having new lines inside. Commented Jan 28, 2022 at 11:00
  • 3
    then don't export it as latex, just paste the mathematica code into your latex document in a verbatim or listings or minted environment (verbatim is simplest and requires no packages, do that first) Commented Jan 28, 2022 at 13:40

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.