如何通过 tabularx 和图像最终实现“正确”对齐?

如何通过 tabularx 和图像最终实现“正确”对齐?

在以下 MWE 中,我遇到了两件困难的事情:

  1. “更长的文本”不适合:不希望中间和右边的列间距相等:枫树可能会向右移动一点(但应该不是通过此操作垂直移动)。
  2. 我曾多次尝试让枫树整齐地垂直居中(并且然后垂直方向根据判断进行调整),请参见许多注释掉的行。可能有更好的方法:David 暗示了命令\put(?),请参阅 MWE 中的注释和链接。欢迎提出建议,以更好地控制枫树的垂直对齐(在屏幕截图中按期望对齐,但代码似乎很乱)。

在此处输入图片描述


平均能量损失

\documentclass[a4paper]{article}

\usepackage{graphicx}

%%%http://tex.stackexchange.com/questions/79414/how-to-align-the-following-in-a-table
\usepackage{calc}


 \newlength{\mylengthydate}
%\settowidth\mylengthydate{08/1968 – 10/1971}
\settowidth\mylengthydate{08/1968\,-\,10/1971}

%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{tabularx}

\usepackage{multirow}

% \usepackage{enumitem}
% \setlist[itemize]{nosep, leftmargin=*, partopsep=0pt}

%%% tex.SX (97180) - How to get column alignment in tabularx?
\usepackage{array}
\newcolumntype{Z}{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}X}
%{>{\hsize=1.5\hsize}X>{\hsize=0.5\hsize}X}

%------------------------------------

% \usepackage{layout}

\begin{document}

