Math & ScienceCircling text in \underbrace mode

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
feryee
Posts: 20
Joined: Sun Aug 09, 2015 12:57 pm

Circling text in \underbrace mode

Post by feryee »

Hi,
I am trying to circle a text under my math equation. I used \tikz and \circled but it didn't work. Can you please help me as how to circle a text while using \underbrace. thanks
Last edited by cgnieder on Mon Aug 10, 2015 7:01 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Circling text in \underbrace mode

Post by Stefan Kottwitz »

Hi feryee,

welcome to the forum!
feryee wrote:i used \tikz and \circled but it didn't work.
What did you try? We could improve or fix it. TikZ is usually fine for this.
feryee wrote:can you please help me as how to circle a text while using underbrace.
Sure! In an abstract theoretical way? Or show simply your text sample with your approach so we could work on this.

Stefan
LaTeX.org admin
feryee
Posts: 20
Joined: Sun Aug 09, 2015 12:57 pm

Circling text in \underbrace mode

Post by feryee »

Thank you very much for your time.Below here you may see my sample code.

Code: Select all

\begin{eqnarray}
\gamma E\Bigg[\underbrace{\bigg(\textbf{x}(k)\textbf{x}^T(k)\otimes \textbf{I})vec\left(\boldsymbol\delta(k)\boldsymbol\delta^T(k)\right)\bigg)\left(\sum\limits_{i=0}^{k-2}\alpha^i e^2(k-i-1)\right)}_\text{1}\Bigg]
\end{eqnarray}
I'm trying to to circle 1 instead of having simple text 1 under my equation(i.e _\text{circle 1})
thanks
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Circling text in \underbrace mode

Post by Stefan Kottwitz »

The simplest way would be _{\textcircled{1} as here:

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
  \gamma E\Bigg[\underbrace{\bigg(\textbf{x}(k)\textbf{x}^T(k)\otimes
  \textbf{I})vec\left(\boldsymbol\delta(k)\boldsymbol
  \delta^T(k)\right)\bigg)\left(\sum\limits_{i=0}^{k-2}\alpha^i e^2(k-
  i-1)\right)}_{\textcircled{1}}\Bigg]
