-1

I am trying to have a specific figure fit within the required margins. I drew 2 lines with the text "Reconstruction" and "Forecasting" as shown below but they somehow ignore the margins. I have tried the solution from Tikz's picture: out of the page margin but it does not seem to work in my case.

I am finding it impossible to produce a MWE so I am pasting a copy of the overleaf project here. The problem is in 4)experiments.tex lines 575 and 576. https://www.overleaf.com/7541219539fgfjvjckfvzj#aff1f6. I hope to get some help please.

\draw[line width=0.3mm] ([xshift=0.25cm,yshift=0.1cm]imagea.north west) -- ([xshift=-0.25cm,yshift=0.1cm]imagec.north east)node[midway,above] {\strut Reconstruction};
\draw[line width=0.3mm] ([xshift=0.25cm,yshift=0.1cm]imaged.north west) -- ([xshift=-0.25cm,yshift=0.1cm]imageh.north east)node[midway,above] {\strut Forecasting};

enter image description here

Edit: Here is a longer snippet of the code that produces the figure. It can also be viewed in the overleaf project from lines 404 to 579.

\definetrim{kit_rgbd}{8cm 0 6cm 2cm} % {left bottom right top}
\begin{figure*}[t!]
\centering
\subfloat{
\begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}]
    \node[anchor=south west,inner sep=0] (imagea) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/mod/0168.png}};
    \begin{scope}[anchor=north west]
        \node[draw,fill=white,rotate=90] at (0,0) {Mod};
    \end{scope}
    \node[lbl=north west,draw,fill=white] at (imagea.north west) {\tiny{1}};
\end{tikzpicture}}\imagehspace
\subfloat{
\begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}]
    \node[anchor=south west,inner sep=0] (imageb) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/mod/0180.png}};
    \node[lbl=north west,draw,fill=white] at (imageb.north west) {\tiny{2}};
\end{tikzpicture}}\imagehspace
\subfloat{
\begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}]
    \node[anchor=south west,inner sep=0] (imagec) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/mod/0195.png}};
    \node[lbl=north west,draw,fill=white] at (imagec.north west) {\tiny{3}};
\end{tikzpicture}}\imagehspace
\subfloat{
\begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}]
    \node[anchor=south west,inner sep=0] (imaged) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/mod/0207.png}};
    \node[lbl=north west,draw,fill=white] at (imaged.north west) {\tiny{4}};
\end{tikzpicture}}\imagehspace
\subfloat{
\begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}]
    \node[anchor=south west,inner sep=0] (imagee) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/mod/0219.png}};
    \node[lbl=north west,draw,fill=white] at (imagee.north west) {\tiny{5}};
\end{tikzpicture}}\imagehspace
\subfloat{
\begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}]
    \node[anchor=south west,inner sep=0] (imagef) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/mod/0231.png}};
    \node[lbl=north west,draw,fill=white] at (imagef.north west) {\tiny{6}};
\end{tikzpicture}}\imagehspace
\subfloat{
\begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}]
    \node[anchor=south west,inner sep=0] (imageg) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/mod/0243.png}};
    \node[lbl=north west,draw,fill=white] at (imageg.north west) {\tiny{7}};
\end{tikzpicture}}\imagehspace
\subfloat{
\begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}]
    \node[anchor=south west,inner sep=0] (imageh) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/mod/0255.png}};
    \node[lbl=north west,draw,fill=white] at (imageh.north west) {\tiny{8}};
\end{tikzpicture}}\imagevspace

% % % % % % ours % % % % % %

