You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:Tikz节点无法应用左/右对齐的问题

解决LaTeX封面标题左对齐问题

你的问题根源在于\makecell命令默认是居中对齐,它会覆盖TikZ节点设置的align=left属性,导致标题始终居中。下面提供两种直接有效的解决方法:

方法一:修改makecell的对齐参数

给\makecell添加[l]参数指定左对齐,让单元格内的内容跟随节点的对齐设置:

\usepackage{tikz}
\usepackage{makecell}

\begin{titlepage}
\setlength{\parindent}{0pt}

\begin{figure}
\begin{tikzpicture}[remember picture,overlay]
     \node at (current page.center)      {\includegraphics[scale=0.2]{example-image-10x16}};
     \node[fill=white, scale=2, text=red, text width=94mm, align=left] at ([xshift=7mm,yshift=30mm]current page.center) {\makecell[l]{\textbf{The title goes here and it is very}\\textbf{long so it covers two lines}\\Xhline{2\arrayrulewidth}\\[-18pt]\scalebox{.35}{\textbf{\fontfamily{phv}\selectfont DEPARTMENT OF SOME ENGINEERING DISCIPLINE $\vert$ MY UNIVERSITY}}\\[-7pt]\scalebox{.35}{\textbf{\fontfamily{phv}\selectfont MY NAME HERE $\vert$ NAME OF PROGRAM}}}};
\end{tikzpicture}
\end{figure}

\end{titlepage}

方法二:移除makecell直接利用节点属性

你已经给TikZ节点设置了text width=94mm和align=left,完全可以去掉\makecell,直接用\\换行,节点会自动处理文本的左对齐和换行:

\usepackage{tikz}
\usepackage{makecell}

\begin{titlepage}
\setlength{\parindent}{0pt}

\begin{figure}
\begin{tikzpicture}[remember picture,overlay]
     \node at (current page.center)      {\includegraphics[scale=0.2]{example-image-10x16}};
     \node[fill=white, scale=2, text=red, text width=94mm, align=left] at ([xshift=7mm,yshift=30mm]current page.center) {\textbf{The title goes here and it is very}\\textbf{long so it covers two lines}\\Xhline{2\arrayrulewidth}\\[-18pt]\scalebox{.35}{\textbf{\fontfamily{phv}\selectfont DEPARTMENT OF SOME ENGINEERING DISCIPLINE $\vert$ MY UNIVERSITY}}\\[-7pt]\scalebox{.35}{\textbf{\fontfamily{phv}\selectfont MY NAME HERE $\vert$ NAME OF PROGRAM}}};
\end{tikzpicture}
\end{figure}

\end{titlepage}

两种方法都能实现标题的左对齐,你可以根据习惯选择其中一种。

内容的提问来源于stack exchange,提问作者Max

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 16:31:17