1

I would like to modify 2 of formulas like the figure below. Could you help me?

enter image description here

enter image description here

\documentclass[a4paper,12pt]{article}[12pt] 
\usepackage[italian]{babel} 
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc} 
\usepackage{anysize}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathrsfs} 
\usepackage{textcomp} 
\linespread{1.5}

\frenchspacing 

\newcommand{\abs}[1]{\lvert#1\rvert}

\usepackage{floatflt,epsfig}

\usepackage{multicol}




  \usepackage[a4paper,top=1.0cm,bottom=1.0cm,left=1.0cm,right=1.0cm]{geometry}


\begin{document}


$ a^2 = 16 \rightarrow a = \pm 4 =  $

\newpage

$ x \cdot \left( x+3\right)  = 0 \rightarrow $




\end{document}
Johannes_B
  • 24,235
  • 10
  • 93
  • 248
ryuk
  • 2,257

1 Answers1

3

Here is how to do it with pstricks and mathtools (for the \underbracket command).

Unrelated: the epsfighas been obsolete for more than 20 years, and should be replaced with graphicx. Also, since version 3.10 the language options of babel should be loaded with the document class, so language-dependent packages be aware of the language of the document.

\documentclass[a4paper,12pt, italian, svgnames]{article}[12pt]
\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{anysize}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{textcomp}

\usepackage{mathtools}
\usepackage{pst-node}
\usepackage{auto-pst-pdf} %% to compile with pdflatex --enable-write18 (MiKTeX) or pdflatex --shell-escape (TeX Live, MacTeX))
\newcommand\mathpnode[1]{\pnode[0,\fontdimen22\textfont2]{#1}}

\linespread{1.5}

\frenchspacing
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}

\usepackage{floatflt}%
\usepackage{multicol}

 \usepackage[a4paper, margin=1.0cm]{geometry}

\begin{document}

\begin{pspicture}
$ a^2 = 16 \rightarrow a = \pm 4 = \mathpnode{M}\qquad\begin{aligned}
  \mathpnode{R1} & \mathbf{ + 4} \\[1ex]
  \mathpnode{R2} & \mathbf{ - 4}
\psset{nodesep = 3pt}
\ncline{M}{R1}
\ncline{M}{R2}
\end{aligned} $
\end{pspicture}
\bigskip

$\psset{fillstyle = solid} \underbracket[0.8pt]{\,x\vphantom{)}\,}_{{\substack{\vert\\\pscirclebox[fillcolor = BlanchedAlmond]{1}}}}\! \cdot \underbracket[1pt]{( x+3) }_{\substack{\vert\\\pscirclebox[fillcolor = Aqua!40]{2}}}= 0 \rightarrow \quad\begin{aligned}
 & \raisebox{-0.3\height}{\pscirclebox[fillcolor = BlanchedAlmond]{1}}\quad\mathbf{x = 0}
\\[1ex]
 & \raisebox{-0.3\height}{\pscirclebox[fillcolor = Aqua!40]{2}}\quad\mathbf{x + 3\rightarrow x = -3}
\end{aligned}$

\end{document} 

enter image description here

Bernard
  • 271,350
  • thank you for your answer! How can I enable "shell escape" (or "write18") in order to run the code? thanks a lot. – ryuk Feb 11 '18 at 21:17
  • 1
    @ryuk: What are your distribution and editor? – Bernard Feb 11 '18 at 21:22
  • I use texmaker. – ryuk Feb 11 '18 at 21:33
  • The editor, yes. But the distribution: MiKTeX, TeX Live, MacTeX? – Bernard Feb 11 '18 at 21:40
  • It could be TeX live (I use ubuntu) – ryuk Feb 11 '18 at 21:49
  • 1
    Sure. Go to the Options -> Configure TeXmaker menu; click on the Commands icon (it should be opened by default) and in the second line (for pdflatex), type pdflatex -synctex=1 -shell-escape -interaction=nonstopmode %.tex and validate. ( I guess it works the same way for all platforms). – Bernard Feb 11 '18 at 21:55
  • now it works! thanks a lot! One last question...I prefer the standalone format compared to the article format, because I would like to create the formula in pdf and insert it in another latex file at a later time, but typing "\ documentclass [border = 5mm] {standalone}" instead of "\ documentclass [a4paper, 12pt, italian, svgnames] {article} [12pt] "an error appears. – ryuk Feb 11 '18 at 22:32
  • 1
    I guess this is because the two groups are in different paragraphs (there's a blank line). Doy you want to group the groups ;o) ? – Bernard Feb 11 '18 at 22:44
  • yes, i want it . – ryuk Feb 11 '18 at 22:46
  • 1
    @ryuk: I'll try to see that tomorrow to find a solution – I also have problems with standalone and these two equations grouped. – Bernard Feb 11 '18 at 23:31