\subfloat{ \begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}] \node[anchor=south west,inner sep=0] (image1) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/ours/0168.png}}; \begin{scope}[anchor=north west] \node[draw,fill=white,rotate=90] at (0,0) {Ours}; \end{scope} \node[lbl=north west,draw,fill=white] at (image1.north west) {\tiny{1}}; \end{tikzpicture}}\imagehspace \subfloat{ \begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}] \node[anchor=south west,inner sep=0] (image2) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/ours/0180.png}}; \node[lbl=north west,draw,fill=white] at (image2.north west) {\tiny{2}}; \end{tikzpicture}}\imagehspace \subfloat{ \begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}] \node[inner sep=0] (image3) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/ours/0195.png}}; \node[lbl=north west,draw,fill=white] at (image3.north west) {\tiny{3}}; \end{tikzpicture}}\imagehspace \subfloat{ \begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}] \node[anchor=south west,inner sep=0] (image4) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/ours/0207.png}}; \node[lbl=north west,draw,fill=white] at (image4.north west) {\tiny{4}}; \end{tikzpicture}}\imagehspace \subfloat{ \begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}] \node[anchor=south west,inner sep=0] (image5) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/ours/0219.png}}; \node[lbl=north west,draw,fill=white] at (image5.north west) {\tiny{5}}; \end{tikzpicture}}\imagehspace \subfloat{ \begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}] \node[anchor=south west,inner sep=0] (image6) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/ours/0231.png}}; \node[lbl=north west,draw,fill=white] at (image6.north west) {\tiny{6}}; \end{tikzpicture}}\imagehspace \subfloat{ \begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}] \node[anchor=south west,inner sep=0] (image7) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/ours/0243.png}}; \node[lbl=north west,draw,fill=white] at (image7.north west) {\tiny{7}}; \end{tikzpicture}}\imagehspace \subfloat{ \begin{tikzpicture}[remember picture,lbl/.style = {draw, outer sep=2\pgflinewidth, fill=white, anchor=#1}] \node[anchor=south west,inner sep=0] (image8) at (0,0) {\frameincludegraphicsblack[width=\imagewidth,kit_rgbd,clip]{figures/experiments/kit_rgbd/subject_6/task_3_k_pouring/take_8/ours/0255.png}}; \node[lbl=north west,draw,fill=white] at (image8.north west) {\tiny{8}}; \end{tikzpicture}}\vspace{0.2cm}

% % % % % % % % % % % % % % % contact classification % % % % % % % % % % % % % % %

\noindent\begin{tabular}{@{}rl}
\footnotesize{True Left} & \begin{tikzpicture}[remember picture] \node[inner sep=0] (bar1) at (0,0) {\includegraphics[width=0.85\textwidth,height=\barheight\textwidth,trim={0 0 0 0},clip]{figures/experiments/kit_rgbd/true_l.png}}; \end{tikzpicture}\ \footnotesize{Pred Left} & \begin{tikzpicture}[remember picture] \node[inner sep=0] (bar2) at (0,0) {\includegraphics[width=0.85\textwidth,height=\barheight\textwidth,trim={0 0 0 0},clip]{figures/experiments/kit_rgbd/pred_l.png}}; \end{tikzpicture}\ \footnotesize{True Right} & \begin{tikzpicture}[remember picture] \node[inner sep=0] (bar3) at (0,0) {\includegraphics[width=0.85\textwidth,height=\barheight\textwidth,trim={0 0 0 0},clip]{figures/experiments/kit_rgbd/true_r.png}}; \end{tikzpicture}\ \footnotesize{Pred Right} & \begin{tikzpicture}[remember picture] \node[inner sep=0] (bar4) at (0,0) {\includegraphics[width=0.85\textwidth,height=\barheight\textwidth,trim={0 0 0 0},clip]{figures/experiments/kit_rgbd/pred_r.png}}; \end{tikzpicture}\ \end{tabular}

% % % % % % bars % % % % % %

\begin{tikzpicture}[overlay,remember picture] \begin{scope}

% min t = 168
% max t = 255

% take (t - min) / length
% length = 84

% image1 t=0
\def\time1{0}
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(image1.south)+(0,0)$)--($(bar1.north west)+(\n1,0)$);
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(bar1.north west)+(\n1,0)$)--($(bar2.south west)+(\n1,0)$);

% image2 t=40
\def\time1{0.13793103448275862}
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(image2.south)+(0,0)$)--($(bar1.north west)+(\n1,0)$);
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(bar1.north west)+(\n1,0)$)--($(bar2.south west)+(\n1,0)$);

% image3 t=70
\def\time1{0.3103448275862069}
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(image3.south)+(0,0)$)--($(bar1.north west)+(\n1,0)$);
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(bar1.north west)+(\n1,0)$)--($(bar2.south west)+(\n1,0)$);

% image4 t=92
\def\time1{0.4482758620689655}
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(image4.south)+(0,0)$)--($(bar1.north west)+(\n1,0)$);
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(bar1.north west)+(\n1,0)$)--($(bar4.south west)+(\n1,0)$);

% image5 t=120
\def\time1{0.5862068965517241}
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(image5.south)+(0,0)$)--($(bar1.north west)+(\n1,0)$);
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(bar1.north west)+(\n1,0)$)--($(bar4.south west)+(\n1,0)$);

