4

The snippet

\documentclass[png,convert={density=600}]{standalone}
\usepackage{times,fancybox,varwidth,color}
\pagecolor{cyan}
\cornersize{1}

\begin{document}
\ovalbox{\large Hello}
\end{document}

generates the png image

Hello

with the help of pdflatex -shell-escape question.

How do I make the background fill just the ovalbox (while the ovalbox appears with no boundary)?

  • If you are ok with using tikz package then you can use \begin{tikzpicture} \node [draw=none, fill=cyan, rounded corners=5pt] {\large Hello}; \end{tikzpicture}. – Peter Grill Jan 28 '14 at 18:47
  • I was hoping to delay reading the tikz documentation even longer, but whatever works is fine. If you are ok with my marking your answer as the correct one, but then marking another if it turns out a solution without tikz is possible, please add an answer. – Calaf Jan 28 '14 at 19:31
  • You also can use pstricks (and auto-pst-pdf if you do not want to go the way latex -> dvi -> dvipdf) with this line:\psframebox*[fillcolor=cyan, framearc=0.5]{\large Hello} – Bernard Jan 28 '14 at 20:38
  • This is not as easy with fancybox since the box is constructed using 4 straight rules (top/bottom + left/right) and four corners (upper left/right, lower left/right). There is no single structure to bound colour within. Graphics packages like tikz and pstricks can manage this without problem though. – Werner Jan 28 '14 at 20:38
  • @Calaf: Yep, I can understand why one would want to postpone learning tikz, but if you are doing any serious drawings (or already know pstricks), resistance is futile :-). – Peter Grill Jan 28 '14 at 21:35
8

With tcolorbox?

enter image description here

Code:

\documentclass[png,convert={density=600}]{standalone}
\usepackage{times,tcolorbox}
\newtcbox{\myovalbox}{colback=cyan,boxrule=0pt,arc=5pt,
  boxsep=0pt,left=3pt,right=3pt,top=3pt,bottom=3pt}

\begin{document}
\myovalbox{\large Hello}
\end{document} 
| improve this answer | |
3

Here is a tikz solution:

enter image description here

Code:

\documentclass[png,convert={density=600}]{standalone}
\usepackage{times}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \node [fill=cyan, rounded corners=5pt] {\large Hello};
\end{tikzpicture}
\end{document}
| improve this answer | |

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.