Re: Code listings in colored boxes
Thanks Joel, Nice and clean! Our use-case was slightly different--- rather than color-coding tokens, we needed to color-code (bf) selected program fragments that correlated with tutorial text. All the best, Lloyd -Original Message- From: "Joel Kulesza" Sent: Thursday, April 5, 2018 10:32pm To: "Lloyd Prentice" Cc: "mailing lyx" Subject: Re: Code listings in colored boxes On Wed, Apr 4, 2018 at 10:30 AM, wrote: > Hello, > > Just a note of hearty thanks to all for support of Lyx and Lyx users. And > an apology if I inadvertently abused list etiquette. > > I've attached a piece that I wrote to document the solution to the code > listing problem that I posed on the list. I never would have found the > solution without the lyx-users list and the generous help of Paul Rubin. > > Thanks again, > > Lloyd R. Prentice Lloyd, That was an entertaining read; thanks for (a) putting the time into documenting your ordeal and (b) keeping a light heart. I've attached a style I use for showing code that I thought might be of interest. The configuration is in the document preamble and the "program listing" used to display the code should fit into your colored boxes. - Joel
Re: Code listings in colored boxes
On Wed, Apr 4, 2018 at 10:30 AM, wrote: > Hello, > > Just a note of hearty thanks to all for support of Lyx and Lyx users. And > an apology if I inadvertently abused list etiquette. > > I've attached a piece that I wrote to document the solution to the code > listing problem that I posed on the list. I never would have found the > solution without the lyx-users list and the generous help of Paul Rubin. > > Thanks again, > > Lloyd R. Prentice Lloyd, That was an entertaining read; thanks for (a) putting the time into documenting your ordeal and (b) keeping a light heart. I've attached a style I use for showing code that I thought might be of interest. The configuration is in the document preamble and the "program listing" used to display the code should fit into your colored boxes. - Joel program_listing.pdf Description: Adobe PDF document program_listing.lyx Description: Binary data
Re: Code listings in colored boxes
Thanks guys, There is so much to learn and so much I want to learn about Lyx/LaTex/Tex. Has anyone come up with a syllabus that that takes one from total noob to mastery? All the best, Lloyd -Original Message- From: "Scott Kostyshak" Sent: Wednesday, April 4, 2018 11:00pm To: "Kornel Benko" Cc: lyx-users@lists.lyx.org, ll...@writersglen.com Subject: Re: Code listings in colored boxes On Wed, Apr 04, 2018 at 05:27:34PM +, Kornel Benko wrote: > Wow! This attached document would be pretty good as a lyx-preface. Lloyd almost makes it feel like we are on an adventure! It has the perfect mix of humor, information, and beautiful writing. Well done! Scott
Re: Code listings in colored boxes
On 04/04/2018 10:57 PM, Scott Kostyshak wrote: On Wed, Apr 04, 2018 at 04:30:35PM +, ll...@writersglen.com wrote: Hello, Just a note of hearty thanks to all for support of Lyx and Lyx users. And an apology if I inadvertently abused list etiquette. I don't think you did. I am just picky and do not like to leave threads hanging without knowing whether they're solved or not. I've attached a piece that I wrote to document the solution to the code listing problem that I posed on the list. I never would have found the solution without the lyx-users list and the generous help of Paul Rubin. As you put in your PDF, Paul is indeed a LyX wizard! He has helped many users find their way. Scott Scott, Thanks for the wizard line. I got my aerobic workout for the day laughing. I've been on the receiving end of a lot of help from the list (particularly Angus Leeming, back when I was stuck in Windows purgatory). I just have idle time on my hands now that I'm retired. Paul
Re: Code listings in colored boxes
Le 05/04/2018 à 05:00, Scott Kostyshak a écrit : On Wed, Apr 04, 2018 at 05:27:34PM +, Kornel Benko wrote: Wow! This attached document would be pretty good as a lyx-preface. Lloyd almost makes it feel like we are on an adventure! It has the perfect mix of humor, information, and beautiful writing. Well done! I hope I will eventually be able to re-use "comeuppence". JMarc
Re: Code listings in colored boxes
On Wed, Apr 04, 2018 at 05:27:34PM +, Kornel Benko wrote: > Wow! This attached document would be pretty good as a lyx-preface. Lloyd almost makes it feel like we are on an adventure! It has the perfect mix of humor, information, and beautiful writing. Well done! Scott signature.asc Description: PGP signature
Re: Code listings in colored boxes
On Wed, Apr 04, 2018 at 04:30:35PM +, ll...@writersglen.com wrote: > Hello, > > Just a note of hearty thanks to all for support of Lyx and Lyx users. And an > apology if I inadvertently abused list etiquette. I don't think you did. I am just picky and do not like to leave threads hanging without knowing whether they're solved or not. > I've attached a piece that I wrote to document the solution to the code > listing problem that I posed on the list. I never would have found the > solution without the lyx-users list and the generous help of Paul Rubin. As you put in your PDF, Paul is indeed a LyX wizard! He has helped many users find their way. Scott signature.asc Description: PGP signature
Re: Code listings in colored boxes
Am Mittwoch, 4. April 2018 12:30:35 CEST schrieb ll...@writersglen.com: > Hello, > > Just a note of hearty thanks to all for support of Lyx and Lyx users. And an > apology if I inadvertently abused list etiquette. > > I've attached a piece that I wrote to document the solution to the code > listing problem that I posed on the list. I never would have found the > solution without the lyx-users list and the generous help of Paul Rubin. > > Thanks again, > > Lloyd R. Prentice > > > -Original Message- > From: "Scott Kostyshak" > Sent: Wednesday, April 4, 2018 11:49am > To: "Paul A. Rubin" > Cc: lyx-users@lists.lyx.org, ll...@writersglen.com > Subject: Re: Code listings in colored boxes > > On Wed, Apr 04, 2018 at 12:56:33PM +, Paul A. Rubin wrote: > > Sorry. Lloyd got back to me directly and we sorted it out off the list. I > > meant to come back and close the thread but forgot. > > No problem! Thanks for the update. Good job figuring out the issue. I > will let this thread rest peacefully now. > > Scott Wow! This attached document would be pretty good as a lyx-preface. Kornel signature.asc Description: This is a digitally signed message part.
Re: Code listings in colored boxes
On Wed, Apr 04, 2018 at 12:56:33PM +, Paul A. Rubin wrote: > Sorry. Lloyd got back to me directly and we sorted it out off the list. I > meant to come back and close the thread but forgot. No problem! Thanks for the update. Good job figuring out the issue. I will let this thread rest peacefully now. Scott signature.asc Description: PGP signature
Re: Code listings in colored boxes
On 04/03/2018 10:28 PM, Scott Kostyshak wrote: On Sun, Feb 25, 2018 at 12:49:47AM +, Paul A. Rubin wrote: On 02/24/2018 02:40 PM, ll...@writersglen.com wrote: Hello, I've been struggling to format attractive code listings. The boxes in the attached mini-lyx document show my feeble attempts so far. Box 2 is close to what I want, but has numerous problems: 1. Rather than red and white, I'd want black and light gray 2. I'd like width to be full width of text area of my page 3. I'd to use \listno\ in header, but get this error message when I try: File ended while scanning use of \codelist. <*> listno.tex *** (job aborted, no legal \end found) 4. If I try to add a second code listing I get error messages or a broken box depending upon how I try to terminate the first list specification 5. I'd like to use a monospace font in the code area that has both normal and bold face Most of all, I'd like to understand how to gain programming control over the appearance of my code list boxes. I've been studying the tcolorbox manual. But when I try to change parameters in the lyx preamble nothing seems to change. So I'm guessing there's a lyx issue I'm ignorant of. I'd much appreciate any and all tips to help solve these issues. Many thanks, Lloyd R. Prentice [I screwed up and replied privately rather than to the list, so I'm repeating the reply here.] Lloyd, There are a couple of problems with your MWE. One is that it won't compile due to a typo. In the TeX box after "More code", you have a left parenthesis where you need a left brace. The other is that you seem to be using a nonstandard document class. It's a good idea to keep MWEs as vanilla as possible. To make the background for the text in your code box more gray, ratchet up the "5" in colback settings. Right now you have gray!5!white, which is a mix of 5% gray and 95% white. Try something like 25 rather than 5. I believe the specification red!1175!black for the colframe parameter is illegal; the xcolor package wants numbers between 0 and 100. Since I'm not sure what you're going for here, I can't make a useful suggestion, other than to say the closer you get to 0 (100) the more red (black) you get in the mix. If you want the box header to have a pure black background, add "colbacktitle=black" to the definition of the box. To get full text width, you may need to use \newtcolorbox rather than \newtcbox (which does not seem to like the width option). That will mean using \begin{my box name} and \end{my box name} to create the box. The extra option you give in the definition of the color box is "width=\textwidth". An easier approach, in my opinion, is to use the features of the LyX module to define a custom color box. I've attached a hacked copy of your file, changing the document type to plain old book, fiddling a bit with your preamble (while noting that the color box stuff in the preamble won't be needed at all if you use the module features), and demonstrating the custom color box feature from the module. As for your other questions, it's dinner time here, so you're on your own. Hopefully someone else will pick up the thread. Paul I'm CC'ing Lloyd. Since I did not see a reply, I'm guessing that he did not receive the email. Scott Sorry. Lloyd got back to me directly and we sorted it out off the list. I meant to come back and close the thread but forgot. Paul
Re: Code listings in colored boxes
On Sun, Feb 25, 2018 at 12:49:47AM +, Paul A. Rubin wrote: > On 02/24/2018 02:40 PM, ll...@writersglen.com wrote: > > > > Hello, > > > > I've been struggling to format attractive code listings. The boxes in > > the attached mini-lyx document show my feeble attempts so far. > > > > Box 2 is close to what I want, but has numerous problems: > > > > 1. Rather than red and white, I'd want black and light gray > > > > 2. I'd like width to be full width of text area of my page > > > > 3. I'd to use \listno\ in header, but get this error message when I try: > > > > File ended while scanning use of \codelist. > > > > <*> listno.tex > > > > *** (job aborted, no legal \end found) > > > > 4. If I try to add a second code listing I get error messages or a > > broken box depending upon how I try to terminate the first list > > specification > > > > 5. I'd like to use a monospace font in the code area that has both > > normal and bold face > > > > Most of all, I'd like to understand how to gain programming control over > > the appearance of my code list boxes. I've been studying the tcolorbox > > manual. But when I try to change parameters in the lyx preamble nothing > > seems to change. So I'm guessing there's a lyx issue I'm ignorant of. > > > > I'd much appreciate any and all tips to help solve these issues. > > > > Many thanks, > > > > Lloyd R. Prentice > > > [I screwed up and replied privately rather than to the list, so I'm > repeating the reply here.] > > Lloyd, > > There are a couple of problems with your MWE. One is that it won't compile > due to a typo. In the TeX box after "More code", you have a left parenthesis > where you need a left brace. The other is that you seem to be using a > nonstandard document class. It's a good idea to keep MWEs as vanilla as > possible. > > To make the background for the text in your code box more gray, ratchet up > the "5" in colback settings. Right now you have gray!5!white, which is a mix > of 5% gray and 95% white. Try something like 25 rather than 5. > > I believe the specification red!1175!black for the colframe parameter is > illegal; the xcolor package wants numbers between 0 and 100. Since I'm not > sure what you're going for here, I can't make a useful suggestion, other > than to say the closer you get to 0 (100) the more red (black) you get in > the mix. > > If you want the box header to have a pure black background, add > "colbacktitle=black" to the definition of the box. > > To get full text width, you may need to use \newtcolorbox rather than > \newtcbox (which does not seem to like the width option). That will mean > using \begin{my box name} and \end{my box name} to create the box. The extra > option you give in the definition of the color box is "width=\textwidth". > > An easier approach, in my opinion, is to use the features of the LyX module > to define a custom color box. I've attached a hacked copy of your file, > changing the document type to plain old book, fiddling a bit with your > preamble (while noting that the color box stuff in the preamble won't be > needed at all if you use the module features), and demonstrating the custom > color box feature from the module. > > As for your other questions, it's dinner time here, so you're on your own. > Hopefully someone else will pick up the thread. > > Paul I'm CC'ing Lloyd. Since I did not see a reply, I'm guessing that he did not receive the email. Scott signature.asc Description: PGP signature
Re: Code listings in colored boxes
On 02/24/2018 02:40 PM, ll...@writersglen.com wrote: Hello, I've been struggling to format attractive code listings. The boxes in the attached mini-lyx document show my feeble attempts so far. Box 2 is close to what I want, but has numerous problems: 1. Rather than red and white, I'd want black and light gray 2. I'd like width to be full width of text area of my page 3. I'd to use \listno\ in header, but get this error message when I try: File ended while scanning use of \codelist. <*> listno.tex *** (job aborted, no legal \end found) 4. If I try to add a second code listing I get error messages or a broken box depending upon how I try to terminate the first list specification 5. I'd like to use a monospace font in the code area that has both normal and bold face Most of all, I'd like to understand how to gain programming control over the appearance of my code list boxes. I've been studying the tcolorbox manual. But when I try to change parameters in the lyx preamble nothing seems to change. So I'm guessing there's a lyx issue I'm ignorant of. I'd much appreciate any and all tips to help solve these issues. Many thanks, Lloyd R. Prentice [I screwed up and replied privately rather than to the list, so I'm repeating the reply here.] Lloyd, There are a couple of problems with your MWE. One is that it won't compile due to a typo. In the TeX box after "More code", you have a left parenthesis where you need a left brace. The other is that you seem to be using a nonstandard document class. It's a good idea to keep MWEs as vanilla as possible. To make the background for the text in your code box more gray, ratchet up the "5" in colback settings. Right now you have gray!5!white, which is a mix of 5% gray and 95% white. Try something like 25 rather than 5. I believe the specification red!1175!black for the colframe parameter is illegal; the xcolor package wants numbers between 0 and 100. Since I'm not sure what you're going for here, I can't make a useful suggestion, other than to say the closer you get to 0 (100) the more red (black) you get in the mix. If you want the box header to have a pure black background, add "colbacktitle=black" to the definition of the box. To get full text width, you may need to use \newtcolorbox rather than \newtcbox (which does not seem to like the width option). That will mean using \begin{my box name} and \end{my box name} to create the box. The extra option you give in the definition of the color box is "width=\textwidth". An easier approach, in my opinion, is to use the features of the LyX module to define a custom color box. I've attached a hacked copy of your file, changing the document type to plain old book, fiddling a bit with your preamble (while noting that the color box stuff in the preamble won't be needed at all if you use the module features), and demonstrating the custom color box feature from the module. As for your other questions, it's dinner time here, so you're on your own. Hopefully someone else will pick up the thread. Paul listno.lyx Description: application/lyx
Code listings in colored boxes
Hello, I've been struggling to format attractive code listings. The boxes in the attached mini-lyx document show my feeble attempts so far. Box 2 is close to what I want, but has numerous problems: 1. Rather than red and white, I'd want black and light gray 2. I'd like width to be full width of text area of my page 3. I'd to use \listno\ in header, but get this error message when I try: File ended while scanning use of \codelist. <*> listno.tex *** (job aborted, no legal \end found) 4. If I try to add a second code listing I get error messages or a broken box depending upon how I try to terminate the first list specification 5. I'd like to use a monospace font in the code area that has both normal and bold face Most of all, I'd like to understand how to gain programming control over the appearance of my code list boxes. I've been studying the tcolorbox manual. But when I try to change parameters in the lyx preamble nothing seems to change. So I'm guessing there's a lyx issue I'm ignorant of. I'd much appreciate any and all tips to help solve these issues. Many thanks, Lloyd R. Prentice listno.lyx Description: application/lyx