2

I want to have a rounded box with black border lines and a backgroundcolor, f.e. yellow just around the text, not around the whole line, so the sentence should just continue on the same line. I found many threads regarding similar questions but the answer was always around a whole line or a whole paragraph but not about just one word.

2
  • 1
    Welcome to TeX.SX! This question is very similar to tex.stackexchange.com/questions/36401/…. Please take a look at it as the information there might help you. If so, that's great, and we'll probably close this question as a duplicate just to keep the place tidy and to help people find answers quickly. If not, please edit your question here to explain why so that people can better focus their attention to help you. Dec 4, 2015 at 12:25
  • I already saw this thread, but can you add a border to the box with this solution?
    – KonfuPanda
    Dec 4, 2015 at 12:33

1 Answer 1

2

Based on this answer by Roelof Spijker, just add draw=black to achieve the black border:

\documentclass{article}
\usepackage{tikz}
\newcommand\mybox[2][]{\tikz[overlay]\node[fill=yellow!20,draw=black,inner sep=2pt, anchor=text, rectangle, rounded corners=1mm,#1] {#2};\phantom{#2}}
\begin{document}
  \begin{minipage}{0.4\textwidth}
    \noindent
    this is some text \mybox{box} text\\
    this is some text box text
  \end{minipage}
  \begin{minipage}{0.4\textwidth}
    \noindent
    this is some text box text\\
    this is some text box text
  \end{minipage}    
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .