TransWikia.com

Vertical alignment of tikzpicture within tabular / change to current bounding box?

TeX - LaTeX Asked on May 4, 2021

See inset mwe. Note that current bounding box.top previously worked, no longer seems to. current bounding box.north illustrates the general goal of this table but suffers from a vertical alignment issue of the symbol with the corresponding description text. Middle vertical alignment of the description text with the symbol may be most desired. I am, however, open to alternative suggestions.

documentclass[border=1mm]{standalone}%
usepackage{tikz}%
usepackage{booktabs}%
usepackage{filecontents}%
%usetikzlibrary{positioning}
%usetikzlibrary{calc}

%
newcommandcalltikzsymbol[4]{%
%hfil
begin{tikzpicture}[scale=#1,y=yunit, x=xunit,xscale=#2,yscale=#3, inner sep=0pt, outer sep=0pt,%
baseline=(current bounding box.north)]% **** works, but vertical alignment is not desireable
%baseline=(current bounding box.top)]% **** this worked previously, doesn't seem to now
input{#4}
end{tikzpicture}
}%


% SYMBOL

begin{filecontents}{needle_valve.tex}
path[draw=black,line width=0.480pt] (392.8074,233.6943) -- 
 (392.8074,209.7008);path[draw=black,line width=0.480pt] (363.0429,263.1322) 
 -- (390.7731,247.1222);path[draw=black,line width=0.480pt] 
 (388.3074,233.6943) -- (392.8074,258.2010);path[draw=black,line 
 width=0.480pt] (363.0429,228.7631) -- 
 (390.2906,244.4946);path[draw=black,line width=0.480pt] (397.3088,233.6943) 
 -- (392.8074,258.2010);path[draw=black,line width=0.480pt] 
 (422.5720,263.1322) -- (394.8424,247.1222);path[draw=black,line 
 width=0.480pt] (422.5720,228.7631) -- 
 (395.3251,244.4941);path[draw=black,line width=0.480pt] (392.8074,233.6943) 
 -- (388.3074,233.6943);path[draw=black,line width=0.480pt] 
 (392.8074,233.6943) -- (388.3074,233.6943);path[draw=black,line 
 width=0.480pt] (392.8074,233.6943) -- 
 (397.3088,233.6943);path[draw=black,line width=0.480pt] (397.3088,233.6943) 
 -- (392.8074,233.6943);path[draw=black,line width=0.480pt] 
 (363.0429,245.9476) -- (337.1305,245.9476);path[draw=black,line 
 width=0.480pt] (392.8074,209.7008) -- 
 (405.7584,209.7008);path[draw=black,line width=0.480pt] (363.0429,228.7631) 
 -- (363.0429,263.1322);path[draw=black,line width=0.480pt] 
 (422.5720,228.7631) -- (422.5720,263.1322);path[draw=black,line 
 width=0.480pt] (422.5720,245.9476) -- 
 (448.4843,245.9476);path[draw=black,line width=0.480pt] (379.8564,209.7008) 
 -- (392.8074,209.7008);path[fill=black] (397.3088,233.6943) -- 
 (392.8074,233.6943) -- (388.3074,233.6943) -- (392.8074,258.2010) -- 
 (397.3088,233.6943) -- cycle;`
end{filecontents}


% PARAMETERS


% define default symbol scale
defdefaultsymbolscale{1.2}

% default horizontal orientation (inverse achieves horizontal flip)
defdefaultxscale{-1}

% default vertical orientation (inverse achieves vertical flip)
defdefaultyscale{-1}

% set x grid unit
newlengthxunit{}
setlengthxunit{0.8pt}

% set y grid unit
newlengthyunit{}
setlengthyunit{0.8pt}

% define width for the table
newlengthdescriptioncolumnwidth{}
setlengthdescriptioncolumnwidth{5.5cm}

% vertical spacing
setlength{defaultaddspace}{3.1mm}


% CONTENT

begin{document}%

%
begin{tabular}{cp{descriptioncolumnwidth}}%
toprule%
Symbol & Description %
midrule addlinespace%
calltikzsymbol{defaultsymbolscale}{defaultxscale}{defaultyscale}{needle_valve.tex} &  Needle valve addlinespace%
calltikzsymbol{defaultsymbolscale}{defaultxscale}{defaultyscale}{needle_valve.tex} &  Same sh#t, different line.  This line happens to have a longer description which spans multiple lines.  It is worth considering this case; top alignment may actually look better in this case.  Open to suggestions. addlinespace%
bottomrule%
end{tabular}%
end{document}

Output is also inset:

enter image description here

One Answer

baseline=(current bounding box.center) seems to work well enough

Answered by John Chris on May 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP