# copying a code to latex without loosing the format [duplicate]

I have a code of around 350 lines, and I need to paste it inside a LaTeX file without losing the formatting such as the extra spaces. What do I need to use to get this in LaTeX?

## marked as duplicate by Zarko, Stefan Pinnow, Maarten Dhondt, moewe, Paul GaboritApr 22 '16 at 6:18

• What "code" exactly do you have? Is it some source code that you want to show as a listing (use verbatim then)? Could you copy-paste a few lines here as an example? – Georges Dupéron Apr 21 '16 at 22:56
• Have a look at the listings package. You can include an external file with \lstinputlisting. – Andrew Apr 21 '16 at 23:00

You can use the package \usepackage{listings} and put your code in the following way
\begin{lstlisting}