2010-07-17 7 views
5

यह प्रागमैटिक बुक्सहेल्फ़ पुस्तक से एक स्क्रीन कैप्चर है।पर्यावरण की तरह verbatim रंग?

http://img13.imageshack.us/img13/3168/screenshot20100717at123.png

ऐसा नहीं है कि रंग के साथ शब्दशः पर्यावरण की तरह लग रहा है, लेकिन मुझे यकीन है कि नहीं हूँ।

कैसे दिखाया गया वातावरण जैसे क्रियापद के लिए रंग का उपयोग कर सकते हैं?

लाइन विधि द्वारा लाइन का उपयोग करना एक समाधान होगा, लेकिन मुझे जाने का बेहतर तरीका होने की उम्मीद है।

 
{\color{red}\begin{verbatim} 
line 1 
    line 2 
\end{verbatim} } 
\color{blue}{\begin{verbatim} 
line 3 
    line 4 
\end{verbatim}} 
+0

प्रश्न हा है एलएफ बेकार क्योंकि आपने उचित छवि अपलोड फ़ंक्शंस का उपयोग नहीं किया था। –

उत्तर

4

आप fancyvrb पैकेज का उपयोग कर सकते हैं। इसमें रंग के लिए विकल्प शामिल हैं, ताकि आप एकाधिक वर्बैटिम पर्यावरण ब्लॉक का उपयोग कर सकें।

3

आप listings पैकेज भी उपयोग कर सकते हैं:

\lstinputlisting[language=Ruby]{source_filename.rb} 

या

\begin{lstlisting} 
\end{lstlisting} 
16

एक उदाहरण पैकेज

fancyvbr का उपयोग कर
\documentclass[a4paper,10pt]{scrartcl} 
\usepackage{color} 
\usepackage[utf8]{inputenc} 
\usepackage{fancyvrb} 
\usepackage[usenames,dvipsnames]{xcolor} 

\fvset{frame=single,framesep=1mm,fontfamily=courier,fontsize=\scriptsize,numbers=left,framerule=.3mm,numbersep=1mm,commandchars=\\\{\}} 

\begin{document} 
    \begin{Verbatim}[label={My orange command sample output}] 
# \textcolor{Orange}{My orange command} 
My black output 
that it can be 
many lines long 
but this specific \textbf{\textcolor{OliveGreen}{word}} 
and the following 2 
\textbf{\textcolor{red}{lines are important so they}} 
\textbf{\textcolor{red}{need to be highlighted and bold}} 
    \end{Verbatim} 
\end{document} 

Sample output of this code

+0

'टैब्यूलर' के अंदर काम नहीं कर रहा है; जब तक 'कमांडर्स' इस तरह सेट की जाती है तब तक नई लाइनें खो जाती हैं। –

+0

उनमें से किसी का परीक्षण नहीं किया है, लेकिन ऐसा लगता है कि यहां समान समाधानों के साथ कुछ समान प्रश्न हैं: http://tex.stackexchange.com/questions/119842/how-to-use-fancyvrb-verbatim-in -टाबुलरक्स और यहां: http://tex.stackexchange.com/questions/234292/how-to-put-verbatim-inside-multicolumn-in-tabular –

+0

मैं पहले से ही उन पर देखता हूं :) –

संबंधित मुद्दे