public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* How to center an oversized figure (md to tex to pdf)?
@ 2022-10-18 10:17 Niko
       [not found] ` <6268051b-bc26-4c5a-a1ba-32790dbc8271n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Niko @ 2022-10-18 10:17 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1401 bytes --]

Hi all, 

I am trying to center figures on pdf. The main.md has:

![some text](some-figure.png){width=166%  #fig:figlabel}

The created .tex file has

\begin{figure}
\hypertarget{fig:figlabel}{%
\centering
\includegraphics[width=1.66\textwidth,height=\textheight]{some-figure.png}
\caption{some text}\label{fig:figlabel}
}
\end{figure}

I read from here  
<https://tex.stackexchange.com/questions/16582/center-figure-that-is-wider-than-textwidth>that 
a possible solution is to use

\usepackage[export]{adjustbox}[2011/08/13]

in latex preamble and add "center" argument to includegraphics, like so:

 \includegraphics[width=1.66\textwidth,height=\textheight, *center*
]{some-figure.png}

I tested it and it works. Now, how would one add arguments to 
includegraphics from within markdown?  Another solution I came up with 
would include redefining includegraphics in latex preamble to always have 
the "center" added, but I feel that is a bit hacky. Is there a better way?

Regards,

Niko

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6268051b-bc26-4c5a-a1ba-32790dbc8271n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 2144 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to center an oversized figure (md to tex to pdf)?
       [not found] ` <6268051b-bc26-4c5a-a1ba-32790dbc8271n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-10-21 16:40   ` John MacFarlane
       [not found]     ` <247E0FC5-5E0D-4EAD-8D9D-07DDD5732E02-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: John MacFarlane @ 2022-10-21 16:40 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

I'm confused.  The code pandoc produces already contains \centering, which should center the graphic.
Did it not do this?

