5

I am not sure I express my question correctly, but my objective is to reproduce this kind of presentation. CSA mode a

And add an equation tag to the right of the image.

I am somewhat able to reproduce the equation and the image with this code.

\documentclass[pdftex,10pt,letterpaper, oneside, article]{memoir}

     \usepackage{amsmath}
     \usepackage{tabularx}
     \usepackage[pdftex]{graphicx}
\begin{document}
\begin{tabularx}{\textwidth}{m{6 cm} X}
     $\displaystyle n_u = f_1 d_f t_1 \text{(N)}$
     &
     \includegraphics[width=8 cm]{./img/mode_a.jpg}
\end{tabularx}
\end{document}

But how could I add the equation number tag to the right of the image?

  • Remove the pdftex option from the \documentclass line and from \usepackage{graphicx}. It does nothing and makes the document not portable. – egreg Jan 16 '18 at 17:09

2 Answers2

8

You don't need a tabular for that.

\documentclass[pdftex,10pt,letterpaper, oneside, article]{memoir}

     \usepackage{amsmath}
     \usepackage{tabularx}
     \usepackage[pdftex]{graphicx}
\begin{document}
\begin{align}
 n_u &= f_1 d_f t_1 \text{(N)}
     &
     \vcenter{\hbox{\includegraphics[width=8 cm]{./img/mode_a.jpg}}}
\end{align}
\end{document}

enter image description here

EDIT Since I was saying that it might look better with TikZ, I think I need to proof that.

\documentclass[10pt,letterpaper, oneside, article]{memoir}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{align}
 n_u &= f_1 d_f t_1 \text{(N)}
     &
\begin{tikzpicture}[scale=0.7,font=\sffamily,font=\footnotesize,baseline=(c.base),
murmel/.style={rectangle,thick,ultra thick, minimum width=2cm,minimum
height=0.5cm, draw,inner sep=0pt,align=left,text width=1.9cm,
append after command={% courtesy of Alenanno ref: https://tex.stackexchange.com/questions/287967/drawing-thin-line-around-a-multipart-tikz-shape#comment696552_287972
\pgfextra{\draw (\tikzlastnode.north) -- (\tikzlastnode.south);}}}]
      \node[murmel] (l1) at (0,0)  {2};
      \draw[-stealth,line width=1mm]  (l1.west)-- ++ (-1,0);
      \node[murmel,above=0cm of l1,xshift=0.5cm] (l2) {1};
      \draw[-stealth,line width=1mm]  (l2.east)-- ++ (1,0);
      \node[murmel] (c) at (6.5,0.25)  {1};
      \draw[-stealth,line width=1mm]  (c.east)-- ++ (1,0);
      \node[murmel,above=0cm of c,xshift=-0.5cm] (r1)  {1};
      \node[murmel,below=0cm of c,xshift=-0.5cm] (r2)  {2};
      \draw[-stealth,line width=1mm]  (r1.west) -- ++(-1,0);
      \draw[-stealth,line width=1mm]  (r2.west) -- ++(-1,0);
      \draw[line width=1.8mm] ($(l2.north)+(0,0.1)$)--($(l2.south)+(0,-0.85)$);
      \draw[line width=1.8mm] ($(c.north)+(0,0.85)$)--($(c.south)-(0,0.85)$);
     \end{tikzpicture}
\end{align}
\end{document} 

enter image description here

  • +1. To reduce code clutter, though, I'd omit the two mentions of the option pdftex, and I wouldn't load the tabularx package. – Mico Jan 16 '18 at 01:09
  • 1
    @Mico Yes, this is true, but I always try to accommodate the OP's inputs/wishes as far as possible. Personally, I would also draw the pic with TikZ such that the fonts are the same as in the ambient text and so on. –  Jan 16 '18 at 01:12
  • Thank you for the comment, I am currently learning to add images which include text that is latex generated. Trying through svg and others, but I am not there yet. – Simon Boucher Jan 16 '18 at 01:21
  • @SimonBoucher Even though one is a bit overwhelmed when trying this for the first time, I'd like to argue that on the long run it pays off. So I added a TikZ version of your graphics. –  Jan 16 '18 at 02:46
  • @marmot Thank you, but considering the numerous graphic I would have to do, wouldn't be better to just export them from a vector graphic file, like .svg (which is an other game to make work) or .eps which is manage natively? And for your example, to lighten the document, is there a way to call that TikZ graphic form else where? – Simon Boucher Jan 16 '18 at 03:36
  • @SimonBoucher There is inkscape, which has a plug-in (which I never could make work, but everyone else does) that allows you to export the graphics to TikZ. What I like about TikZ (and pstricks and asymptote the like) is that you can make global changes in your TeX document and you do not have to adjust each file separately. This is also helpful when you work in collaborations. –  Jan 16 '18 at 04:01
  • @marmot I tried the inkscape 2tizk plug-in, it works, I get a tizk file, but... not great for use at this point in learning. – Simon Boucher Jan 16 '18 at 04:42
  • @SimonBoucher Impressive! I never managed to get it installed. Note that one year ago I hardly knew that TikZ exists. Usually the learning curve is quite steep. Of course, certain limitations of LaTeX are a bit unfortunate, but overall it's great, and in many areas of science the only reasonable choice anyway. –  Jan 16 '18 at 04:58
  • i'd be tempted to add just a bit more space between equation and graphic. (totally subjective preference.) – barbara beeton Jan 16 '18 at 13:03
6

If you want an equation with a tag (number), use an equation:

enter image description here

\documentclass{article}

\usepackage{lipsum}
\usepackage[export]{adjustbox}

\begin{document}

\lipsum[1]
\begin{equation}
  f(x) = a x^2 + b x + c \qquad
  \includegraphics[height = 40pt, valign = c]{example-image}
\end{equation}
\lipsum[2]

\end{document}

Since graphics are typically set on the baseline, you can align them vertically with the help of adjustbox. Using the export package option, you can add valign = c to achieve a centred vertical alignment when placing your graphic.

If you want multiple (stacked) equations, use an align (or something similar).

Werner
  • 603,163