如何将图片置于表格单元格的顶部中央?

如何将图片置于表格单元格的顶部中央?

您好,我对 LaTeX 以及它的工作原理还很陌生。

我想制作一个有 6 列和 x 行的表格。

\section*{\centerline {Counter-Strike: Global Offensive}}
Her finder du information om de forskellige skins du gerne vil have.
Tabellen med information er sidst opdateret den \today. \\

\begin{longtable}{|l|l|l|l|l|l|} \hline
Våben  &Navn på skin  &Stattrak  &Kvalitet &Pris &Billede \\ \hline

AUG       &Torque  &Ja  &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal - Wear\\Factory-New\end{tabular} 
                        &\begin{tabular}[c]{@{}l@{}}1 euro\\1,6 euro \\2,4 euro \end{tabular}  
                        &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

AWP       &Redline &Ja  &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular}
                        &\begin{tabular}[c]{@{}l@{}}24 euro\\46 euro \\D.E \end{tabular}   
                        &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

CZ75 Auto   &Tigris  &Ja  &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular}
                          &\begin{tabular}[c]{@{}l@{}}2 euro\\4,5 euro \\13,7 euro \end{tabular} 
                          &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

Desert eagle &Hypnotic &Ja    &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular}
                              &\begin{tabular}[c]{@{}l@{}}D.E\\29 euro \\15,90 euro \end{tabular} 
                              &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

Famas &Pulse &Ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular}
                 &\begin{tabular}[c]{@{}l@{}}1,2 euro\\1,6 euro \\2,8 euro \end{tabular} 
                 &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

Scout/SSG08 & Abyss &Ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular}
                        &\begin{tabular}[c]{@{}l@{}}0,3 euro\\0,9euro \\4,4 euro \end{tabular} 
                        &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

 Usp-S & Caiman &Ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                    &\begin{tabular}[c]{@{}l@{}}6 euro\\11 euro \\15,2 euro \end{tabular} 
                    &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

\pagebreak

Five-Seven & Kami & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                       &\begin{tabular}[c]{@{}l@{}}0,1 euro\\0,2 euro \\0,3 euro \end{tabular} 
                       &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

G3SG1 & Azure Zebra & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                         &\begin{tabular}[c]{@{}l@{}}0,2 euro\\0,2 euro \\0,3 euro \end{tabular} 
                         &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

Galil AR & Blue Titanium & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                              &\begin{tabular}[c]{@{}l@{}}D.E\\D.E\\0,6 euro \end{tabular} 
                              &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

Glock-18 & Water Element & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                              &\begin{tabular}[c]{@{}l@{}}16 euro\\24 euro \\38,1 euro \end{tabular} 
                              &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

M4A1-S & Guardian & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                       &\begin{tabular}[c]{@{}l@{}}20,1 euro\\28,2 euro \\39,7 euro \end{tabular} 
                       &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

M4A4 & Bullet Rain & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                        &\begin{tabular}[c]{@{}l@{}}22,4 euro\\33,7 euro \\66,8 euro \end{tabular} 
                        &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

Mag 7 & Heaven Guard & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                          &\begin{tabular}[c]{@{}l@{}}0,1 euro\\0,1 euro \\0,2 euro \end{tabular} 
                          &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

Nova & Rising Skull & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                         &\begin{tabular}[c]{@{}l@{}}0,3 euro\\0,5 euro \\0,8 euro \end{tabular} 
                         &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

 AK-47 &Redline & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                     &\begin{tabular}[c]{@{}l@{}}35 euro\\115 euro \\D.E euro \end{tabular} 
                     &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

PP-bizon & Osiris & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                       &\begin{tabular}[c]{@{}l@{}}0,5 euro\\1,4 euro \\2,8 euro \end{tabular} 
                       &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

Scar-20 & Cyrex & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                     &\begin{tabular}[c]{@{}l@{}}2 euro\\4 euro \\8,3 euro \end{tabular} 
                     &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

SG 553 & Pulse & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                    &\begin{tabular}[c]{@{}l@{}}0,8 euro\\4,5 euro \\D.E \end{tabular} 
                    &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline 

Sawed-Off & HighWayMan & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                            &\begin{tabular}[c]{@{}l@{}}1,4 euro\\2,3 euro \\9,1 euro \end{tabular} 
                            &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline

Tec-9 & Isaac & ja &\begin{tabular}[c]{@{}l@{}}Field-Tested\\ Minimal-Wear\\Factory-New\end{tabular} 
                   &\begin{tabular}[c]{@{}l@{}}0,2 euro\\0,4 euro \\2,3 euro \end{tabular} 
                   &\raisebox{-\totalheight}{\includegraphics[scale=0.1]{Plot1}} \\ \hline


\end{longtable}
\end{document}

我在第 2 页和第 3 页上看到了这个以及更多内容。 在此处输入图片描述

我希望将图片放在最后一列单元格顶部,并将文本放在前三列。

我用: \documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[danish]{babel} \usepackage{amsmath,amsfonts,amssymb,amsthm} \usepackage{graphicx} \usepackage{enumerate} \usepackage{fancyhdr} \usepackage{lastpage} \usepackage{longtable} \usepackage{booktabs}

该怎么办?

答案1

在此处输入图片描述

您已使用

