我无法将第一行垂直居中在图片中间。我尝试过:
- \raisebox{-.5\height}{\includegraphics
- raisebox{\dimexpr-.5\height+.5\ht\strutbox\relax} {\includegraphics
- \adjustbox{valign=m}
问题在于它们在行之间没有垂直空白空间...你知道如何解决这个问题吗?
或者我应该使用另一种策略来使第一行居中?
非常感谢大家!
\begin{longtable}{@{\extracolsep{\fill}}c c c c c r@{}}\toprule
Var. & Aufnahme & Positionierung & Ausrichtung-Drehung Y & Führung X\&Y & Anschlag X\&Y \\
\midrule\\[3pt]
1 & {\includegraphics[width=1in]{Projekte/LV1.jpeg}}
& {\includegraphics[width=1in]{Projekte/IMG_6228.jpg}}
&
&
& \\
2 & {\includegraphics[width=1in]{Projekte/LV2.jpeg}}
& {\includegraphics[width=1in]{Projekte/IMG_6235.jpg}}
&
&
& \\
3 & {\includegraphics[width=1in]{Projekte/LV3.jpeg}}
& {\includegraphics[width=1in]{Projekte/IMG_6236.jpg}}
&
&
& \\
4 & {\includegraphics[width=1in]{Projekte/LV4.jpeg}}
&
&
&
& \\
5 & {\includegraphics[width=1in]{Projekte/LV5.jpeg}}
&
&
&
& \\
6 & {\includegraphics[width=1in]{Projekte/LV6.jpeg}}
&
&
&
& \\
7 & {\includegraphics[width=1in]{Projekte/LV7.jpeg}}& & & & \\
8 & {\includegraphics[width=1in]{Projekte/LV8.jpeg}}& & & & \\
\hline
\end{longtable}
答案1
使用adjustbox
包就可以了。假设除第一列之外的所有列都包含相同宽度的图像,那么您的表格可以写成如下形式:
\documentclass[a4paper]{scrreprt}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage[T1]{fontenc}
\usepackage[ngerman,english]{babel}
\usepackage{booktabs, longtable, makecell}
\usepackage[export]{adjustbox} % it load graphicx too
\begin{document}
\begingroup
\setlength\tabcolsep{3pt}
\adjustboxset{width=0.17\linewidth,valign=c, margin=0pt 3pt 0pt 3pt}
\begin{longtable}{@{} *{6}{c} @{}}
Var. & Aufnahme
& Positionierung
& \makecell{Ausrichtung-\\Drehung Y}
& \makecell{Führung\\ X\&Y}
& \makecell{Anschlag\\ X\&Y} \\
\toprule
1 & \adjustimage{}{example-image-a}
& \adjustimage{}{example-image-b}
& \adjustimage{}{example-image-c}
& %\adjustimage{}{example-image}
& %\adjustimage{}{example-image}
\\
2 & \adjustimage{}{example-image-a}
& \adjustimage{}{example-image-b}
& \adjustimage{}{example-image-c}
& \adjustimage{}{example-image}
& \adjustimage{}{example-image}
\\
\bottomrule
\end{longtable}
\endgroup
\end{document}
这使:
(红线表示页面布局)
如果表格中的最后五列不包含图像,则这些列将采用单元格内容。
答案2
这是否达到了目的——改编自——
https://tex.stackexchange.com/a/457216/197451
\documentclass[a4paper]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman,english]{babel}
\usepackage{longtable}
\usepackage{array}
\usepackage{booktabs}
\usepackage{graphicx}
\newcommand{\lowincludegraphics}[2][]{%
\raisebox{-0.7\dp\strutbox}{\includegraphics[#1]{#2}}%
}
\begin{document}
\begin{longtable}{
c
m{0.4\textwidth}
m{0.4\textwidth}
}
Index & \multicolumn{1}{c}{Figure1} & \multicolumn{1}{c}{Figure2} \\
\toprule
1 & \lowincludegraphics[width=\linewidth]{example-image-a}
& \lowincludegraphics[width=\linewidth]{example-image-a} \\
\bottomrule
\end{longtable}
\end{document}