%%% \layout{}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{tabularx}{\textwidth}{@{}*{1}{p{\mylengthydate}}|*{1}{X}|*{1}{Z}@{}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%\begin{tabularx}{\textwidth}{@{}*{1}{p{\mylengthydate}}*{1}{l}*{1}{X}@{}}
%\begin{tabularx}{\textwidth}{@{}*{1}{p{\mylengthydate}}*{2}{X}@{}}
%\begin{tabularx}{\textwidth}{@{}*{1}{p{\mylengthydate}}|>{\hsize=1.5\hsize}X|>{\hsize=0.5\hsize}Z@{}}
%>{\hsize=1.5\hsize}
%\begin{tabularx}{\textwidth}{@{}*{1}{p{\mylengthydate}}|*{1}{X}|*{1}{c}@{}}
%\begin{tabularx}{\textwidth}{@{}*{2}{m{\mylengthydate}}*{1}{X}@{}}
%%% even older
%%% \begin{tabularx}{\textwidth}{@{}*{1}{m{\mylengthydate}}*{1}{l}*{1}{X}@{}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% http://en.wikibooks.org/wiki/LaTeX/Importing_Graphics
%% trim option's parameter order: left bottom right top
% \includegraphics[trim = 10mm 80mm 20mm 5mm, clip, width=3cm]{chicken}
% Note the presence of clip, as the trim operation will not work without it.
% Trick: You can also use negative trim values to add blank space to your graphics, in cases where you need some manual alignment.

%%%%% newest one (with pic on left)
%\multirow{7}{*}{\includegraphics[trim=0mm 0mm 0mm -5mm, clip, scale=0.15]{./figures/maple}}
%%%%%
%\includegraphics[trim=0mm -10mm 0mm -5mm, clip, scale=0.15]{./figures/maple}
%%% older ...
%\multirow{7}{*}{\includegraphics[scale=0.15]{./figures/maple}}
%\multirow{7}{*}{\includegraphics[trim=0mm 0mm 0mm -5mm, clip, scale=0.15]{./figures/maple}}
%%%%%%%%%%% \includegraphics[trim=0mm 0mm 0mm -5mm, clip, scale=0.15]{./figures/maple} & Date of birth

Some Thing
& some text here

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
& \multirow{8}{*}{\raisebox{-.83\height}[\ht\strutbox]{\includegraphics[trim=0mm 5mm -50mm 0mm, clip, scale=0.19]{./figures/maple}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% trim option's parameter order: left bottom right top
%& \raisebox{-\totalheight}{\multirow{8}{*}{\includegraphics[trim=0mm 0mm -50mm 0mm, clip, scale=0.23]{./figures/maple}}}
%%%http://tex.stackexchange.com/questions/79414/how-to-align-the-following-in-a-table
%%%http://www.golatex.de/wiki/\raisebox
%%%%%%%%%%%%% http://chat.stackexchange.com/transcript/message/22741805#22741805
%get rid of multirow and use \begin{picture}(0,0)\put(0,-10){\includegraphics{...}}\end{picture} and adjust the coordinate until it looks right
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%& \multirow{7}{*}{\raisebox{\baselineskip}{\includegraphics[trim=0mm 0mm -50mm 0mm, clip, scale=0.21]{./figures/maple}}}
%& \multirow{7}{*}{\includegraphics[trim=0mm -5mm -50mm 0mm, clip, scale=0.20]{./figures/maple}}
%& \multirow{7}{*}{\raisebox{5mm}[5mm]{\includegraphics[trim=0mm 0mm -50mm 0mm, clip, scale=0.21]{./figures/maple}}}
%& \raisebox{2\height}{\multirow{7}{*}{\includegraphics[trim=0mm 0mm -50mm 0mm, clip, scale=0.21]{./figures/maple}}}
%& \multirow{7}{*}{\raisebox{15mm}{\includegraphics[trim=0mm 0mm -50mm 0mm, clip, scale=0.21]{./figures/maple}}}
% & 
%& \multirow{7}{*}{\raisebox{0.01\baselineskip}[\ht\strutbox]{\includegraphics[trim=0mm 0mm -50mm 0mm, clip, scale=0.21]{./figures/maple}}}
%& \multirow{7}{*}{\raisebox{\baselineskip}[\ht\strutbox]{\includegraphics[trim=0mm 0mm -50mm 0mm, clip, scale=0.21]{./figures/maple}}}
%& \multirow{7}{*}{\raisebox{-\totalheight}[20mm]{\includegraphics[trim=0mm 0mm -50mm 0mm, clip, scale=0.21]{./figures/maple}}}
%%%% "hello!" :-)
%%%%& \multirow{7}{*}{\raisebox{\ht\strutbox-1.5\height}{{\includegraphics[trim=0mm 0mm -50mm 0mm, clip, scale=0.21]{./figures/maple}}}}
%& \multirow{7}{*}{\raisebox{-25mm}{{\includegraphics[trim=0mm 0mm -50mm 0mm, clip, scale=0.21]{./figures/maple}}}}
%%% older:
%%%%& \raisebox{-\totalheight}{\multirow{8}{*}{\includegraphics[trim=0mm 24mm -50mm 7mm, clip, scale=0.23]{./figures/maple}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\\

Some Thing
& some text here
&
\\

Some Thing
& some looooooooooooooooonger text here

&
\\

&&

\\[-0.5\normalbaselineskip]

07/1968\,-\,03/1970
& some text here
&
\\

08/1968\,-\,10/1971
& some text here
&
\\


Some Thing
& some text here
&
\\


\\[-\normalbaselineskip]


\end{tabularx}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}

在此处输入图片描述

答案1

在此处输入图片描述

\documentclass[a4paper]{article}




\usepackage[framemethod=TikZ]{mdframed}


\definecolor{abcd}{RGB}{0,155,155}


\mdfsetup{skipabove=0pt,skipbelow=1.25\topskip, nobreak=true, innertopmargin=0.5\baselineskip, innerbottommargin=0.5\baselineskip, frametitleaboveskip=2pt, frametitlebelowskip=1pt, roundcorner=5pt}

\mdfdefinestyle{my_style_abcd}{%
     linecolor=abcd,middlelinewidth=0.7pt, frametitlebackgroundcolor=abcd}

\usepackage{tabularx}


%------------------------------------

% \usepackage{layout}


\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{mdframed}[style=my_style_abcd,frametitle=\color{white}{Important Information}\phantom{p}]


\noindent
\begin{tabularx}{\textwidth}{@{}l|X|c@{}}
Some Thing
& some text here
& \smash{\raisebox{-70pt}{\includegraphics[width=5em]{maple}}}
\\
Some Thing
& some text here
&
\\
Some Thing
& some looooooooooooooooonger text here
&
\\
&&
\\

07/1968\,--\,03/1970
& some text here
&
\\

08/1968\,--\,10/1971
& some text here
&
\\

Some Thing
& some text here
&
\\
\end{tabularx}

\end{mdframed}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}

相关内容