emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* TikZ (circuitikz) and org-preview-latex-fragment don't play nicely together
@ 2013-12-10 15:37 Mark Edgington
  2013-12-11  8:46 ` Eric S Fraga
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Edgington @ 2013-12-10 15:37 UTC (permalink / raw)
  To: emacs-orgmode

Hello everyone,

Assume I have an org-mode file that contains the following:

----------------------

#+OPTIONS: tex:imagemagick
#+LaTeX_HEADER: \usepackage[siunitx]{circuitikz}

* Test circuit
#+begin_lateX
    \begin{circuitikz}[scale = 1.0] \draw
        (0,0) node[anchor=east]{$V_{in} -$}
        to[short, o-] (4,0)
        to[V, v_=$V_{s}(t)$] (4,2)
        to[L, l_=$L_m$] (2,2)
        to[R, l_=3<\kilo\ohm>] (1,2) -- (0,2)
        to[short, o-] (0,2)
        node[anchor=east]{$V_{in} +$};
    \end{circuitikz}
#+end_latex

--------------------

If my current emacs color-theme background is black, running
org-preview-latex-fragment on the latex block results in all
electrical-elements being invisible (only labels and lines are
visible).  The only (poor) workaround I have for this is to add the
configuration option:

#+LaTeX_HEADER: \tikzset{every picture/.style={color=gray}}

Which means that I can barely see the picture when previewed in emacs,
and that it appears in gray on the exported PDF instead of black.

Is there any way that I can make it so that without a lot of "hacks" I
can make the previews appear as white-on-black, and the PDFs print
black on white?  Would something need to change with how org-mode
handles previewing to make this possible?

Regards,

Mark

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

* Re: TikZ (circuitikz) and org-preview-latex-fragment don't play nicely together
  2013-12-10 15:37 TikZ (circuitikz) and org-preview-latex-fragment don't play nicely together Mark Edgington
@ 2013-12-11  8:46 ` Eric S Fraga
  2013-12-11 14:02   ` Mark Edgington
  0 siblings, 1 reply; 7+ messages in thread
From: Eric S Fraga @ 2013-12-11  8:46 UTC (permalink / raw)
  To: Mark Edgington; +Cc: emacs-orgmode

Mark Edgington <edgimar@gmail.com> writes:

[...]

> Is there any way that I can make it so that without a lot of "hacks" I
> can make the previews appear as white-on-black, and the PDFs print
> black on white?  Would something need to change with how org-mode
> handles previewing to make this possible?

I have the following for when I use org-tree-slide-mode for
presentations, where my colour theme is light text on dark background:

#+begin_src emacs-lisp :results none
  (setq org-format-latex-options '(:foreground "white" :background "black" :scale 3 :html-foreground "Black" :html-background "Transparent" :html-scale 1.0 :matchers ("begin" "$1" "$" "$$" "\\(" "\\["))
        org-latex-create-formula-image-program 'imagemagick
        org-tree-slide-heading-emphasis t
        )
#+end_src

I think the key is the =org-format-latex-options= variable.  I have no
idea whether this is used by the exporter or just for previewing LaTeX
in org.
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.1, Org release_8.2.4-322-gece429

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

* Re: TikZ (circuitikz) and org-preview-latex-fragment don't play nicely together
  2013-12-11  8:46 ` Eric S Fraga
@ 2013-12-11 14:02   ` Mark Edgington
  2013-12-11 15:06     ` Mark Edgington
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Edgington @ 2013-12-11 14:02 UTC (permalink / raw)
  To: Mark Edgington, emacs-orgmode

On Wed, Dec 11, 2013 at 3:46 AM, Eric S Fraga <e.fraga@ucl.ac.uk> wrote:
> Mark Edgington <edgimar@gmail.com> writes:
>
> [...]
>
>> Is there any way that I can make it so that without a lot of "hacks" I
>> can make the previews appear as white-on-black, and the PDFs print
>> black on white?  Would something need to change with how org-mode
>> handles previewing to make this possible?

[...]

> I think the key is the =org-format-latex-options= variable.  I have no
> idea whether this is used by the exporter or just for previewing LaTeX
> in org.

Hi Eric,

I tried modifying org-format-latex-options (and disabling the global
'gray' TikZ setting I had previously had) like you have it, where
:foreground and :background are specified explicitly, but the result
is the same as when :foreground and :background are set to 'default'
-- the electrical components aren't visible.

