我想使用 tikz 将阿拉伯语内容(文字和图片)置于页面中央。内容并未按预期置于中央。有什么建议吗?
% !TEX TS-program=lualatex
\documentclass[a5paper,12pt,landscape]{article}
%\usepackage[empty]{fullpage}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,backgrounds}
\definecolor{gris}{HTML}{D7D7D7}
\usepackage{gradientframe}
\usepackage{garamondlibre}
\pagenumbering{gobble}
\usepackage{polyglossia}
\setmainlanguage[locale=algeria,numerals=maghrib]{arabic}
\setotherlanguage{english}
\usepackage{fontspec}
\setmainfont[Script=Arabic]{Amiri}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node (image) at (current page.center) {\gradientframe[linewidth=1px,padding =5 mm ]{\includegraphics[width=0.8\paperwidth,height=0.7\paperheight]{myimage}}};
\node[font=\fontsize{50}{60}\selectfont,below=2ex of image](word) {القراءة};
\end{tikzpicture}
\end{document}
答案1
如果您不使用该polyglossia
包,您的图像将按需要居中:
% !TEX TS-program=lualatex
\documentclass[a5paper,12pt,landscape]{article}
%\usepackage[empty]{fullpage}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,backgrounds}
\definecolor{gris}{HTML}{D7D7D7}
\usepackage{gradientframe}
\usepackage{garamondlibre}
\pagenumbering{gobble}
\usepackage[bidi=default]{babel}
\babelprovide[import]{arabic}
\babelfont[arabic]{rm}{Amiri}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node (image) at (current page.center) {\gradientframe[linewidth=1px,padding =5 mm ]{\includegraphics[width=0.8\paperwidth,height=0.7\paperheight]{example-image-duck}}};
\node[font=\fontsize{50}{60}\selectfont,below=-3ex of image](word) {\foreignlanguage{arabic}{القراءة}};
\end{tikzpicture}
\end{document}
答案2
LuaLaTeX
使用如下技巧进行编译:
\node[
anchor=center,
xshift=12.5cm,
yshift=0mm
]
\documentclass[a5paper,12pt,landscape]{article}
%\usepackage[empty]{fullpage}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,backgrounds}
\definecolor{gris}{HTML}{D7D7D7}
\pagenumbering{gobble}
\usepackage{polyglossia}
\setmainlanguage[locale=algeria,numerals=maghrib]{arabic}
\setotherlanguage{english}
\usepackage{fontspec}
\setmainfont[Script=Arabic]{Amiri}
\usepackage{gradientframe}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node[
anchor=center,
xshift=12.5cm,
yshift=0mm
] (image) at (current page.center) {\gradientframe[linewidth=1px,padding =5 mm ]{\includegraphics[width=0.8\paperwidth,height=0.7\paperheight]{example-image-a}}};
\node[font=\fontsize{50}{60}\selectfont,below=-3ex of image](word) {القراءة};
\end{tikzpicture}
\end{document}
答案3
好奇:计算“中心”时,边距、文本方向性、总 tikz 图片大小和覆盖(= 以前运行的 .aux 文件中的数据)之间似乎存在复杂的相互作用。
保持polyglossia
并使用绝对图像定位,不记住叠加,geometry
的默认设置加上较小的边距,以及稍微缩小的图像和标题以及标题位置可得出:
看起来很稳定。
平均能量损失
\documentclass[a5paper,12pt,landscape]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,backgrounds}
\definecolor{gris}{HTML}{D7D7D7}
\usepackage{gradientframe}
\usepackage{garamondlibre}
\pagenumbering{gobble}
\usepackage{polyglossia}
\setmainlanguage[locale=algeria,numerals=maghrib]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic,Renderer=HarfBuzz,Colour=blue]{Amiri}
\newfontfamily\captionfont[Scale=2.5,Script=Arabic,Renderer=HarfBuzz,Colour=red]{Amiri}
% \usepackage{fontspec}
% \setmainfont[Script=Arabic]{Amiri}
\begin{document}
\fcolorbox{black}{green!3}{%
\begin{tikzpicture}%[remember picture,overlay]
\node (image) at (current page.center) {%
\gradientframe[linewidth=1px,padding =5 mm ]{%
\includegraphics[width=0.75\textwidth]{example-image-duck}%
}%
};
\node[below=0.5ex of image](word) {{\captionfont القراءة}};
\end{tikzpicture}
}
%\selectlanguage{arabic}
%
% القراءة
%
\end{document}