How to input multiple txt files with special characters into the main tex file

charactersinput

I am very new to LaTex and learning it with TexMaker. I want to make a book. For this book i have 99 txt-files (each a chapter).

I want to import this chapters into my main tex-file with the command \input{}. The problem is, that the txt-files have special characters like #, @ or _ in it. When I am trying to input them, it becomes an error. I don't want to go through all the txt files and add a \ in front of the special characters. Is it possible to disable the function of these characters?

thx for your help

edit:

thank you for your comments. I try to explain it more clearly. My folderstructure is as followed:

../BookProject/myTemplate_A5_Book.tex

../BookProject/Parts/Part_1.txt…Part_99.txt

In the Part_x.txt-Files there are special characters used (i generated them with an AI so i didn't wrote them myself and i don't now all the characters which are used).

My goal is to import the text of the txt-files as paragraphs with linebreaking etc.. But when I use \input{} the first files are working and then by part 11 it end in an error (See image).

enter image description here

i hope this helps for understanding my problem.

Best Answer

If your file is like file1.txt

#!/bin/sh

# define FOO
FOO=abc

# show FOO
echo $FOO

then you could input it verbatim:

enter image description here

Using

\documentclass{article}

\usepackage{verbatim}

\begin{document}

\section{File 1}
\verbatiminput{file1.txt}

\end{document}

But you may prefer a fancier formatting that knows something about the format (a unix shell here)

enter image description here

\documentclass{article}

\usepackage{listings}

\begin{document}

\section{File 1}
\lstinputlisting[language=sh]{file1.txt}

\end{document}

If however your text file is normal text but has LaTeX special characters like file2.txt

This is some text that costs $0.00 which is an increase of 0% on the old price
You can find it in my home directory ~/file2.txt  and ping me on
stackexchange using @

This is a second paragraph of useless text.
This is a second paragraph of useless text.
This is a second paragraph of useless text.
This is a second paragraph of useless text.
This is a second paragraph of useless text.
This is a second paragraph of useless text.
This is a second paragraph of useless text.
This is a second paragraph of useless text.
This is a second paragraph of useless text.


And here is another mention of a price in $: $30.

Then you do not want verbatim monospace rendering with all line endings preserved, but rather, you just need to set the text but treating $ as a normal character so:

enter image description here

\documentclass{article}

\usepackage[T1]{fontenc}
\begin{document}

\section{File 2}
{
\catcode`\$=12
\catcode`\_=12
\catcode`\^=12
\catcode`\%=12
\catcode`\~=12
\input{file2.txt}
}

\end{document}