Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\documentclass{article}
\begin{document}
 My text.
\end{document}

Here 'My text' is the output.But I want to get the following output:

\begin{document} 
My text 
\end{document} 

Is there any way to get this output ?

share|improve this question
    
Here 'My text' is the output.But I want to get the following output: '\begin{document} My text \end{document}'. Is there any way to get this output ? –  Md Kutubuddin Sardar Mar 19 '13 at 13:16
    
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it). –  hpesoj626 Mar 19 '13 at 13:17
2  
Are you asking about the verbatim environment? –  JLDiaz Mar 19 '13 at 13:20
1  
Related/Duplicate: How do I print a syntax-highlighted LaTeX source file? –  hpesoj626 Mar 19 '13 at 13:31
    
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs Apr 20 '13 at 10:49
add comment

1 Answer

Yes. Use the verbatim environment.

\documentclass{article}
\begin{document}
\begin{verbatim}
\begin{document}
 My text.
\end{document}
\end{verbatim}
\end{document}

If you want to output the whole source code of some file, say myfile.tex, you can make a frame file and use \VerbatimInput from the fancyvrb package:

\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\VerbatimInput{myfile.tex}
\end{document}
share|improve this answer
1  
with \usepackage{verbatim}, \verbatiminput{myfile.tex} (lowercase \verbatiminput) does the same thing. if you want a file to input itself, you can say \verbatiminput{\jobname.tex}. (great for documenting small examples.) –  barbara beeton Mar 19 '13 at 15:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.