emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* puzzled about :fit for LaTeX src block
@ 2022-01-12 13:08 Eric S Fraga
  2022-01-12 17:22 ` Juan Manuel Macías
  0 siblings, 1 reply; 7+ messages in thread
From: Eric S Fraga @ 2022-01-12 13:08 UTC (permalink / raw)
  To: Emacs Org mode mailing list

[-- Attachment #1: Type: text/plain, Size: 817 bytes --]

I hope somebody here on this list can help me solve a puzzling
situation.

I have a LaTeX src block which creates an image using tikz.  In a book
I'm writing, the image, when created as a png, does not get shrunk but
is instead a full page (with the actual diagram in the top left corner).
If I create a PDF, instead, it works fine.

I have extracted this src block into a minimal file (attached).  For
that file, the image creation works fine whether I create a png or a
PDF.

I have gone through the settings in the book file but cannot find
anything that would affect this behaviour.

I am hoping somebody can suggest what it might be that makes the png
image not be shrunk!

Both emacs and org from git as of this morning.

Thank you,
eric

-- 
: Eric S Fraga, with org release_9.5.2-298-g1f48d2 in Emacs 29.0.50

[-- Attachment #2: t.org --]
[-- Type: application/vnd.lotus-organizer, Size: 552 bytes --]

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

* Re: puzzled about :fit for LaTeX src block
  2022-01-12 13:08 puzzled about :fit for LaTeX src block Eric S Fraga
@ 2022-01-12 17:22 ` Juan Manuel Macías
  2022-01-13 10:14   ` Eric S Fraga
  0 siblings, 1 reply; 7+ messages in thread
From: Juan Manuel Macías @ 2022-01-12 17:22 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: orgmode

Hi Eric,

Eric S Fraga writes:

> I have a LaTeX src block which creates an image using tikz.  In a book
> I'm writing, the image, when created as a png, does not get shrunk but
> is instead a full page (with the actual diagram in the top left corner).
> If I create a PDF, instead, it works fine.

Testing two possibilities:

What (latex) code produces that image in the output *tex file of your book?

and

C-h v RET org-format-latex-header RET: what value?

Best regards,

Juan Manuel 


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

* Re: puzzled about :fit for LaTeX src block
  2022-01-12 17:22 ` Juan Manuel Macías
@ 2022-01-13 10:14   ` Eric S Fraga
  2022-01-13 11:17     ` Juan Manuel Macías
  0 siblings, 1 reply; 7+ messages in thread
From: Eric S Fraga @ 2022-01-13 10:14 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

Hi Juan,

On Wednesday, 12 Jan 2022 at 17:22, Juan Manuel Macías wrote:
> Testing two possibilities:
>
> What (latex) code produces that image in the output *tex file of your book?

They both use the same LaTeX src block (as was in the attachment) which
creates an org link to the generated PDF or PNG file.  It's the
generation of the image file that is the problem, not how the file is
used in the end unfortunately.

> C-h v RET org-format-latex-header RET: what value?

Both the same and the default value from org.

thank you,
eric

-- 
: Eric S Fraga, with org release_9.5.2-298-g1f48d2 in Emacs 29.0.50


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

* Re: puzzled about :fit for LaTeX src block
  2022-01-13 10:14   ` Eric S Fraga
@ 2022-01-13 11:17     ` Juan Manuel Macías
  2022-01-13 12:05       ` Eric S Fraga
  0 siblings, 1 reply; 7+ messages in thread
From: Juan Manuel Macías @ 2022-01-13 11:17 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: orgmode

Hi Eric,

Eric S Fraga writes:

> Both the same and the default value from org.

I'm not sure, but maybe the problem comes from the
\documentclass{article} in org-format-latex-header. Can you try
replacing that with "\\documentclass[varwidth]{standalone}"?

Another possibility: please try adding the header arg. :imagemagick yes

Best regards,

Juan Manuel


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

* Re: puzzled about :fit for LaTeX src block
  2022-01-13 11:17     ` Juan Manuel Macías
@ 2022-01-13 12:05       ` Eric S Fraga
  2022-01-13 15:41         ` Juan Manuel Macías
  0 siblings, 1 reply; 7+ messages in thread
From: Eric S Fraga @ 2022-01-13 12:05 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

On Thursday, 13 Jan 2022 at 11:17, Juan Manuel Macías wrote:
> Another possibility: please try adding the header arg. :imagemagick yes

This did it!  Thank you.  I am curious now to find out what tool was
used instead... something for later today!

Thanks again,
eric

-- 
Professor Eric S Fraga, UCL; GnuPG: 0xc89193d8fffcf67d


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

* Re: puzzled about :fit for LaTeX src block
  2022-01-13 12:05       ` Eric S Fraga
@ 2022-01-13 15:41         ` Juan Manuel Macías
  2022-01-13 16:14           ` Eric S Fraga
  0 siblings, 1 reply; 7+ messages in thread
From: Juan Manuel Macías @ 2022-01-13 15:41 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: orgmode

Eric S Fraga writes:

> This did it!  Thank you.  I am curious now to find out what tool was
> used instead... something for later today!

Well, it seems that if you use ":imagemagick yes", the image is created
with the `org-babel-latex-convert-pdf' function. I almost always use this
to create images from latex blocks, for example:

#+begin_src latex: imagemagick yes :iminoptions -density 600
\bfseries Hello world!
#+end_src

":fit" crop the image, but you can also put in your "org-format-latex-header" "\\documentclass[varwidth]{standalone}"

On the contrary, without :imagemagick, but with results to *.png file,
`org-create-formula-image' is used, which depends on
"org-preview-latex-process-alist" and
"org-preview-latex-default-process". Since I only use LuaTeX for
everything, I have this in my init, in order to preview LaTeX fragments:

(setq luamagick
      '(luamagick
	:programs ("lualatex" "convert")
	:description "pdf > png"
	:message "you need to install lualatex and imagemagick."
	:use-xcolor t
	:image-input-type "pdf"
	:image-output-type "png"
	:image-size-adjust (1.0 . 1.0)
	:latex-compiler ("lualatex -interaction nonstopmode -output-directory %o %f")
	:image-converter ("convert -density %D -trim -antialias %f -quality 100 %O")))

(add-to-list 'org-preview-latex-process-alist luamagick)

(setq org-preview-latex-default-process 'luamagick)

Note that the -trim option for the "convert" program (last line) allows
you to crop the image from the pdf page.

Best regards,

Juan Manuel 


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

* Re: puzzled about :fit for LaTeX src block
  2022-01-13 15:41         ` Juan Manuel Macías
@ 2022-01-13 16:14           ` Eric S Fraga
  0 siblings, 0 replies; 7+ messages in thread
From: Eric S Fraga @ 2022-01-13 16:14 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

On Thursday, 13 Jan 2022 at 15:41, Juan Manuel Macías wrote:
> Well, it seems that if you use ":imagemagick yes", the image is created
> with the `org-babel-latex-convert-pdf' function. 

Indeed.  I went to the code.  Thank you.  Everything is working like I
want it!

-- 
: Eric S Fraga, with org release_9.5.2-298-g1f48d2 in Emacs 29.0.50


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

end of thread, other threads:[~2022-01-13 16:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 13:08 puzzled about :fit for LaTeX src block Eric S Fraga
2022-01-12 17:22 ` Juan Manuel Macías
2022-01-13 10:14   ` Eric S Fraga
2022-01-13 11:17     ` Juan Manuel Macías
2022-01-13 12:05       ` Eric S Fraga
2022-01-13 15:41         ` Juan Manuel Macías
2022-01-13 16:14           ` Eric S Fraga

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).