% image6 t=160
\def\time1{0.7241379310344828}
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(image6.south)+(0,0)$)--($(bar1.north west)+(\n1,0)$);
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(bar1.north west)+(\n1,0)$)--($(bar4.south west)+(\n1,0)$);

% image7 t=190
\def\time1{0.8620689655172413}
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(image7.south)+(0,0)$)--($(bar1.north west)+(\n1,0)$);
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(bar1.north west)+(\n1,0)$)--($(bar4.south west)+(\n1,0)$);

% image8 t=220
\def\time1{1.0}
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(image8.south)+(0,0)$)--($(bar1.north west)+(\n1,0)$);
\draw let \p1=(bar1.west), \p2=(bar1.east), \n1={\time1*(\x2-\x1)} in [dotted, line width=0.5mm] ($(bar1.north west)+(\n1,0)$)--($(bar4.south west)+(\n1,0)$);

\draw[line width=0.3mm] ([xshift=0.25cm,yshift=0.1cm]imagea.north west) -- ([xshift=-0.25cm,yshift=0.1cm]imagec.north east)node[midway,above] {\strut Reconstruction};
\draw[line width=0.3mm] ([xshift=0.25cm,yshift=0.1cm]imaged.north west) -- ([xshift=-0.25cm,yshift=0.1cm]imageh.north east)node[midway,above] {\strut Forecasting};

\end{scope} \end{tikzpicture}

The line and text is overshooting the page margin.

enter image description here

Kong
  • 2,313
  • 4
    Please extend your code fragment to complete small document, which reproduce your problem. If you not able to do this, how we can see, what you doing? – Zarko Dec 28 '23 at 17:16
  • @Zarko i have included a longer snippet of the code. It can also be viewed in the link to the overleaf project which I felt would be better since it directly showcases the problem. – Kong Dec 28 '23 at 17:25
  • 3
    @Kong External links might rot and your question will become useless to future users with the same problem. Always include a small, but compilable test document directly in your question and not as an external link. – samcarter_is_at_topanswers.xyz Dec 28 '23 at 17:28
  • 1
    Moreover, we do not know what \frameincludegraph... is doing. There are instructions on how create a useful MWE here: https://tex.meta.stackexchange.com/questions/228/ive-just-been-asked-to-write-a-minimal-working-example-mwe-what-is-that – Rmano Dec 28 '23 at 18:12
  • 2
    Do you realize that \def\time1{0.7241379310344828} does not define a macro named \time1? Macro names can't have digits in them – Rmano Dec 28 '23 at 18:15

1 Answers1

1

Edit:
Apparently I not understand what OP is after. So one more guessing. If this time I again misunderstand you, I will delete my answer

\documentclass[]{article}
\usepackage[margin=1in,top=0.5in,%
            headheight=6\baselineskip,headsep=2\baselineskip,includehead,%
            ]{geometry}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}

\usepackage{graphicx} \usepackage{tabularray} \UseTblrLibrary{booktabs}

\usepackage{fancyhdr} \pagestyle{fancy} \renewcommand{\headrulewidth}{0pt} \chead{% \begin{tblr}{colspec={cX[c, m]}, rowsep=5pt} Reconstruction & & Forecasting \ \cmidrule{1-1} \cmidrule{3-3}
\includegraphics[width=22mm]{example-image-duck} & & \includegraphics[width=22mm]{example-image-duck} \end{tblr} } \begin{document} \lipsum[1] \end{document}

enter image description here

(red lines shows part of page layout)

Zarko
  • 296,517
  • sorry what i meant by margins was that the text and lines I drew are going above the top page margin. They are ignoring the page margins. The drawings and figures need to be pushed below the margin. – Kong Dec 28 '23 at 17:43
  • Please, provide a sketch, what you after. Is maybe http://tex.stackexchange.com/questions/284825/ close to what you after? – Zarko Dec 28 '23 at 17:45
  • i have updated my post to include 2 figures side by side. The one on the left does not overshoot the margin, the one on the right overshoots the margin. – Kong Dec 28 '23 at 17:56
  • @Zarki, you are probably right this time --- the problem is that not knowing what the several macros of the OP are doing, it's impossible to spot the error. The \def\time1{whatever} is an evident one, but $DEITY knows... – Rmano Dec 28 '23 at 18:14