How to configure tcolorbox in lyx? - latex

I’ve been trying for the days now to format attractive code listings in lyx for an Erlang programming book that I’m working on.
The tcolorbox package looks like it should do the trick, but frustrates me at every turn,
Requirements:
Shaded Box with rounded corners, white header text on black, black outline, black on white body text
Head centered and of the form “Listing CN.LN comment” where CN is chapter number and LN is listing number and comment is in italics.
I can do this with a LaTeX macro, but can’t make it work in the head of a shaded box.
Code listing in the body must be mono space font with bold face highlighting.
I’ve read the tcolorbox manual, but still don’t understand how it works in lyx.
Can some kind souls please help dispel my ignorance?
LRP

I'm not sure about all the details of your requirements (could you post the LaTeX that works?) Try the following to get you started (I'm using LyX 2.2.x):
Document > Settings > Modules > Fancy Colored Boxes > Add > Apply
Insert > Custom Insets > Color Box
Inside the Color Box inset, you can find Color Box Options (right-click, or ALT-A 1 in Windows). Those options look similar to the syntax of tcolorbox, e.g.:
title=An enhanced box with a color gradient, enhanced, frame style={left color=red!75!black, right color=blue!75!black}, interior style={left color=red!20!white, right color=yellow!50!white}
Finally, there's an Example (in the LyX Resources/Examples folder) called colored-boxes.lyx that has a lot of info.

Related

Latex color box inline with text

I'm trying to put together a LaTeX color box. The xcolor package \fcolorbox seem to be what I want, but I can't get the rendering quite correct. When I use
\fcolorbox{black}{red}{}
it renders a small box sunken to the bottom of the text line. The best I've managed to do is to fake it with a similar text color:
\fcolorbox{black}{red}{\textcolor{red}{--}}
However, I'm worried that this won't render correctly in all situations with defined colors. Is there a way I can declare an empty text box with full in-line text height? Is there another solution?
I'm basically looking for the code that produces the color boxes all through the document at ftp://ftp.dante.de/pub/tex/macros/latex/contrib/xcolor/xcolor.pdf. The boxes I'm referring to are used throughout, but the first instance is on page 4. Thanks.
The xcolor.dtx file in the same directory as the pdf contains the source for the package and the source for the documentation. The relevant bits from the source for the documentation:
\def\testclr#1#{\#testclr{#1}}
\def\#testclr#1#2{{\fboxsep\z#\fbox{\colorbox#1{#2}{\phantom{XX}}}}}
...
(Answer: 40\% \testclr{green} $+$ 60\% \testclr{yellow} $=$ \testclr{green!40!yellow}, e.g., |\color{green!40!yellow}|)
Basically, use \phantom{} on the contents of your color box, and make sure that at least one of the phantom characters is full-height.
Also, https://tex.stackexchange.com/

How to create a sidebar with latex?

I need to make a journal, and I want to have a "recommended books" on the side of the page within the last page of the journal, but I couldn't find anything that would give me this result. I'm already using multicols package for the content and i cant see how a graphicx package would help me out.
I want to have a nice blue background with rounded corners too, help is welcome ^^.
If you are already using multicol, just make it another column and draw a box around it with the usual techniques. Maybe not the fanciest solution, but it seems like it should work. Use \newcolumn in the multicol environment to put the sidebar in its own column. For your fancy boxes, try the fancybox package. With it, you can draw boxes with rounded corners.
On the other hand, this guy gets super fancy and uses the TikZ package to get colors and all sorts of stuff.

Latex font color

I'm trying to typeset a document I'm working on.
Currently I'm trying to format a piece of text such that the text consists of two colors: a fill color and a line color. In this way the header should pop out more.
I found \psset with options such as linecolor and fillcolor, but I can't get it to work. Can someone provide an example of how I could do this?
Just providing a color using the color-package is no problem, but also not what I want because using this package I can only provide a single color for a piece of text.
Maybe this is what you're looking for: Contour package. Here's the doc containing examples.

How to add changebar in latex?

In Latex, I've created a new command 'changedtext' to mark specifics parts in my document and make it appear blue:
\newcommand{\changedtext}[1]{\textcolor{blue}{#1} }
Is there any easy way to alter the command to have change bars appear next to the text in the resulting PDF?
If not possible, any other suggestion for a visual markup (other than change bars) that would be clear on a black & white printout would be useful as well.
Update: It might be of interest to readers of this question that some time ago I started using the latexdiff script to mark up changes between two versions. I use it in combination with SVN, which I think works great; if you split up your LaTeX files, you might want to look at this tex.stackexchange question though.
Use one of the changebar macro packages in your command.
One other way which would be very clear in B&W would be highlight (shows as gray background).
Use packages soul and color and define your highlight color:
\usepackage{soul}
\usepackage{color}
\definecolor{lightgray}{rgb}{.92,.92,.92}
\sethlcolor{lightgray}
Now you can use \hl{highlighted text} in text to highlight.
Some half-baked solution (not satisfactory) I just came up with myself, is the use of \marginpar to have some arbitrary indication in the margin, e.g.:
\newcommand{\changedtext}[1]{\textcolor{blue}{#1 \marginpar{r1}} }
will put the text 'r1' (from revision 1) in the margin.
However, when using this, the \changedtext command can not be used everywhere (e.g. in formulas, captions) because LateX will complain (in my case) about 'float(s) lost'.
Still,it might be useful to some people...

How to draw borders around slides in latex beamer handouts

I am using the LaTeX beamer package. How do I draw a border around each slide when I use the handout format (eg. {4 on 1}). I would like to have something silmilar to the "-d" option available in Unix "psnup" which I used with my old seminar style slides and PostScript output.
This adds a rectangle around each logical page:
\usepackage{pgfpages}
\pgfpagesuselayout{4 on 1}[a4paper, landscape, border shrink=5mm]
\pgfpageslogicalpageoptions{1}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{2}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{3}{border code=\pgfusepath{stroke}}
\pgfpageslogicalpageoptions{4}{border code=\pgfusepath{stroke}}

Resources