Text FormattingGrayed listing environment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
csmgroup
Posts: 25
Joined: Sat Jul 17, 2010 6:58 pm

Grayed listing environment

Post by csmgroup »

Form LaTeX workshop (http://www.deesaster.org/latex-magazinerstellung.php), I found a way to make this listing style as attached image by defining a new environment.

Code: Select all

\documentclass{article}

\usepackage{color}
\usepackage{listings}

\definecolor{mittelgrau}{gray}{0.85}%
\lstdefinestyle{StyleCommand}{%
style=StyleListingBasic, backgroundcolor=\color{mittelgrau}, prebreak=\mbox{\textbackslash{}}%
} 
\lstnewenvironment{Befehl}[1][1] {\lstset{style=StyleCommand,linewidth=#1\linewidth}} {}%

\begin{document}
\begin{Befehl} 
$ ./robots-gui-helper 
\end{Befehl}%

\end{document}
Running the code, I get this error message.

Code: Select all

ERROR: Package Listings Error: Couldn't load requested style.
What might be wrong?
Attachments
Screen shot 2010-07-17 at 11.29.39 PM.png
Screen shot 2010-07-17 at 11.29.39 PM.png (12.09 KiB) Viewed 3542 times
Last edited by csmgroup on Tue Jul 20, 2010 1:38 am, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: Grayed listing environment

Post by gmedina »

Hi,

please post complete, minimal and compilable code.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
csmgroup
Posts: 25
Joined: Sat Jul 17, 2010 6:58 pm

Re: Grayed listing environment

Post by csmgroup »

I added preambles to generate the error message that I have. Thanks for your help.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Grayed listing environment

Post by localghost »

Your problem description remains unclear because your example is still not a MWE. You try to use some definitions for the listings style which are missing in your code (as the error message clearly states). Take a close look at the content of the archive behind the link »Beispielartikel (Quellcode)« on the page you mentioned. The missing style definitions can be found in the file »layout.tex«. Either try to run the compiler on the file called »main.tex« and see what happens or copy the relevant parts to your MWE and then try this one.


Best regards and welcome to the board
Thorsten
csmgroup
Posts: 25
Joined: Sat Jul 17, 2010 6:58 pm

Grayed listing environment

Post by csmgroup »

Code: Select all

\documentclass{article}

\usepackage{color}              % Farben
\usepackage{listings}	        % für Listings

% Listingdefinitionen
\lstdefinestyle{StyleListingBasic}{%
     basicstyle=\ttfamily,       % Schriftstil
     frame=single,               % einfacher Rahmen
     framesep=1pt,               % Abstand des Rahmens
     framerule=0.8pt,            % Linienstaerke des Rahmens
     rulecolor=\color{mittelgrau},  % Farbe der Rahmenlinie
     breaklines=true,            % automatischen Umbruch aktivieren
     breakindent=0pt             % Einrueckung nach Umbruch
}

\definecolor{mittelgrau}{gray}{0.85}%
\lstdefinestyle{StyleCommand}{%
style=StyleListingBasic, backgroundcolor=\color{mittelgrau}, prebreak=\mbox{\textbackslash{}}%
} 
\lstnewenvironment{Befehl}[1][1] {\lstset{style=StyleCommand,linewidth=#1\linewidth}} {}%

\begin{document}
\begin{Befehl} 
./robots-gui-helper 
\end{Befehl}%

\end{document}
I missed some part of the code, and now it works.
Thanks for the advice.
Last edited by csmgroup on Tue Jul 20, 2010 1:41 am, edited 1 time in total.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Grayed listing environment

Post by localghost »

Now that the problem is solved, please act as you already have been directed in my last reply. Furthermore it is very appreciated if you react on replies to former requests [1,2,3].

[1] View topic: Make one column with two column layout
[2] View topic: <a href> equivalent in TeX?
[3] View topic: Have a grayed box that fits in a multi column.
csmgroup
Posts: 25
Joined: Sat Jul 17, 2010 6:58 pm

Re: Grayed listing environment

Post by csmgroup »

Thanks for the help again.

I checked the green mark as it's solved. Did I do everything that is required?
Post Reply