6

In a tikz timing graph I want to reduce the font size of the labels. When I do that they are not vertically centred with the graph anymore. How does one move the label vertically to the center?

The MWE is below:

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usepackage{tikz-timing}
\begin{document}
\begin{tikztimingtable}[%
    timing/dslope=0.1,
    timing/.style={x=5ex,y=2.2ex},
    x=1ex,
    timing/rowdist=3ex,
    timing/name/.style={font=\rmfamily}]
\small Data   & {[semitransparent]3u} 2D{0} 2D{1}  2D{1} 2D{0} {[semitransparent]2u}\\
\small Clock  & {[semitransparent]3u} LHLHLHLH {[semitransparent]2u}\\ \\
\end{tikztimingtable}
\end{document}

enter image description here

I found in the documentation that I can probably use anchor=mid east, but i'm not sure where to put it.

Thank you for your help!

  • 1
    I'm sorry, included the wrong picture. I meant veritcally center the label on the left (Data & Clock) – Douwe66 Jun 19 '17 at 18:27
  • \makebox[5ex]{Data} and \makebox[5ex]{Clock} will do it. You can place \small either in or outside of the \makebox. – Steven B. Segletes Jun 19 '17 at 18:29
4

A little yshift added to the timing/name style. Also, I'd move the \small there as well.

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usepackage{tikz-timing}
\begin{document}
\begin{tikztimingtable}[%
    timing/dslope=0.1,
    timing/.style={x=5ex,y=2.2ex},
    x=1ex,
    timing/rowdist=3ex,
    timing/name/.style={font=\rmfamily\small,yshift=2pt}]
Data   & {[semitransparent]3u} 2D{0} 2D{1}  2D{1} 2D{0} {[semitransparent]2u}\\
Clock  & {[semitransparent]3u} LHLHLHLH {[semitransparent]2u}\\ \\
\end{tikztimingtable}
\end{document}
  • I'm wondering... Did you find that solution in the manual, or do you know of a way (that I don't) to access all pgfKeys at timing/. or deeper, so you can check, one by one, what they were fed ? – marsupilam Jun 19 '17 at 19:01
  • @marsupilam I assumed that timing/name is the style that is used for the nodes that contain the labels/names for each row, so I guess that any TikZ key will work there. – Torbjørn T. Jun 19 '17 at 19:03
  • So this was a mere lucky guess on your part ?! I mean the fact the key should be called name and not label or title or leftWord... – marsupilam Jun 19 '17 at 19:05
  • @marsupilam Well, given that the font key was already used in that style, it's hardly a long stretch to think that other keys would work as well ... – Torbjørn T. Jun 19 '17 at 19:07
  • Right ! Hadn't spotted that.. ! Cheers ! – marsupilam Jun 19 '17 at 19:08
4

Here, I place the text in equal sized \makeboxes. The \small can be inside or outside of the \makebox, though a slightly different gap will result after the text, depending...

Why the original version of the OP behaves thus, it might be a case of right-aligned labels.

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usepackage{tikz-timing}
\begin{document}
\begin{tikztimingtable}[%
    timing/dslope=0.1,
    timing/.style={x=5ex,y=2.2ex},
    x=1ex,
    timing/rowdist=3ex,
    timing/name/.style={font=\rmfamily}]
\makebox[5ex]{\small Data}   & {[semitransparent]3u} 2D{0} 2D{1}  2D{1} 2D{0} {[semitransparent]2u}\\
\makebox[5ex]{\small Clock}  & {[semitransparent]3u} LHLHLHLH {[semitransparent]2u}\\ \\
\end{tikztimingtable}
\end{document}

enter image description here

The above MWE fixes the horizontal centering of the two words. To also fix the vertical alignment, per follow-up comments, one can combine this result with a \raisebox:

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usepackage{tikz-timing}
\begin{document}
\begin{tikztimingtable}[%
    timing/dslope=0.1,
    timing/.style={x=5ex,y=2.2ex},
    x=1ex,
    timing/rowdist=3ex,
    timing/name/.style={font=\rmfamily}]
\raisebox{1.5pt}{\makebox[5ex]{\small Data}}   & {[semitransparent]3u} 2D{0} 2D{1}  2D{1} 2D{0} {[semitransparent]2u}\\
\raisebox{1.5pt}{\makebox[5ex]{\small Clock}}  & {[semitransparent]3u} LHLHLHLH {[semitransparent]2u}\\ \\
\end{tikztimingtable}
\end{document}

enter image description here

  • Thank you for the answer. I found that makebox didn't do the trick (because 5ex defines the width). \raisebox did the trick however! – Douwe66 Jun 19 '17 at 18:35
  • @Douwe66 I thought you wanted the words centered with respect to each other. Certainly, a \raisebox should accomplish a vertical displacement. Nonetheless, glad to help. – Steven B. Segletes Jun 19 '17 at 18:37
  • Thanks. I was indeed a bit ambiguous in my question. You brought me in the right direction by using the box environment – Douwe66 Jun 19 '17 at 18:39

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.