1

I have the latex document:

\begin{document}

Document introduction.

\onecolumn
\section*{That's how the code looks like}

\begin{algorithm}

\input{z.tex}

\begin{algorithm}



\end{document}

And I wanted to make that z.tex (tex file is exported from program Mathematica) will looks like this: enter image description here

I think that "listing" won't work and I have to use "algorithm" but I don't know how. The tex in file after appropriate formatting looks like this:

enter image description here

Thank you for your help.

2
  • "I think that..." don't post your speculation, explain what you want to do and what's wrong (error messages, etc.) with the current solution instead.
    – user202729
    Commented Dec 25, 2021 at 0:03
  • Besides, you haven't shown what the z.tex file contains, and how the output is related to the file.
    – user202729
    Commented Dec 25, 2021 at 0:08

1 Answer 1

1

I have tried to solve Your problem using \usepackage{listings}, soI have created file named z.tex and as a result everything working fine:

enter image description here

\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}

\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}

\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}

\lstset{style=mystyle}

\begin{document}
The next code will be directly imported from a file

\lstinputlisting[language=tex]{z.tex}


\end{document}
5
  • After doing what You suggested, I get this: link Commented Dec 25, 2021 at 22:18
  • @PawełChmolewski, sooooo is what You wanted or no? if no please clarify more Commented Dec 26, 2021 at 10:51
  • It is not what I want. The text should be nice formatted. Commented Dec 26, 2021 at 21:34
  • what do You mean "nice"? Commented Dec 26, 2021 at 22:12
  • "Nice" I mean appropriate formatting, I've updated post. Commented Dec 28, 2021 at 19:24

You must log in to answer this question.

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