Length can be specified as 3em
, or 3.5ex
. What is required to
make 4en
also valid? Are there any other font related length units?
[Tex/LaTex] em, ex, en? Which length units are font size dependent
lengths
Related Solutions
For this application, you can just define a new combined arrowhead using \pgfarrowsdeclarecombine{name left}{name right}{outer element left}{outer element right}{inner element left}{inner element right}
:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,decorations.markings}
\begin{document}
\pgfarrowsdeclarecombine{|<}{>|}{|}{|}{latex}{latex}
\def\Dimline[#1][#2][#3]{
%\node at (0,0) {"test: #1 - #2 ..."};
\begin{scope}[>=latex] % redef arrow for dimension lines
\draw[|<->|,
decoration={markings, % switch on markings
mark=at position .5 with {\node[gray] at (0,0.25) {\tiny{#3}};},
},
postaction=decorate] #1 -- #2 ;
\end{scope}
}
\begin{tikzpicture}
\node at (0,0) (nA) {A};
\node at (3,0) (nB) {B};
\Dimline[($(nA)+(0,1)$)][($(nB)+(0,1)$)]['test'] ;
\end{tikzpicture}
\end{document}
Or, in order to be able to scale the arrow tips at will, here's your approach with the decorations. The latex
tips are combined with "empty arrows" to fix the protrusion over the end of the line:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,decorations.markings}
\begin{document}
\pgfarrowsdeclarecombine{dimarrow}{dimarrow}{latex}{latex}{}{}
\def\Dimline[#1][#2][#3]{
\draw[|-|,
decoration={markings, % switch on markings
mark=at position 0 with {\arrowreversed[scale=0.5]{dimarrow}};,
mark=at position .5 with {\node[gray] at (0,0.25) {\tiny{#3}};},
mark=at position 1 with {\arrow[scale=0.5]{dimarrow}};,
},
postaction=decorate] #1 -- #2 ;
}
\begin{tikzpicture}
\node at (0,0) (nA) {A};
\node at (3,0) (nB) {B};
\Dimline[($(nA)+(0,1)$)][($(nB)+(0,1)$)]['test'] ;
\end{tikzpicture}
\end{document}
Hmm arguably this is a calc
and/or LaTeX bug.
using calc
and \widthof
would work in most of the places you mention (as in LaTeX2e
such places explicitly changed to use \setlength
internally so that they would work with calc
. However \hspace
appears to have escaped that conversion, the following patch fixes that.....
\documentclass{article}
\usepackage{calc}
\makeatletter
\def\@hspace#1{\begingroup\setlength\dimen@{#1}\hskip\dimen@\endgroup}
\makeatother
\begin{document}
a\hspace{\widthof{some text}}b
\end{document}
The above answers the original question, but the later edits have clarified that this is not needed at all. \widthof
is a relatively expensive operation and doing every row just to make space to insert the same text you measured is really just torturing your computer for no real gain. The formulation in the second table matches the version you gave in the first without the over full boxes and without measuring anything.
\documentclass{article}
\usepackage{fixltx2e}
\usepackage{calc}
\begin{document}
\begin{tabular}{p{0em}@{\hspace{1.0em}\quad}l@{\qquad}l}
\(\bullet\) & \(x = y\) & \(z = w\) \\
\(\bullet\) & \(a = b\) & \(c = d\) \\
\end{tabular}
\begin{tabular}{@{\hspace\tabcolsep\rlap{$\bullet$}\hspace{1.0em}\quad}l@{\qquad}l}
\(x = y\) & \(z = w\) \\
\(a = b\) & \(c = d\) \\
\end{tabular}
\end{document}
Best Answer
There is no
en
unit. TFM fonts have font dimensions 5 and 6 which may be accessed asex
andem
no other fontdimen corresponds directly to a unit.see
What do different \fontdimen<num> mean
Note in comments you ask about the width of an
i
you can use e-tex\fontcharwd
to find the width of a character or classically\setbox0\hbox{i}... \wd0
But thisem
andex
are not related to the width or height of the m and x characters they are just arbitrary lengths assigned by the font designer.