在这个例子中(lualatex 和 TRT pagedir),图像没有出现。如何解决这个问题?
\documentclass{article}
\usepackage{graphicx}
\usepackage[demo]{rotating}
\pagedir TRT \bodydir TRT
\begin{document}
\begin{sidewaysfigure}
\centering
\includegraphics[scale=0.6]{example-image-a}
\caption{text here}
\label{fig:mine}
\end{sidewaysfigure}
\end{document}
答案1
sidewaysfigure
旋转包中的环境是在保存环境内容的命令上建立的 ,\@xrotfloat
原来lrbox
的定义 lrbox
取自latex.ltx
\def\lrbox#1{%
\edef\reserved@a{%
\endgroup
\setbox#1\hbox{%
\begingroup\aftergroup}%
\def\noexpand\@currenvir{\@currenvir}%
\def\noexpand\@currenvline{\on@line}}%
\reserved@a
\@endpefalse
\color@setgroup
\ignorespaces
}
我们需要通过添加dir TLT
到 hbox 来重新定义命令
\documentclass{article}
\usepackage{graphicx}
\usepackage[demo]{rotating}
\pagedir TRT \bodydir TRT
\makeatletter
\def\Lrbox#1{%
\edef\reserved@a{%
\endgroup
\setbox#1\hbox dir TLT{%
\begingroup\aftergroup}%
\def\noexpand\@currenvir{\@currenvir}%
\def\noexpand\@currenvline{\on@line}}%
\reserved@a
\@endpefalse
\color@setgroup
\ignorespaces
}
\AddToHook{cmd/@xrotfloat/before}{\let\lrbox\Lrbox}
\AddToHook{cmd/@rotxdblfloat/before}{\let\lrbox\Lrbox} % for double column floats
\makeatother
\begin{document}
\begin{sidewaysfigure}
\centering
\includegraphics[scale=0.6]{example-image-a}
\caption{text here}
\label{fig:mine}
\end{sidewaysfigure}
\end{document}
答案2
这实现了sidewaysefigure
使用\rotatebox
和minipage
。问题是\rotatebox
交换了高度和深度值,这会让 LaTeX 感到困惑。
\documentclass{article}
\usepackage{graphicx}
%\usepackage[demo]{rotating}
\pagedir TRT \bodydir TRT
\newenvironment{sidewaysfigure}{\figure[p]%
\begin{lrbox}{0}%
\minipage[c][\textwidth][c]{\textheight}}
{\endminipage\end{lrbox}%
\raisebox{0pt}[0pt][\textheight]{\rotatebox{90}{\usebox0}}% swap height and depth
\endfigure}
\begin{document}
\begin{sidewaysfigure}
\centering
\includegraphics[scale=0.6]{example-image-b}
\caption{text here}
\label{fig:mine}
\end{sidewaysfigure}
\end{document}