2

I am trying to make a color box in which I wish to add some words.

How can I make the word "ap" centered? Even please suggest to me any other ways in order to make my box attractive.

One more question how to increase the font size of the words.

MWE:

\documentclass{article}
\usepackage[most]{tcolorbox}

\begin{document}
\Huge
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black,title=ab, width=.19\linewidth, nobeforeafter]
cab
dab
gab
lab
jab
nab
tab
\end{tcolorbox}
\end{document}
4
  • title={\centering ab} can center your title.
    – Niranjan
    Jul 30 at 5:14
  • 1
    @Niranjan In tcolorbox there is a specific option to center the title: center title
    – CarLaTeX
    Jul 30 at 5:16
  • I didn't know that, thanks for the information :)
    – Niranjan
    Jul 30 at 5:53
  • @Niranjan You're welcome. It is easiest than writing \centering every time :)
    – CarLaTeX
    Jul 30 at 5:57
4

To center the title you can use center title.

If all the boxes of you document are like this, you may set the options with \tcbset, instead of repeating them for any box.

I enlarged a bit the width to avoid Overfull hbox warning.

I used halign=left to avoid Underfull hbox warning.

For the font size, you may use fonttitle for the title and fontupper for the box.

To align the boxes to the top, use box align = top.

Regarding making your box attractive, could you be more specific? There are many way to modify a tcolobox. What would you like?

\documentclass{article}
\usepackage[most]{tcolorbox}
\tcbset{colback=red!5!white, colframe=red!75!black, width=.20\linewidth, halign=left, nobeforeafter, center title, box align = top, fonttitle=\Huge, fontupper=\Huge}

\begin{document}
Normal text

\begin{tcolorbox}[title=ab]
cab
dab
gab
lab
jab
nab
tab
\end{tcolorbox}
\begin{tcolorbox}[title=II]
cab
dab
gab
lab
jab
nab
tab
mor
e w
ord
s 
\end{tcolorbox}
\end{document}

enter image description here

6
  • Thanks a lot. Suppose i add one more box which contains more word than the first one then how can i make these two boxes equal in top position
    – Math-Man
    Jul 30 at 5:34
  • My second box and first box are placed with different top alignment. Please guide me
    – Math-Man
    Jul 30 at 5:36
  • Thanks a lot to CarLaTeX .Please help me in my second question
    – Math-Man
    Jul 30 at 5:39
  • @Math-Man box align = top see my edit
    – CarLaTeX
    Jul 30 at 5:39
  • Wonderful thanks a lot again.
    – Math-Man
    Jul 30 at 5:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.