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 3104 times
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- 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: 10335
- 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}