表格中 tikzpicture 的垂直对齐/更改为当前边界框?

表格中 tikzpicture 的垂直对齐/更改为当前边界框?

参见插图 mwe。请注意,current bounding box.top以前有效,现在似乎不再有效。 current bounding box.north说明了此表的总体目标,但符号与相应描述文本的垂直对齐存在问题。描述文本与符号的中间垂直对齐可能是最理想的。但是,我愿意接受其他建议。

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

%
\newcommand\calltikzsymbol[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
\def\defaultsymbolscale{1.2}

% default horizontal orientation (inverse achieves horizontal flip)
\def\defaultxscale{-1}

% default vertical orientation (inverse achieves vertical flip)
\def\defaultyscale{-1}

% set x grid unit
\newlength\xunit{}
\setlength\xunit{0.8pt}

% set y grid unit
\newlength\yunit{}
\setlength\yunit{0.8pt}

% define width for the table
\newlength\descriptioncolumnwidth{}
\setlength\descriptioncolumnwidth{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}

输出也插入:

在此处输入图片描述

答案1

baseline=(current bounding box.center)似乎效果不错

相关内容