文本不会在 Tikz Node 中居中

文本不会在 Tikz Node 中居中

一直试图对齐覆盖在图像上的 tikz 节点内的标题文本

尝试了多种方法,但要么它不对齐中心,要么如果我使用 \centering 它会删除换行符(我不会

有人能给我指明正确的方向吗......

\documentclass[a4paper,10pt,twoside]{book}
\usepackage[paperwidth=210mm, paperheight=297mm, top=25.4mm,bottom=25.4mm,left=25.4mm,right=25.4mm]{geometry}
\usepackage{graphicx}
\usepackage{hvfloat}
\usepackage[export]{adjustbox}
\usepackage{caption}
\usepackage{tikz}
\usepackage[noinfo, width=216truemm, height=303truemm, cam, pdftex, center]{crop}




%get the image width
\makeatletter
\def\maxwidth{%
  \ifdim\Gin@nat@width>\textwidth
    \linewidth
  \else
    \Gin@nat@width
  \fi
}
\makeatother


\begin{document}

\newlength{\imagewidth}

\settowidth{\imagewidth}{\includegraphics{example-image}}

%portrait image full page size
\begin{figure}
\settowidth{\imagewidth}{\includegraphics{example-image}}

\begin{tikzpicture}[remember picture,overlay]
   \node [xshift=0mm, yshift=0mm, anchor=center] at (current page.center)
   {\includegraphics[max width=\dimexpr\paperwidth+6mm\relax, height=\dimexpr\paperheight+6mm\relax, keepaspectratio=true]{example-image}};
\end{tikzpicture}

\begin{tikzpicture}[remember picture,overlay]%
\node [fill=white, anchor=south, text=black, opacity=0.7, text opacity=1, inner xsep=3mm,inner ysep=3mm, xshift=0mm, yshift=0mm, align=center, rounded corners=6mm, text width=0.75\linewidth] at (current page.south) { \begin{center} \caption{
\textbf{\LARGE{King Henry VIII} \\ \\ \normalsize\textit{Tudor King of England, Ireland and Scotland}\label{fig}} \\ \\ Prone to beheading his wives  \\ \\ \textbf{``SERIOUSLY TERRIBLE DUDE"} \\ \\ \textit{``Imagine being related to this guy"}\\ No thank you! and people actually aspire to be one these people? go figure     
} 
\end{center}};
\end{tikzpicture}

\end{figure}



\end{document}

答案1

我想是这样的。

在此处输入图片描述

避免使用\\外部对齐,size 命令不接受参数,并且''不用于"关闭引号,并使用 caption 包(因为无论如何你都会加载它)来格式化标题)。否则,就像你拥有的那样。

\documentclass[a4paper,10pt,twoside]{book}
\usepackage[paperwidth=210mm, paperheight=297mm, top=25.4mm,bottom=25.4mm,left=25.4mm,right=25.4mm]{geometry}
\usepackage{graphicx}
\usepackage{hvfloat}
\usepackage[export]{adjustbox}
\usepackage{caption}
\usepackage{tikz}
\usepackage[noinfo, width=216truemm, height=303truemm, cam, pdftex, center]{crop}




%get the image width
\makeatletter
\def\maxwidth{%
  \ifdim\Gin@nat@width>\textwidth
    \linewidth
  \else
    \Gin@nat@width
  \fi
}
\makeatother


\begin{document}

\newlength{\imagewidth}

%?\settowidth{\imagewidth}{\includegraphics{example-image}}

%portrait image full page size
\begin{figure}
\settowidth{\imagewidth}{\includegraphics{example-image}}
\captionsetup{justification=centering}

\begin{tikzpicture}[remember picture,overlay]
   \node [xshift=0mm, yshift=0mm, anchor=center] at (current page.center)
   {\includegraphics[max width=\dimexpr\paperwidth+6mm\relax, height=\dimexpr\paperheight+6mm\relax, keepaspectratio=true]{example-image}};
\end{tikzpicture}

\begin{tikzpicture}[remember picture,overlay]%
\node [fill=white, anchor=south, text=black, opacity=0.7, text opacity=1, inner xsep=3mm,inner ysep=3mm, xshift=0mm, yshift=0mm, align=center, rounded corners=6mm, text width=0.75\linewidth] at (current page.south) {
\caption
{
\textbf{\LARGE King Henry VIII}\\
\textit{Tudor King of England, Ireland and Scotland}\label{fig}}

Prone to beheading his wives

\textbf{``SERIOUSLY TERRIBLE DUDE''}

\textit{``Imagine being related to this guy''}

No thank you! and people actually aspire to be one these people? go figure     
};
\end{tikzpicture}

\end{figure}



\end{document}

相关内容