I'm wondering if there is a command which allows me to encircle text like that:
It is important that the line space does not change.
I'm wondering if there is a command which allows me to encircle text like that:
It is important that the line space does not change.
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}
if you set \tikzset{/csteps/inner ysep=20pt} you will have
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:
\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}
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}
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}
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.
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}
circledstepspackage. – Jasper Habicht Oct 04 '22 at 11:54\textcirclednumbers? – Werner Oct 04 '22 at 21:22