2

I can see inline image in emacs but when export to html,the image is not displayed. Even if in pdf export, it display a text ([[file:latex.jpg]]) but not the output image.

":exports both" is there but only code exported!

#+HEADER: :headers '("\\usepackage{tikz} \\usetikzlibrary{chains}")
#+BEGIN_SRC latex :fit yes :imagemagick yes :iminoptions -density 300 :exports both :file latex.jpg
\newcommand\ann[3][]{
    \draw[arr,#1,shorten >=1pt,shorten <=1pt] ([yshift=-0.5cm]#2.south) node[below] {#3} -- (#2.south);
}
\definecolor{col1}{RGB} {238,51,34}
\definecolor{col2}{RGB} {153,221,153}
\definecolor{col3}{RGB} {255,255,51}
\tiny\begin{tikzpicture}[start chain=C1 going right,>=latex,node distance=0pt,text height=1.5ex,text depth=.25ex,
box/.style={draw,fill=yellow!5,rectangle, minimum width=.5cm,minimum height=.5cm,outer sep=0},
arr/.style={->,line width=0.2pt}
]
\foreach \val/\col [count=\i] in {1/col1,2/col1,3/col1,6/col2,5/col2,2/col2,4/col3} {
  \node[box,fill=\col,on chain] (N\i) {\val};
}
\ann[black]{N3}{cur};
\ann[black]{N5}{index};
\ann[black]{N7}{key};
\end{tikzpicture}
#+END_SRC
  • How this post help as well – DJJ Mar 10 '17 at 8:57
2

Because the output has a extra tag BEGIN_LaTex/END_LaTex there, it will impact on HTML render.

#+RESULTS:
#+BEGIN_LaTeX
[[file:latex.jpg]]
#+END_LaTeX

Add :results raw file will remove the extra tag then the inline image will show on HTML output.

#+RESULTS:
[[file:latex.jpg]]
0

Can you find the image in the jpeg file?

This configuration works for me. But I don't know how it works exactly. The best info I can give you is from this post How can we convert a range of table types (latex,org) to html when org-exporting to html?.

I'm using this macro which I found in the link above. I recommend putting it in your init file. From my understanding you can handle how latex export blocks depending whether you export to latex or html.

  #+BEGIN_SRC emacs :export no
   (setq org-babel-latex-htlatex "htlatex")
   (defmacro by-backend (&rest body)
   `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body))
   #+END_SRC



#+LATEX_HEADER:\usetikzlibrary{chains}
#+LATEX_HEADER:\usepackage{tikz}
#+OPTIONS: tex:imagemagick



#+header: :results (by-backend (pdf "latex") (t "raw"))
#+BEGIN_SRC latex :results output graphics :file test.png
\newcommand\ann[3][]{
    \draw[arr,#1,shorten >=1pt,shorten <=1pt] ([yshift=-0.5cm]#2.south) node[below] {#3} -- (#2.south);
}
\definecolor{col1}{RGB} {238,51,34}
\definecolor{col2}{RGB} {153,221,153}
\definecolor{col3}{RGB} {255,255,51}
\tiny\begin{tikzpicture}[start chain=C1 going right,>=latex,node distance=0pt,text height=1.5ex,text depth=.25ex,
box/.style={draw,fill=yellow!5,rectangle, minimum width=.5cm,minimum height=.5cm,outer sep=0},
arr/.style={->,line width=0.2pt}
]
\foreach \val/\col [count=\i] in {1/col1,2/col1,3/col1,6/col2,5/col2,2/col2,4/col3} {
  \node[box,fill=\col,on chain] (N\i) {\val};
}
\ann[black]{N3}{cur};
\ann[black]{N5}{index};
\ann[black]{N7}{key};
\end{tikzpicture}
#+END_SRC

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.