\raisebox{-\totalheight}{\includegraphics

将图片的基线移动到其顶部边缘,因此正如您在图像中看到的那样,顶部边缘与列中文本的基线对齐l,例如AUG

您希望图像的基线距图像顶部大约 15pt,因此

 \raisebox{\dimexpr15pt-\totalheight\relax}{\includegraphics

那么你有

  \begin{tabular}[c]{@{}l@{}}Fie

这会强制表格的基线位于其中心,这就是为什么其他条目的顶部有这么多空间,[t]因此使用内部表格的基线位于其顶行。

答案2

我建议使用该adjustbox软件包,它允许使用valign=t您想要的选项。

我还建议您简化一些输入,用宏来替代重复任务。

\documentclass[a4paper]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[danish]{babel}

\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{longtable}
\usepackage{booktabs}

\newcommand{\splitcell}[2][c]{%
  \begin{tabular}[#1]{@{}l@{}}#2\end{tabular}%
}

\newcommand{\addplot}[2][]{%
  \includegraphics[
    % scale=0.1, % what you'll use
    width=3cm,height=3cm, % for this example
    valign=t,
    #1, % other possible options
  ]{#2}%
}


\begin{document}

\section*{Counter-Strike: Global Offensive}

Her finder du information om de forskellige skins du gerne vil have.
Tabellen med information er sidst opdateret den \today. \\

\begin{longtable}{|l|l|l|l|l|l|}
\hline\endhead
\hline\endfoot
Våben  &Navn på skin  &Stattrak  &Kvalitet &Pris &Billede \\ \hline

AUG       &Torque  &Ja  &\splitcell[t]{Field-Tested\\ Minimal - Wear\\Factory-New} 
                        &\splitcell[t]{1 euro\\1,6 euro \\2,4 euro}  
                        &\addplot{duck} \\ \hline

AWP       &Redline &Ja  &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New}
                        &\splitcell[t]{24 euro\\46 euro \\D.E }   
                        &\addplot{duck} \\ \hline

CZ75 Auto   &Tigris  &Ja  &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New}
                          &\splitcell[t]{2 euro\\4,5 euro \\13,7 euro} 
                          &\addplot{duck} \\ \hline

Desert eagle &Hypnotic &Ja    &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New}
                              &\splitcell[t]{D.E\\29 euro \\15,90 euro} 
                              &\addplot{duck} \\ \hline

Famas &Pulse &Ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New}
                 &\splitcell[t]{1,2 euro\\1,6 euro \\2,8 euro} 
                 &\addplot{duck} \\ \hline

Scout/SSG08 & Abyss &Ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New}
                        &\splitcell[t]{0,3 euro\\0,9euro \\4,4 euro} 
                        &\addplot{duck} \\ \hline

 Usp-S & Caiman &Ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                    &\splitcell[t]{6 euro\\11 euro \\15,2 euro} 
                    &\addplot{duck} \\ \hline

Five-Seven & Kami & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                       &\splitcell[t]{0,1 euro\\0,2 euro \\0,3 euro} 
                       &\addplot{duck} \\ \hline

G3SG1 & Azure Zebra & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                         &\splitcell[t]{0,2 euro\\0,2 euro \\0,3 euro} 
                         &\addplot{duck} \\ \hline

Galil AR & Blue Titanium & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                              &\splitcell[t]{D.E\\D.E\\0,6 euro} 
                              &\addplot{duck} \\ \hline

Glock-18 & Water Element & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                              &\splitcell[t]{16 euro\\24 euro \\38,1 euro} 
                              &\addplot{duck} \\ \hline

M4A1-S & Guardian & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                       &\splitcell[t]{20,1 euro\\28,2 euro \\39,7 euro} 
                       &\addplot{duck} \\ \hline

M4A4 & Bullet Rain & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                        &\splitcell[t]{22,4 euro\\33,7 euro \\66,8 euro} 
                        &\addplot{duck} \\ \hline

Mag 7 & Heaven Guard & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                          &\splitcell[t]{0,1 euro\\0,1 euro \\0,2 euro} 
                          &\addplot{duck} \\ \hline

Nova & Rising Skull & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                         &\splitcell[t]{0,3 euro\\0,5 euro \\0,8 euro} 
                         &\addplot{duck} \\ \hline

 AK-47 &Redline & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                     &\splitcell[t]{35 euro\\115 euro \\D.E euro} 
                     &\addplot{duck} \\ \hline

PP-bizon & Osiris & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                       &\splitcell[t]{0,5 euro\\1,4 euro \\2,8 euro} 
                       &\addplot{duck} \\ \hline

Scar-20 & Cyrex & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                     &\splitcell[t]{2 euro\\4 euro \\8,3 euro} 
                     &\addplot{duck} \\ \hline

SG 553 & Pulse & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                    &\splitcell[t]{0,8 euro\\4,5 euro \\D.E } 
                    &\addplot{duck} \\ \hline 

Sawed-Off & HighWayMan & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                            &\splitcell[t]{1,4 euro\\2,3 euro \\9,1 euro} 
                            &\addplot{duck} \\ \hline

Tec-9 & Isaac & ja &\splitcell[t]{Field-Tested\\ Minimal-Wear\\Factory-New} 
                   &\splitcell[t]{0,2 euro\\0,4 euro \\2,3 euro} 
                   &\addplot{duck} \\ \hline

\end{longtable}
\end{document}

注意我只留下了必要的包。在这种情况下,所有单元格的顶部对齐看起来最好。

在此处输入图片描述

相关内容