-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with axis environment in RTL context (graphics layout) #318
Comments
It seems that this line of code \documentclass[12pt]{article}
\usepackage[bidi=basic]{babel}
\usepackage{pgfplots}
\babelprovide[import,main]{arabic}
\pgfplotsset{compat=1.18}
\pagestyle{empty}
\let\bbl@pictresetdir\relax
\def\bbl@pictsetdir#1{%
\ifcase\bbl@thetextdir
\let\bbl@pictresetdir\relax
\else
\ifcase#1\bodydir TLT % Remember this sets the inner boxes
\or\textdir TLT
\else\bodydir TLT \textdir TLT
\fi
% \(text|par)dir required in pgf:
\def\bbl@pictresetdir{\bodydir TRT\pardir TRT\textdir TRT\relax}%
\fi}%
\AtBeginDocument
{ \ifx\pgfpicture\@undefined\else % TODO. Allow deactivate?
\AddToHook{env/pgfpicture/begin}{\bbl@pictsetdir\@ne}%
% ---> \bbl@add\pgfinterruptpicture{\bbl@pictresetdir}%
\bbl@add\pgfsys@beginpicture{\bbl@pictsetdir\z@}%
\fi
\ifx\tikzpicture\@undefined\else
\AddToHook{env/tikzpicture/begin}{\bbl@pictsetdir\tw@}%
\bbl@add\tikz@atbegin@node{\bbl@pictresetdir}%
\bbl@sreplace\tikz{\begingroup}{\begingroup\bbl@pictsetdir\tw@}%
\fi
}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x=1cm,y=1cm,
axis lines=middle,
ymajorgrids=true,
xmajorgrids=true,
xmin=-6.2,
xmax=6.2,
ymin=-8.2,
ymax=4.2,
xtick={-6,-5,...,6},
ytick={-8,-7,...,4},]
\clip(-6.2,-8.64) rectangle (6.2,4.08);
\addplot[smooth,domain=-4:4,purple,very thick] {x^2-3};
\end{axis}
\end{tikzpicture}
\end{document}
|
I haven't forgotten about this issue. Sadly, if I remove that line other things break. I’m investigating what’s going on exactly. |
From \documentclass[12pt]{article}
\usepackage[bidi=basic]{babel}
\usepackage{pgfplots}
\babelprovide[import,main]{arabic}
\pgfplotsset{compat=1.18}
\pagestyle{empty}
\makeatletter
\let\bbl@pictresetdir\relax
\def\bbl@pictsetdir#1{%
\ifcase\bbl@thetextdir
\let\bbl@pictresetdir\relax
\else
\ifcase#1\bodydir TLT % Remember this sets the inner boxes
\or\textdir TLT
\else\bodydir TLT \textdir TLT
\fi
% \(text|par)dir required in pgf:
\def\bbl@pictresetdir{\bodydir TRT\pardir TRT\textdir TRT\relax}%
\fi}%
\AtBeginDocument
{ \ifx\pgfpicture\@undefined\else % TODO. Allow deactivate?
\AddToHook{env/pgfpicture/begin}{\bbl@pictsetdir\@ne}%
\bbl@add\pgfinterruptpicture{\bbl@pictresetdir}%
\bbl@add\pgfsys@beginpicture{\bbl@pictsetdir\z@}%
\fi
\ifx\tikzpicture\@undefined\else
\AddToHook{env/tikzpicture/begin}{\bbl@pictsetdir\tw@}%
\bbl@add\tikz@atbegin@node{\bbl@pictresetdir}%
\bbl@sreplace\tikz{\begingroup}{\begingroup\bbl@pictsetdir\tw@}%
\fi
\ifx\pgfplotsset\@undefined\else
\bbl@sreplace\pgfplotsutil@BEGIN@cell@picture{\tikzpicture}{\bbl@pictsetdir\tw@\tikzpicture}%
\fi
}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x=1cm,y=1cm,
axis lines=middle,
ymajorgrids=true,
xmajorgrids=true,
xmin=-6.2,
xmax=6.2,
ymin=-8.2,
ymax=4.2,
xtick={-6,-5,...,6},
ytick={-8,-7,...,4},]
\clip(-6.2,-8.64) rectangle (6.2,4.08);
\addplot[smooth,domain=-4:4,purple,very thick] {x^2-3};
\end{axis}
\end{tikzpicture}
\end{document}
|
Or maybe just like that \documentclass[12pt]{article}
\usepackage[bidi=basic]{babel}
\usepackage{pgfplots}
\babelprovide[import,main]{arabic}
\pgfplotsset{compat=1.18}
\pagestyle{empty}
\makeatletter
\let\bbl@pictresetdir\relax
\def\bbl@pictsetdir#1{%
\ifcase\bbl@thetextdir
\let\bbl@pictresetdir\relax
\else
\ifcase#1\bodydir TLT % Remember this sets the inner boxes
\or\textdir TLT
\else\bodydir TLT \textdir TLT
\fi
% \(text|par)dir required in pgf:
\def\bbl@pictresetdir{\bodydir TRT\pardir TRT\textdir TRT\relax}%
\fi}%
\AtBeginDocument
{ \ifx\pgfpicture\@undefined\else % TODO. Allow deactivate?
\AddToHook{env/pgfpicture/begin}{\bbl@pictsetdir\@ne}%
\bbl@add\pgfinterruptpicture{\bbl@pictresetdir}%
\bbl@add\pgfsys@beginpicture{\bbl@pictsetdir\z@}%
\fi
\ifx\tikzpicture\@undefined\else
\AddToHook{env/tikzpicture/begin}{\bbl@pictsetdir\tw@}%
\bbl@add\tikz@atbegin@node{\bbl@pictresetdir}%
\bbl@sreplace\tikz{\begingroup}{\begingroup\bbl@pictsetdir\tw@}%
\bbl@sreplace\tikzpicture{\begingroup}{\begingroup\bbl@pictsetdir\tw@}% <--
\fi
}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x=1cm,y=1cm,
axis lines=middle,
ymajorgrids=true,
xmajorgrids=true,
xmin=-6.2,
xmax=6.2,
ymin=-8.2,
ymax=4.2,
xtick={-6,-5,...,6},
ytick={-8,-7,...,4},]
\clip(-6.2,-8.64) rectangle (6.2,4.08);
\addplot[smooth,domain=-4:4,purple,very thick] {x^2-3};
\end{axis}
\end{tikzpicture}
\end{document}
|
This example of plotting using pgfplots in a right-to-left document (lualatex engine) give wrong result, the
layout=graphics
option is supposed to place tikzpicture environment in LTR context but after adding axis environment the graph exits the page.https://tex.stackexchange.com/q/729573/54817
The text was updated successfully, but these errors were encountered: