Text Formatting ⇒ How would i make the text appear in pdf as written here?
How would i make the text appear in pdf as written here?
Hey completely new to LaTeX, how would i make the text in picture below appear in same order and space?
- Attachments
-
- textex.PNG (11.46 KiB) Viewed 3112 times
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10337
- Joined: Mon Mar 10, 2008 9:44 pm
How would i make the text appear in pdf as written here?
Hi doruido,
welcome to the forum!
Code as image? Nice, I'll do that too.
If I understand correctly, you would like to have line breaks and spaces in the output to be the same as in the source. I needed the same, some time ago, to print text configs the same as in the source.
Here's the package I wrote based on
Don't worry if this looks difficult! It's easy to use. Place that code as file
The output in the PDF file is:
Stefan
welcome to the forum!
Code as image? Nice, I'll do that too.

If I understand correctly, you would like to have line breaks and spaces in the output to be the same as in the source. I needed the same, some time ago, to print text configs the same as in the source.
Here's the package I wrote based on
eplain.tex
and used:Don't worry if this looks difficult! It's easy to use. Place that code as file
config.sty
in the same folder as your .tex document. Her is a sample code, how it can be used:The output in the PDF file is:
Stefan
LaTeX.org admin
How would i make the text appear in pdf as written here?
As an alternative to Stefan's nice package
you can also use LaTeX's own
There are more sophisticated packages: listings, fancyvrb and a lot more: http://www.ctan.org/topic/listing
There are also some algorithm (pseudocode) related packages: http://www.ctan.org/topic/pseudocode
Regards

{verbatim}
environment:Code: Select all
\documentclass{article}
\begin{document}
\begin{verbatim}
algorithm exists
lo=0
hi=7
while hi >= lo
mid = floor ...
\end{verbatim}
\end{document}
There are also some algorithm (pseudocode) related packages: http://www.ctan.org/topic/pseudocode
Regards
site moderator & package author
- Stefan Kottwitz
- Site Admin
- Posts: 10337
- Joined: Mon Mar 10, 2008 9:44 pm
How would i make the text appear in pdf as written here?
Hi Clemens,
by the way, the reason why I did not simply use verbatim, was that I needed TeX commands for loops and expansion, creating multiple config snippets in such a way:
Stefan
by the way, the reason why I did not simply use verbatim, was that I needed TeX commands for loops and expansion, creating multiple config snippets in such a way:
Code: Select all
\begin{config}% white space obeyed
\foreach{\i}in{1,...,30}{%
\def\VLAN{6\twodigits{\i}}%
! Virtual interface subnet 10.16.\i.0/24 switch stack \i
interface Vlan\VLAN
vrf member CCTV
ip address 10.16.\i.2/24
ip pim sparse-mode
hsrp version 2
hsrp \VLAN
authentication text HSRP\VLAN
preempt
ip 10.16.\i.1
description IPTV:10.16.\i.0/24:SWITCH\i
no shutdown
}
\end{config}
LaTeX.org admin