\end{equation}
\end{document}
It looks nice with TikZ, I created a command \mycircle for this:

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\mycircle}[1]{%
  \tikz[baseline]\node[draw,shape=circle,anchor=base,inner sep=0.4ex] {#1} ;}
\begin{document}
\begin{equation}
  \gamma E\Bigg[\underbrace{\bigg(\textbf{x}(k)\textbf{x}^T(k)\otimes 
  \textbf{I})vec\left(\boldsymbol\delta(k)\boldsymbol
  \delta^T(k)\right)\bigg)\left(\sum\limits_{i=0}^{k-2}\alpha^i e^2(k-
  i-1)\right)}_{\mycircle{1}}\Bigg]
\end{equation}
\end{document}
circled.png
circled.png (8.22 KiB) Viewed 8722 times
Btw. never use eqnarray, better equation or align. For reasons, see eqnarray vs. align.

Stefan
LaTeX.org admin
feryee
Posts: 20
Joined: Sun Aug 09, 2015 12:57 pm

Re: Circling text in \underbrace mode

Post by feryee »

Thank you very much indeed Stephen. The reason that i use \eqnarray is due to many terms of similar form exist. So, i would be not be practical to center all of such a terms.
Now, The first option worked fine. However, unfortunately my DVI viewer gives rendering error and the circle disappears.I took PS, but the problem stands.do you have any idea what this happens.
Thanks
Farhad
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Circling text in \underbrace mode

Post by Stefan Kottwitz »

Hi Farhad,
feryee wrote:The reason that i use \eqnarray is due to many terms of similar form exist. So, i would be not be practical to center all of such a terms.
still, align, flalign or related environments would be better. And if there's no relation sign, as above, I would even use array for positioning math formula parts.
feryee wrote:However, unfortunately my DVI viewer gives rendering error and the circle disappears.I took PS, but the problem stands.do you have any idea what this happens.
Today most people use pdfLaTeX, which produces PDF directly without the way over DVI or PS. I used it, and it worked fine with the circle.

Why do you use LaTeX in DVI mode?

Even though, TikZ should work with all drivers including producing DVI. Perhaps post a reduced Infominimal working example, which shows the problem.

Stefan
LaTeX.org admin
feryee
Posts: 20
Joined: Sun Aug 09, 2015 12:57 pm

Re: Circling text in \underbrace mode

Post by feryee »

Stephen,
The main reason is EPS file. I have a EPS file and pdflatex fails to compile it. there is a way to get around with this issue.But, I just feel that reduces the quaility of eps file. Any suggestion?
Farhad
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Circling text in \underbrace mode

Post by Stefan Kottwitz »

Hi Farhad,

a modern TeX Live should easily work with EPS files also with pdfLaTeX. It can convert the images on the fly using the epstopdf script. I expect the quality to be the same, if PDF is the final result anyway, so there's the same kind of conversion necessary.

I don't know how MiKTeX handles it, but generally

Code: Select all

\usepackage{epstopdf}
plus enabling the shell-escape option should work.

Stefan
LaTeX.org admin
feryee
Posts: 20
Joined: Sun Aug 09, 2015 12:57 pm

Circling text in \underbrace mode

Post by feryee »

Thank you very much Stephen for your updates. I would like ask your help in drawing the following block diagram given throgh the address(System identification block at the beginning of the page):

http://zone.ni.com/reference/en-XX/help ... system_id/
aft_sysid.gif
aft_sysid.gif (3.99 KiB) Viewed 8663 times
would you please let me know the simplest method to get this block in the latex.
Thanks
Last edited by Stefan Kottwitz on Mon Aug 10, 2015 6:12 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Circling text in \underbrace mode

Post by Stefan Kottwitz »

That's not so hard with TikZ. I did it for you, but please return the favor and later post also a drawing, which you may have made later on, so we would learn a bit.

If you got questions regarding how it was made, just ask.
Btw. please open a new topic for each new question, that's better to see than different topics at the end of earlier questions. I may split this topic later too. Just for keeping the forum well sorted. And further readers can see your new questions better as a new topic, so good for you. ;-)

Code: Select all

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning,quotes,arrows.meta}
\pgfdeclarelayer{bg}%   background layer
\pgfsetlayers{bg,main}% order of the layers
\tikzset{
  block/.style  = {draw, rectangle, align = center,
                   text width = 5em, fill = white},
  bullet/.style = {draw, circle, inner sep = 0.3ex,
                   fill = black},
  round/.style  = {draw, circle},
             >  = {Triangle[width = 1.5ex, length = 1.5ex]}
}
\usepackage{sfmath}
\renewcommand*{\familydefault}{\sfdefault}
\begin{document}
\begin{tikzpicture}
  \coordinate (start);
  \node (left)   [bullet, right = 3em of start]  {};
  \node (block1) [block,  right = 2em of left]   {Unknown System};
  \node (block2) [block,  below = 3em of block1] {Adaptive Filter};
  \node (sigma)  [round,  right = 5em of block1] {$\Sigma$};
  \node (right)  [bullet, right = 2em of sigma]  {};
  \node (stop)   [right = 3em of right]          {};
  \node [above left = -0.5em and -0.3 em of sigma] {$+$};
  \node [below left = -0.5em and -0.3 em of sigma] {$-$};
  \draw (start) edge ["$x(n)$", near start, ->] (block1);
  \draw (left) -- (left|-block2) edge[->] (block2);
  \draw (block2) to["$y(n)$", near end] (block2-|sigma) edge[->] (sigma);
  \draw (block1) edge["$d(n)$", ->] (sigma);
  \draw (sigma) edge["$e(n)$", near end, ->] (stop);
  \begin{pgfonlayer}{bg}% on background layer
    \draw (right) -- ++ (0em,-9em) -- ++ (-14.8em,0em)
                  -- ++ (0em,1em) edge[->] ++(5.5em,5.5em);
  \end{pgfonlayer}
\end{tikzpicture}
\end{document}
drawing.png
drawing.png (10.71 KiB) Viewed 8665 times
TikZ is great for natively creating high-quality drawings within LaTeX. Perhaps you have further use for it, such as for other diagrams.

Stefan
LaTeX.org admin
Post Reply