如何对齐两张图片并在中间添加文字

如何对齐两张图片并在中间添加文字

我想创建一些文字,每边都有图像,例如这里。问题是,右侧溢出了边距。我该如何让这个块居中?

这就是我目前所做的。

\documentclass[11pt]{article} % select main document font size
\usepackage[a4paper]{geometry} % set paper size
% remove all possible margins
\geometry{top=2.54cm, bottom=2.54cm, left=2.54cm, right=2.54cm}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{newtxtext,newtxmath} % Times Roman font (clone)
%\usepackage{times}
\usepackage{ragged2e}       % for "\Centering" directive
\usepackage{graphicx} % omit "demo" option in real document
\usepackage{mwe} % for "\raisebox" directive
\usepackage[export]{adjustbox} % for aligning image

% indentation is zero
\setlength{\parindent}{0mm}
\begin{document}
    \begin{titlepage}
        \begin{minipage}{0.2\linewidth}
            \includegraphics[width=\textwidth,
            height=0.667\textwidth, keepaspectratio,left]{image001.jpg}
        \end{minipage}
        \begin{minipage}{0.667\linewidth}  % another guess
            \Centering
            \Large\textbf{REPUBLIKA OF ITALY}\\
            \Large\textbf{UNIVERSITETY OF PISA}\\
            \Large\textbf{RANDOM FACULTTY ETC ETC ETC}\\
            \Large\textbf{ADDITIONAL LINE}
        \end{minipage}%
        \begin{minipage}{0.2\linewidth}  % yet another guess
            \includegraphics[width=\textwidth,
            height=0.667\textwidth,keepaspectratio,right]{image002.png}
        \end{minipage}
\end{document}

答案1

欢迎来到 TeX.SE!

您对minipages 宽度的计算是错误的:

0.2\linwidth + 0.667\linwidth + 0.20\linwidth = 1,067\linwidth

因此它们会溢出右边界。

minipage我会使用表格而不是s tabularx,其中我会将中间列的计算留给 LateX:

\documentclass[11pt]{article}       % select main document font size
\usepackage[a4paper,
            margin=1in,
            showframe               % remove in real doc+ument
            ]{geometry}             % set paper size
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath}    % Times Roman font (clone)
\usepackage{ragged2e}               % for "\Centering" directive
\usepackage{tabularx}               % for table ...
\usepackage[export]{adjustbox}      % for aligning image

% indentation is zero
\setlength{\parindent}{0mm}
\begin{document}
\begin{titlepage}
    \centering
    \setkeys{Gin}{width=\linewidth,height=0.7\linewidth, keepaspectratio}
    \begin{tabularx}{\linewidth}{@{} p{0.2\linewidth}
                                >{\Centering\large\bfseries}X
                                 p{0.2\linewidth}
                                 @{} }
    \includegraphics[valign=t]{example-image-duck}
        &   REPUBLIKA OF ITALY          \par
            UNIVERSITETY OF PISA        \par
            RANDOM FACULTTY ETC ETC ETC \par
            ADDITIONAL LINE &   \includegraphics[valign=t]{example-image-duck}
    \end{tabularx}
\end{titlepage}
\end{document}

在此处输入图片描述

(灰线表示页面布局)

相关内容