General ⇒ background colour in *round* boxes
background colour in *round* boxes
\ovalbox{\colorbox{red}{\begin{minipage}[H]{15cm}
\vspace{6pt}
\QTR{bf}{Completeness does not guarantee utility representation}
BLA BLA BLA
\end{minipage}}}
I do get the colour in the box, but its corners are square, and it looks ugly.
Then I tried this
\ovalbox{
\pagecolor{green}
\begin{minipage}[H]{15cm}
\vspace{6pt}
\QTR{bf}{Completeness does not guarantee utility representation}
BLA BLA BLA
\vspace{6pt}
\end{minipage}}
and though I do not get any error messages, the results is simply nothing, i.e. no colour. Can anyone please help (bearing in mind that I am very computer illiterate...)?
Many thanks!
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
-
- Posts: 105
- Joined: Fri Nov 30, 2007 11:32 pm
background colour in *round* boxes
Load the package TikZ in the preamble:
Code: Select all
\usepackage{tikz}
Code: Select all
\begin{tikzpicture}
\node[circle,draw,fill=green!30]{Completeness does not guarantee utility representation};
\end{tikzpicture}
Code: Select all
\begin{tikzpicture}
\node[circle,draw,fill=green!30,text width=2in]{Completeness does not guarantee utility representation};
\end{tikzpicture}
Re: background colour in *round* boxes
Before I do so, and just to make sure I made myself clear: my objective is to create some kind of box with a background, a bit like those you may find in a textbook, like "test yourself before you continue", which would contain quite a fair amount of text (something like half a page).
Basically, what I am looking for is those boxes that one can do in the beamer class, only I need it for a paper, not a presentation.
Since you are talking of a circle, if a circle is literally what would come out, I guess it is not what I am looking for, or did I get you wrong?
thanks again!
-
- Posts: 105
- Joined: Fri Nov 30, 2007 11:32 pm
Re: background colour in *round* boxes
Though I think I misunderstood you a little. I was thinking that you wanted to have the shape with text in it in a sort of figure format. While what you are talking about (filling half a page with text that has a background) can be done in TikZ, it is perhaps not the best method. I don't know what is a good method in Latex for that. There is another system called ConText, which can do something like that very easily. But I am sure there is a way in Latex and some one here will help.
Re: background colour in *round* boxes
thanks again. Just one more question (I warned you I am computer illiterate): I jsut downloaded the pgf-2.00.tar.gz, which I eventually managed to extract. I am afraid I do not understand the installation instructions, though. Is it ok if I just copy the whole extracted directory in the "contrib" subdirectory of latex (in fact, I am using scientific word, which has a contrib sudirectory somewhere: should I copy it there?)
Thanks again!
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: background colour in *round* boxes
Best regards and welcome to the board
Thorsten¹
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
background colour in *round* boxes
thanks for your welcome!
Though I do have a copy of MiKTeX installed, I am still entirely reliant on Scientific Workplace: I know I knwo I should not, and hopefully by reading this board I will learn something, but at present my problem is I have to produce a document in a short time, and trying for a quickish fix with that, this is why I was asking where to copy...localghost wrote:When using MiKTeX, you can (and should) install the package with the Package Manager.
Thorsten¹
many thanks
p
-
- Posts: 105
- Joined: Fri Nov 30, 2007 11:32 pm
Re: background colour in *round* boxes
Sorry to hear that! I used SWP for about 4-5 years before switching to latex and I am so glad that I switched. I am not sure whether you can even use TikZ with SWP.
In case you want a quick solution, one possibility is to save your SWP file in the portable latex format (that is an option available in SWP when you choose save as) and then work with that file. If you are windows, an easy way is to use Winedt as your texteditor. When you download Winedt, it will automatically recognize your MikTex installation. Update your Miktex as Thorsten suggested...I don't know how to use the package manager to update MikTex. I had set it up such a way that it automatically looked for, downloaded and installed packages that were not available on my system.
background colour in *round* boxes
I owe you big time! It did take me a few hours to install the two packages, pgf and xcolor in Sword, but in the end, with some hit and misses, it seems to be working. The problem with SWord is that it is not fully compatible with Latex, they do have their own proprietary macros, so that sometimes things go wrong. I know I shoudl move to MikTeX, but people I work with are impermeable to this, and since we've got to exchange documents, this si a problem.
Anyhow, since I eventually managed, and thanks to your advice, I thought I should tell you how, in case some other poor soul stuck to SWord wants to do something better with it.
So, first of all xcolor: I downloaded the package, put it in sw55\tcitex\latex\contrib\ directory, then followed the xcolor instruction for installation, helped with what MacKichan software says here:
http://www.mackichan.com/index.html?tec ... ~mainFrame
note that to run the "makeindex" isntruction you have to locate the file makeindex.exe yourself and run it form the "run" cpmmand line if you are using windows.
I got loads of error messages, one of the test pages "xcolor2.tex" did not compile at all, but the other three more or less did, so I persevered with the pgf package.
This is much easier to install: I just put the whole lot in the sw55\tcitex\latex\contrib\ directory (you should instead put each subdirectory in its place, but I wanted to be able to keep some form of easy control on what I was doing, in case I failed - I told you I am coputer dumb). That was all.
Then to load the packages in SWorkplace, you can either modify files so that the program finds the new packages, as explained in step 7 in the above link; or be lazy and just "go native" and invoke the package manually in your file.
So now it does seem to work, although I cannot compile figures correctly in dvi, though I can in pdf, which is enough by now.
I did get the nice box I wanted by writing this:
\begin{tikzpicture}
\node[right,text width=14cm,rounded corners,fill=red!20,inner sep=1ex]
{
\QTR{bf}{Completeness does not guarantee utility representation}
BLA BLA BLA and...\footnote{even a footnote.}
};
\end{tikzpicture}
Thanks again!
paola
background colour in *round* boxes
one more question. I am now trying to setup a new "paolbox" environment, so that in the body of the paper I only have to write something like "\begin{Paolabox}" and "\end{Paolabox}" so that I can put the text in between, and keep the same style. Problem is, I do not know how to give the "node" command some kind of wildcard in the definition. More precisely, this is what I have written:
however, when I then try in the document something like\newcounter{Paolaboxcount}
\setcounter{Paolaboxcount}{0}
\newenvironment{Paolabox}
{% This is the begin code
\stepcounter{Paolaboxcount}
\begin{tikzpicture}
\node[right,text width=14cm,rounded corners,fill=red!20,inner sep=1ex]{\bf Box \arabic{Paolaboxcount}}
}
{% This is the end code
\end{tikzpicture} }
I get the following error message\begin{Paolabox}
bla bla bla
\end{Paolabox}
"! Package tikz Error: Giving up on this path.", and the log file continues with the "bla bla bla" bit, which does not make it to the output file. In the output I get my pink box with the heading Box 1: but how do I get the "bla bla bla" text to go to the lines below? I understand why latex gets crossed, but I do not know how to tell the node to allow more text in it.