0

I use following preamble in org file to export my regular documents. I want to add logo to right header, but for some reason, the \includegraphics command is not getting exported.

Here is the code

#+OPTIONS: num:nil; p:t 
    #+OPTIONS: toc:nil 
    #+LATEX_HEADER:\usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
    #+LATEX_HEADER:\geometry{a4paper} % or letterpaper (US) or a5paper or....
    #+LATEX_HEADER:\usepackage{graphicx} % support the \includegraphics command and options
    #+LATEX_HEADER:\usepackage{fancyhdr, lastpage}
    #+LATEX_HEADER:\usepackage{fontspec,xltxtra}
    #+LATEX_HEADER:\usepackage{polyglossia}
    #+LATEX_HEADER:\usepackage[Latin,Devanagari]{ucharclasses} 
    #+LATEX_HEADER:\setlength{\parindent}{0pt}
    #+LATEX_HEADER:\fancyhead{}
    #+LATEX_HEADER:\headsep= .51 cm
    #+LATEX_HEADER:\headheight= 1.5 cm
    #+LATEX_HEADER:\fancyhead[L] {{\huge \bfseries My hospital,} \\ 4th floor, My Building \\ My City square, City  }
    #+LATEX_HEADER:\fancyfoot [L]{{\Large \bfseries Dr My Name} \\{\small  MD (Med), DNB(Med), DM (Specialty)}\\ Reg No 123 }
    #+LATEX_HEADER:\fancyfoot [R]{{\Large \bfseries Dr Other Name}\\{ \small MBBS DOMS} \\  Reg No  0001}
    #+LATEX_HEADER:\renewcommand{\headrulewidth}{0pt}
    #+LATEX_HEADER:\fancyhead[R]{\includegraphics[scale=0.15]{c:/gl.jpg}}
    #+LATEX_HEADER:\pagestyle{fancy}
    #+LATEX_HEADER: \setmainfont{Halant}

Kindly help

In short, how can I use \rhead{\includegraphics[width=1cm]{example-image-a}} in org mode

2
  • Have you looked at the .tex file that is produced? That might give you a clue about what's going wrong. If that looks OK, then process the tex file directly from the command line and see if that works.
    – NickD
    Mar 16 '20 at 16:44
  • What is the error? FWIW, I produce a .tex file with C-c C-e l l and process it with latexmk -xelatex --shell-escape <file>.tex and it works fine. The reason I break the processing into two pieces is that my org-latex-pdf-process variable is set to (texi2dvi --pdf %f) which cannot deal with fontspec and xelatex apparently. What is the setting of your org-latex-pdf-process variable?
    – NickD
    Mar 16 '20 at 17:18
1

I think you read this .tex question - and your question is really how to transfer it to org-mode. Try/modify your headers according to the below code:

#+LaTeX_HEADER: \usepackage{fancyhdr}
#+LATEX_HEADER: \pagestyle{fancy}
#+ATTR_LATEX:   \setlength\headheight{26pt}
#+LATEX_HEADER: \fancyhead[R]{\includegraphics[width=1cm]{fig1.png}}

And the result is this:

enter image description here

2
  • While everything else work, only the includegraphic portion is not getting transferred to resulting intermediate tex file. It is sort of getting filtered
    – Vaibhav
    Mar 18 '20 at 4:02
  • Do you have the package wrapfig declared in your variable org-latex-default-packages-alist ? That one is responsible for figure placement.
    – Ian
    Mar 18 '20 at 8:10
0

When I replace [scale=0.15] with [width = 2cm], everything work fine .

1
  • 1
    If you read my code posted, it is exactly as you do here.
    – Ian
    Mar 19 '20 at 14:35

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.