It seems like what is needed is an extra key in
org-format-latex-options that allows one to add the equivalent of
#+LaTeX_HEADER: options (which only apply when (pre)viewing fragments
within emacs.  Or is there some other way to make this work?

Regards,

Mark

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

* Re: TikZ (circuitikz) and org-preview-latex-fragment don't play nicely together
  2013-12-11 14:02   ` Mark Edgington
@ 2013-12-11 15:06     ` Mark Edgington
  2013-12-11 15:31       ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Edgington @ 2013-12-11 15:06 UTC (permalink / raw)
  To: emacs-orgmode

Ok, I dug into the problem a little deeper, and it seems that it
really can be considered a bug in the circuitikz code -- in order to
remedy it for the present time, the circuitikz.code.tex file from this
package should be modified, and the line:

\ctikzset{color/.initial=black}

must be removed / commented-out.

Nonetheless, I do think that to make it easier for people to share
org-mode files that use packages that are in some way buggy, having a
way to specify #+LaTeX_HEADER options which only apply when generating
preview images would be useful, so that workarounds for bugginess
could be added on the org-mode side, instead of requiring all
collaborators to patch their buggy libraries / packages.

Regards,

Mark

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

* Re: TikZ (circuitikz) and org-preview-latex-fragment don't play nicely together
  2013-12-11 15:06     ` Mark Edgington
@ 2013-12-11 15:31       ` Nicolas Goaziou
  2013-12-11 15:43         ` Mark Edgington
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2013-12-11 15:31 UTC (permalink / raw)
  To: Mark Edgington; +Cc: emacs-orgmode

Hello,

Mark Edgington <edgimar@gmail.com> writes:

> Nonetheless, I do think that to make it easier for people to share
> org-mode files that use packages that are in some way buggy, having a
> way to specify #+LaTeX_HEADER options which only apply when generating
> preview images would be useful, so that workarounds for bugginess
> could be added on the org-mode side, instead of requiring all
> collaborators to patch their buggy libraries / packages.

You can remove offending packages with `org-export-before-parsing-hook'
if you don't want them to be used during the export process.


Regards,

-- 
Nicolas Goaziou

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

* Re: TikZ (circuitikz) and org-preview-latex-fragment don't play nicely together
  2013-12-11 15:31       ` Nicolas Goaziou
@ 2013-12-11 15:43         ` Mark Edgington
  2013-12-11 15:55           ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Edgington @ 2013-12-11 15:43 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <n.goaziou <at> gmail.com> writes:
> 
> You can remove offending packages with `org-export-before-parsing-hook'
> if you don't want them to be used during the export process.
> 

Yes, but I need the package which is buggy.  If I were to remove it, I
couldn't preview latex fragements or export a PDF file.

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

* Re: TikZ (circuitikz) and org-preview-latex-fragment don't play nicely together
  2013-12-11 15:43         ` Mark Edgington
@ 2013-12-11 15:55           ` Nicolas Goaziou
  0 siblings, 0 replies; 7+ messages in thread
From: Nicolas Goaziou @ 2013-12-11 15:55 UTC (permalink / raw)
  To: Mark Edgington; +Cc: emacs-orgmode

Mark Edgington <edgimar@gmail.com> writes:

> Nicolas Goaziou <n.goaziou <at> gmail.com> writes:
>> 
>> You can remove offending packages with `org-export-before-parsing-hook'
>> if you don't want them to be used during the export process.
>> 
>
> Yes, but I need the package which is buggy.  If I were to remove it, I
> couldn't preview latex fragements or export a PDF file.

If you need a package only in LaTeX fragments, you can customize
`org-format-latex-header'.


Regards,
-- 
Nicolas Goaziou

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

end of thread, other threads:[~2013-12-11 15:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-10 15:37 TikZ (circuitikz) and org-preview-latex-fragment don't play nicely together Mark Edgington
2013-12-11  8:46 ` Eric S Fraga
2013-12-11 14:02   ` Mark Edgington
2013-12-11 15:06     ` Mark Edgington
2013-12-11 15:31       ` Nicolas Goaziou
2013-12-11 15:43         ` Mark Edgington
2013-12-11 15:55           ` Nicolas Goaziou

Code repositories for project(s) associated with this public 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).