1

I have one problem when I want to align my text font in and out math mode, here is the code:

\documentclass[xcolor=x11names,compress]{beamer}

\usepackage{xcolor}
\usepackage{tikz}
\usepackage{amsmath,amssymb}

\definecolor{Gray}{gray}{0.85}

\begin{document} 

\begin{frame}{I$^{2}$C contd}
Follow figure shows a master writes data to slave with 7-bits address:
%\vspace{-2.5em}
\begin{figure}
\centering
\hspace*{-1.5em}
\begin{tikzpicture}
%    \draw[gray] (0,0) grid (12,8);
%    \foreach \x in {0,1,...,12}
%           \draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {$\x$};
%    \foreach \y in {1,2,...,8}
%       \draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east] {$\y$};

    %draw data structure
    \draw [fill=Gray] (0,5.5)    rectangle (1,6)    node[pos=.5] {S};
    \draw [fill=Gray] (1,5.5)    rectangle (4.5,6)  node[pos=.5] {SLAVE ADDRESS};
    \draw [fill=Gray] (4.5,5.5)  rectangle (5.5,6)  node[pos=.5] {R/$\overline{W}$};
    \draw             (5.5,5.5)  rectangle (6,6)    node[pos=.5] {A};
    \draw [fill=Gray] (6,5.5)    rectangle (7.5,6)  node[pos=.5] {DATA};
    \draw             (7.5,5.5)  rectangle (8,6)    node[pos=.5] {A};
    \draw [fill=Gray] (8,5.5)    rectangle (9.5,6)  node[pos=.5] {DATA};
    \draw             (9.5,5.5)  rectangle (11,6)   node[pos=.5] {A/$\overline{A}$};
    \draw [fill=Gray] (11,5.5)   rectangle (11.5,6) node[pos=.5] {P};

    %draw example
    \draw [fill=Gray] (0.5,3) rectangle (1,3.5);
    \draw             (0.5,2) rectangle (1,2.5);

    %draw line
    \draw (5,5.3) -- (5,4.5);
    \draw (6,5.3) -- (6,4.5) -- (6.5,4.5);
    \draw (11,5.3) -- (11,4.5) -- (10.5,4.5);

    %add text
    %\coordinate [label={[blue]above:`0'(write)}] (RW) at (5,4);
    %\coordinate [label={[blue]above:`0'(data transferred \\())}] (RW) at (8.5,4);
    \node [blue, align=center, above] at (5,4) {`0'(write)};
    \node [blue, align=center, above] at (8.5,4) {data transferred \\(n bytes + ACK)};
    \node [red, align=left, above] at (2.8,3) {from master to slave};
    \node [red, align=left, above] at (2.8,2) {from slave to master};
    \node [red, align=left, above] at (8, 3) {A$=$ACK (SDA LOW)};
    \node [red, align=left, above] at (8, 2.5) {$\overline{A}=$NAK (SDA HIGH)};
    \node [red, align=left, above] at (7.1, 2) {S=START};
    \node [red, align=left, above] at (7, 1.5) {P=STOP};



\end{tikzpicture}
\end{figure}
\end{frame}

\end{document}

The output is: enter image description here How the change the font in math mode to the same font I used out side math mode??

  • 2
    \overline{\text{A}}? – Ignasi Jul 18 '16 at 10:17
  • 1
    @Ignasi, wow, I forgot this....many thanks! I previously try \textrm but seems doesn't work – How Chen Jul 18 '16 at 11:12
  • @Ignasi Would you like to answer? – user36296 Jul 19 '16 at 14:54
  • @samcarter Yes, of course! – Ignasi Jul 20 '16 at 7:35
1

If you want non-math symbols inside a math environment, commands \mathrm or \text can be used.

Which one to use?: Is there a preference of when to use \text and \mathrm?

\documentclass[tikz,border=2mm]{standalone} 
\usetikzlibrary{positioning}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}

\node[draw] {$\overline{A}$};
\node[draw] at (1,0) {$\overline{\text{A}}$};
\node[draw] at (2,0) {$\overline{\mathrm{A}}$};

\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.