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?
- Attachments
-
- textex.PNG (11.46 KiB) Viewed 3187 times
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
How would i make the text appear in pdf as written here?
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
How would i make the text appear in pdf as written here?

{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
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
How would i make the text appear in pdf as written here?
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}