Text FormattingColor Box Formatting

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
kjkazinski
Posts: 2
Joined: Sun Jul 01, 2012 7:01 pm

Color Box Formatting

Post by kjkazinski »

I want to have a black box with white text. I want the box to go all the way across the column in a multi-columned document. I thought a \colorbox would be the way to go but I can not find a width command.

This is what I am using:

Code: Select all

\noindent
\colorbox{black}{\color{white}\huge{{\textbf{(A0.0) GENERAL RULES}}}}
\newline
I used a \framebox but I could not find a fill method for it.

Code: Select all

\noindent
\framebox[\columnwidth][l]{\textbf{(A1.1) INTRODUCTION TO THE CAPTAIN'S EDITION}}\\
\newline
Am I using the wrong type of box or just missing a command.
Last edited by localghost on Sun Jul 01, 2012 9:52 pm, edited 1 time 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

GerlofVito
Posts: 27
Joined: Wed May 16, 2012 8:24 pm

Color Box Formatting

Post by GerlofVito »

You should be able to do this with an adjustbox from the adjustbox package. Have a look at the documentation. You can specify width, frame color, text color and background color.
kjkazinski
Posts: 2
Joined: Sun Jul 01, 2012 7:01 pm

Re: Color Box Formatting

Post by kjkazinski »

Thank you for the information. I have been working with the adjustbox and I am able to create the boxes that fill the column and have a black background with white text.

The only problem I am having is my text is all the same size. It seems as if the \large and \huge commands are being ignored. Am I missing something?

Thanks.
GerlofVito
Posts: 27
Joined: Wed May 16, 2012 8:24 pm

Color Box Formatting

Post by GerlofVito »

Well it's hard to say for certain since I can't see your code. But for me, the following works fine:

Code: Select all

\documentclass{article}
\usepackage{adjustbox}

\begin{document}
\adjustbox{fbox}{\footnotesize {\Large Large text} and {\small Small Text} and even {\Huge Huge text} }
\end{document}
You could try uploading a Infominimal working example, and I'll see if anything jumps out at me.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Color Box Formatting

Post by cgnieder »

kjkazinski wrote:This is what I am using:

Code: Select all

\noindent
\colorbox{black}{\color{white}\huge{{\textbf{(A0.0) GENERAL RULES}}}}
\newline
I used a \framebox but I could not find a fill method for it.

Code: Select all

\noindent
\framebox[\columnwidth][l]{\textbf{(A1.1) INTRODUCTION TO THE CAPTAIN'S EDITION}}\\
\newline
This looks to me as if you're trying to format section headers (in the appendix?). If that's the case you should probably use something like the titlesec package.

Regards
site moderator & package author
Post Reply