I am trying to export an org file to latex (to pdf via latex) and to make latex color the inline ~code~ parts.
According to the manual (see [1] "Defining filters for individual files") this should be possible with the following:
#+BIND: org-export-filter-code-functions (tmp-latex-code-filter)
#+BEGIN_SRC emacs-lisp :exports results :results none
(defun tmp-latex-code-filter (text backend info)
"red inline code"
(when (org-export-derived-backend-p backend 'latex)
(format "{\color{red} %s }" text)))
#+END_SRC
#+latex_header: \usepackage{xcolor}
~this is a test~
However, it does not work at all and I cannot seem to pin down the problem.
I have tried to c/p the example from the manual (again see [1]) but this does not work either (it should remove the striked out text).
#+BIND: org-export-filter-strike-through-functions (tmp-f-strike-through)
#+BEGIN_SRC emacs-lisp :exports results :results none
(defun tmp-f-strike-through (s backend info) "")
#+END_SRC
~this is a test~
+this is a test+
Does anyone have an idea of how to achieve coloring ~code~ when exporting to latex?
Thank you
Edit: Using the fixed example from your answer, the produced .tex file (minus personal information):
% Created 2020-06-10 Wed 00:27
% Intended LaTeX compiler: pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{xcolor}
\hypersetup{
pdftitle={},
pdfkeywords={},
pdfsubject={},
pdfcreator={Emacs 26.3 (Org mode 9.1.9)},
pdflang={English}}
\begin{document}
\tableofcontents
\texttt{this is a test}
\sout{this is a test}
\end{document}
It is interesting to me, that it simply works for you. I have tried reinstalling emacs. My emacs was at version 25 before, however, there was no change in the output.
I have also tried it with a clean init.el
and just org mode enabled and it still does not work for me.
Edit2: Here the Emacs and Org mode version outputs
GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2019-09-16
Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.3/lisp/org/)
Edit3: That did the trick, Thank you very much. I added
# -*- org-export-allow-bind-keywords: t -*-
as first line in my org file (allowing the #+BIND
keyword for this file only) and now it works perfectly.
[1] https://orgmode.org/manual/Advanced-Export-Configuration.html
.tex
file that is produced? That should provide a fair idea of what is going on.C-u M-x emacs-version
andC-u M-x org-version
will provide that information and insert it into the current buffer, ready for cut-and-pasting it here.