이미지 주변의 텍스트 위치 변경

이미지 주변의 텍스트 위치 변경

그래서 일종의 크리스마스 카드에 대한 시각적 레이아웃 작업을 하려고 합니다. 아이디어는 오른쪽 위 사분면 중앙에 성과 날짜가 있는 사진을 왼쪽 위와 오른쪽 아래 모서리에 두는 것입니다. 텍스트를 가로 중앙에 배치할 수 있지만 왼쪽 상단 이미지 하단(오른쪽 하단 이미지 바로 위)과 정렬됩니다. 누구든지 텍스트가 상단 이미지의 중앙을 통과하는 선에 있도록 이동하는 데 도움을 줄 수 있다면 좋을 것입니다.

\includegraphics[scale = 0.15]{Family.jpg} \hspace{\fill\textbf{\textsc{\Large{FamilyNameHere\\Date}}}\hspace*{\fill}
\newline
\hspace*{\fill}\includegraphics[scale = 0.05]{Family2.jpg}

답변1

다음을 사용하여 그래픽의 중앙 수직 정렬을 쉽게 얻을 수 있습니다.adjustbox, 키-값 옵션을 제공합니다 valign. 다음은 귀하의 경우에 사용되는 것을 보여주는 최소한의 예입니다.

여기에 이미지 설명을 입력하세요

\documentclass{article}
\usepackage[export]{adjustbox}% adjustbox loads graphicx
\begin{document}

\noindent
\includegraphics[width=.5\linewidth,valign=c]{example-image-a}%
\hfill
{\Large\bfseries
\begin{tabular}{c}
  Family Name Here \\
  Date
\end{tabular}}\hspace*{\fill}

\hfill
\includegraphics[width=.5\linewidth]{example-image-b}

\end{document}

기본 수직 정렬이 중앙에 있으므로 a를 사용하여 tabular성 및 날짜를 ​​구성했습니다.

옵션을 로드 adjustbox하면 [export]해당 키를 사용할 수 있게 됩니다.graphicx패키지.

답변2

여기에 tikz해결책이 있습니다

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
  \node[inner sep=0pt,outer sep=0pt,text width=0.5\textwidth] (a)
       {\includegraphics[width=\linewidth]{example-image-a}};
  \node[outer sep=0pt,text width=0.5\textwidth,align=center,anchor=west]
        at (a.east) {Family Name Here \\
                             Date};
  \node[inner sep=0pt,outer sep=0pt,text width=0.5\textwidth,anchor=north west]
        at (a.south east) {\includegraphics[width=\linewidth]{example-image-b}};
\end{tikzpicture}

\end{document}

여기에 이미지 설명을 입력하세요

답변3

추가 패키지가 없는 간단한 솔루션은 카드를 4개로 분할하는 것입니다 minipage. 기본적으로 미니페이지는 세로로 중앙에 위치하므로 이미지 및/또는 기타 항목을 중앙에 맞추는 데 효과적입니다.

\documentclass{article}
\usepackage{graphicx}
\def\Img#1{\includegraphics[width=\linewidth]{example-image-#1}}
\def\Family{\centering\Large\textsc{Family Name Here}\\[1em]\textit\today} 
\begin{document}
\parindent0pt
\begin{minipage}{.5\linewidth} \Img{a} \end{minipage}%
\begin{minipage}{.5\linewidth} \Family \end{minipage}\\[-1pt]
\begin{minipage}{.5\linewidth} ~ \end{minipage}%
\begin{minipage}{.5\linewidth} \Img{c} \end{minipage}\par
\end{document}

분명히 이 경우 빈 미니페이지는 \raggedleft마지막 미니페이지를 오른쪽으로 정렬하기 위해 다른 것으로 안전하게 대체될 수 있지만 여기에 텍스트나 장식을 추가하고 싶을 수도 있습니다. MWE

관련 정보