> On Oct 18, 2022, at 3:17 AM, Niko <niko-k13cyrtlpCBBDLzU/O5InQ@public.gmane.org> wrote:
> 
> Hi all, 
> 
> I am trying to center figures on pdf. The main.md has:
> 
> ![some text](some-figure.png){width=166%  #fig:figlabel}
> 
> The created .tex file has
> 
> \begin{figure}
> \hypertarget{fig:figlabel}{%
> \centering
> \includegraphics[width=1.66\textwidth,height=\textheight]{some-figure.png}
> \caption{some text}\label{fig:figlabel}
> }
> \end{figure}
> 
> I read from here that a possible solution is to use
> 
> \usepackage[export]{adjustbox}[2011/08/13]
> 
> in latex preamble and add "center" argument to includegraphics, like so:
> 
>  \includegraphics[width=1.66\textwidth,height=\textheight, center]{some-figure.png}
> 
> I tested it and it works. Now, how would one add arguments to includegraphics from within markdown?  Another solution I came up with would include redefining includegraphics in latex preamble to always have the "center" added, but I feel that is a bit hacky. Is there a better way?
> 
> Regards,
> 
> Niko
> 
> -- 
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6268051b-bc26-4c5a-a1ba-32790dbc8271n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/247E0FC5-5E0D-4EAD-8D9D-07DDD5732E02%40gmail.com.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to center an oversized figure (md to tex to pdf)?
       [not found]     ` <247E0FC5-5E0D-4EAD-8D9D-07DDD5732E02-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2022-10-22  9:30       ` Niko
       [not found]         ` <92231fef-1dff-4799-b934-eaf85de4dec8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Niko @ 2022-10-22  9:30 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 2355 bytes --]

If the figure is oversized (larger than \textwidth), it needs special 
handling. Otherwise, in the pdf the figure will start at the end of left 
margin, and only overflow to the right margin. 

On Friday, 21 October 2022 at 19:40:56 UTC+3 fiddlosopher wrote:

> I'm confused. The code pandoc produces already contains \centering, which 
> should center the graphic.
> Did it not do this?
>
> > On Oct 18, 2022, at 3:17 AM, Niko <ni...-k13cyrtlpCBBDLzU/O5InQ@public.gmane.org> wrote:
> > 
> > Hi all, 
> > 
> > I am trying to center figures on pdf. The main.md has:
> > 
> > ![some text](some-figure.png){width=166% #fig:figlabel}
> > 
> > The created .tex file has
> > 
> > \begin{figure}
> > \hypertarget{fig:figlabel}{%
> > \centering
> > 
> \includegraphics[width=1.66\textwidth,height=\textheight]{some-figure.png}
> > \caption{some text}\label{fig:figlabel}
> > }
> > \end{figure}
> > 
> > I read from here that a possible solution is to use
> > 
> > \usepackage[export]{adjustbox}[2011/08/13]
> > 
> > in latex preamble and add "center" argument to includegraphics, like so:
> > 
> > \includegraphics[width=1.66\textwidth,height=\textheight, 
> center]{some-figure.png}
> > 
> > I tested it and it works. Now, how would one add arguments to 
> includegraphics from within markdown? Another solution I came up with would 
> include redefining includegraphics in latex preamble to always have the 
> "center" added, but I feel that is a bit hacky. Is there a better way?
> > 
> > Regards,
> > 
> > Niko
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "pandoc-discuss" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/6268051b-bc26-4c5a-a1ba-32790dbc8271n%40googlegroups.com
> .
>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/92231fef-1dff-4799-b934-eaf85de4dec8n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 3564 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to center an oversized figure (md to tex to pdf)?
       [not found]         ` <92231fef-1dff-4799-b934-eaf85de4dec8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-10-24 18:06           ` John MacFarlane
  0 siblings, 0 replies; 5+ messages in thread
From: John MacFarlane @ 2022-10-24 18:06 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


I haven't been able to get good results using adjustbox and center, in my tests.
Either the aspect ratio is wrong or the whole thing is not 1.66 size.

In any case, I wouldn't want to depend on adjustbox in the default template.

If this solution actually worked, I'd be tempted to allow a center attribute to
propagate through (though there is risk that people will do this and then get
confused because the custom template doesnt' contain adjustbox).  But I can't
get it to work well, even specifying the specific version of adjustbox as you do.


> On Oct 22, 2022, at 2:30 AM, Niko <niko-k13cyrtlpCBBDLzU/O5InQ@public.gmane.org> wrote:
> 
> If the figure is oversized (larger than \textwidth), it needs special handling. Otherwise, in the pdf the figure will start at the end of left margin, and only overflow to the right margin. 
> 
> On Friday, 21 October 2022 at 19:40:56 UTC+3 fiddlosopher wrote:
> I'm confused. The code pandoc produces already contains \centering, which should center the graphic. 
> Did it not do this? 
> 
> > On Oct 18, 2022, at 3:17 AM, Niko <ni...-k13cyrtlpCBBDLzU/O5InQ@public.gmane.org> wrote: 
> > 
> > Hi all, 
> > 
> > I am trying to center figures on pdf. The main.md has: 
> > 
> > ![some text](some-figure.png){width=166% #fig:figlabel} 
> > 
> > The created .tex file has 
> > 
> > \begin{figure} 
> > \hypertarget{fig:figlabel}{% 
> > \centering 
> > \includegraphics[width=1.66\textwidth,height=\textheight]{some-figure.png} 
> > \caption{some text}\label{fig:figlabel} 
> > } 
> > \end{figure} 
> > 
> > I read from here that a possible solution is to use 
> > 
> > \usepackage[export]{adjustbox}[2011/08/13] 
> > 
> > in latex preamble and add "center" argument to includegraphics, like so: 
> > 
> > \includegraphics[width=1.66\textwidth,height=\textheight, center]{some-figure.png} 
> > 
> > I tested it and it works. Now, how would one add arguments to includegraphics from within markdown? Another solution I came up with would include redefining includegraphics in latex preamble to always have the "center" added, but I feel that is a bit hacky. Is there a better way? 
> > 
> > Regards, 
> > 
> > Niko 
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. 
> > To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
> > To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6268051b-bc26-4c5a-a1ba-32790dbc8271n%40googlegroups.com. 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/92231fef-1dff-4799-b934-eaf85de4dec8n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/0D15DED9-6919-491B-A635-A08F7DC42693%40gmail.com.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* How to center an oversized figure (md to tex to pdf)?
@ 2022-10-18 10:19 Niko
  0 siblings, 0 replies; 5+ messages in thread
From: Niko @ 2022-10-18 10:19 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1444 bytes --]

Hi all, 

I am trying to center figures on pdf. The main.md has:

![some text](some-figure.png){width=166%  #fig:figlabel}

The created .tex file has

\begin{figure}
\hypertarget{fig:figlabel}{%
\centering
\includegraphics[width=1.66\textwidth,height=\textheight]{some-figure.png}
\caption{some text}\label{fig:figlabel}
}
\end{figure}

I read from SO (link removed) that a possible solution is to use

\usepackage[export]{adjustbox}[2011/08/13]

in latex preamble and add "center" argument to includegraphics, like so:

 \includegraphics[width=1.66\textwidth,height=\textheight, *center*
]{some-figure.png}

I tested it and it works. Now, how would one add arguments to 
includegraphics from within markdown?  Another solution I came up with 
would include redefining includegraphics in latex preamble to always have 
the "center" added, but I feel that is a bit hacky. Is there a better way?

Regards,

Niko

(PS. For some reason my messages are getting removed automatically. Trying 
to post without links to see if that affects)

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/b18d68f1-e4d0-4b45-ab10-03f890838484n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 2205 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-24 18:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18 10:17 How to center an oversized figure (md to tex to pdf)? Niko
     [not found] ` <6268051b-bc26-4c5a-a1ba-32790dbc8271n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-10-21 16:40   ` John MacFarlane
     [not found]     ` <247E0FC5-5E0D-4EAD-8D9D-07DDD5732E02-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-10-22  9:30       ` Niko
     [not found]         ` <92231fef-1dff-4799-b934-eaf85de4dec8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-10-24 18:06           ` John MacFarlane
2022-10-18 10:19 Niko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).