1

I'm wondering if there is a command which allows me to encircle text like that:

enter image description here

It is important that the line space does not change.

5 Answers5

7

another option:

\documentclass{article}
\usepackage{tikz}

\usepackage{circledsteps}

\begin{document} text text text
\Circled[outer color=blue,inner color=blue,fill color=lime]{texto}
text text text text text text text text text text text text text text text text text text text text text text text text \end{document}

enter image description here

Circledsteps manual

if you set \tikzset{/csteps/inner ysep=20pt} you will have

enter image description here

CrocoDuck
  • 3,875
4

Maybe for inline text you will prefer a stadium shape (rectangle with rounded corners) to avoid the dilema of increase the interline space vs overlapping text when the encircled text is too wide.

A easy way to do this is a \tcbox (tcolorbox package) with the on line option, with the bonus that it is highly customizable:

MWE

\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\newtcbox{\myoval}{on line,arc=7pt,colback=yellow!50,colframe=orange!50,
boxrule=1pt, boxsep=1pt,left=1pt,right=1pt,top=1pt,bottom=1pt}
\begin{document}
\lipsum[1][1-6] 
\lipsum[1][1] Ut purus elit, vestibulum ut, placerat ac,\myoval{adipiscing vitae}, felis 
\lipsum[1][3-6]
\end{document}
Fran
  • 80,769
3

This uses tikz to overlap the ellipse and the surreounding space, but not the text itself.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit, shapes.geometric}

\newcommand{\ellipted}[1]{% #1 = text \begin{tikzpicture}[baseline=(A.base)] \node[inner sep=0pt] (A) {#1}; \begin{pgfinterruptboundingbox} \node[draw, red, ellipse, inner sep=1pt, fit=(A)] {}; \end{pgfinterruptboundingbox} \end{tikzpicture}}

\begin{document}

\noindent This is a line of text.\ This is a line of text.\ This is \ellipted{a line} of text.\ This is a line of text.\ This is a line of text.

\end{document}

demo

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
1

You asked to encircle text and showed an image not of a circle but of an oval (perhaps, even an ellipse; I cannot tell). If you wish to literally encircle stuff, i.e, surround it by a circle, consider using \textcircled (but cf. issue 926) for single letters and, say, TikZ (thx to http://tex.stackexchange.com/a/660525) otherwise:

\documentclass{article}
\pagestyle{empty}
\usepackage{tikz}
\usetikzlibrary{fit, shapes.geometric}
\newcommand{\encircle}[1]{% #1 = text; thx to http://tex.stackexchange.com/a/660525
\begin{tikzpicture}[baseline=(A.base)]
  \node[inner sep=0pt] (A) {#1};
  \begin{pgfinterruptboundingbox}
    \node[draw, circle, inner sep=1pt, fit=(A)] {};
  \end{pgfinterruptboundingbox}
\end{tikzpicture}}
\begin{document}\noindent
I like to move it move it.\\
\textcircled{I} like to move it move it.\\
I like to move it move it.\\
Ya like to \encircle{move it!}
\end{document}

output

1

Here is an option using tikzmark. Define a command \encircle that takes two arguments, one optional.

\encircle[<tikz options>]{<text>}

The optional first argument can include color, line width, changing inner xsep or inner ysep, etc.

enter image description here

Here is the code. You must compile twice.

\documentclass{article}

\usepackage{tikz} \usetikzlibrary{tikzmark, shapes.geometric, fit}

\newcommand{\encircle}[2][]{\tikzmarknode{A}{#2}\tikz[remember picture, overlay] {\node[draw, ellipse, inner xsep=-.4em, inner ysep=3pt, fit=(A),#1]{};}}

\begin{document}

Here are a few lines of text. Here are a few lines of text. Here are a few lines of text. Here are a few lines of text. Here are a few lines of text. Here are a few lines of text. I want to circle \encircle[red, thick]{some text} in the middle without affecting line spacing. Here are a few lines of text. Here are a few lines of text. Here are a few lines of text. Here are a few lines of text. Here are a few lines of text.

\end{document}

Sandy G
  • 42,558