I am converting a MS Word-document (.docx) with Pandoc to LaTeX (.tex). The .docx-file contains backslashes and brackets which Pandoc converts to the corresponding LaTeX-commands (e.g. \textbackslash) what I do not want.
How can I prevent Pandoc from converting special characters?
I think pandoc is actually doing what you want. You cannot have plain backslashes in LaTeX since they would be interpreted as commands, so instead you have to use \textbackslash{}, which is the command to print a simple plain backslash in LaTeX. Try generating a PDF with LaTeX and you'll see what I mean.
If you actually want to include LaTeX commands in your Word file, I think that's not possible. (How would pandoc know whether the word user wanted to write a backslash or a LaTeX command?) However, you can transform your word doc to markdown, adjust it (in pandoc markdown you actually can include raw TeX), then export it to LaTeX.
pandoc input.docx -o file.md
# edit file.md now
pandoc file.md -o output.tex
For a more automated solution, you could look into pandoc filters. Then it's up to you how to solve the ambiguity of backslashes...
Related
I am having to work with word users who don't use bibtex. However I am trying to create a workflow where those users simply input [#citation] directly in the word doc. Then I use pandoc to convert that word doc back to markdown so I can more readily use bibtex. So here is what is in the word doc (foo.docx):
Sentence with a citation [#foo]
Then I run this pandoc code:
pandoc -s foo.docx -t markdown -o foo.md
Then resulting markdown is:
Sentence with a citation \[\#foo\]
Because of these escaped characters, I can't actually generate the citations. Happy to entertain other ideas to make this work but merging markdown and office users seems to be always a bit friction-y. The ultimately question is how to maintain citation from word to markdown?
given a file formatted as markdown occasionally interspersed with blocks of PGP, how can I strip out the PGP blocks using standard linux tools in a shell script?
The file looks like this gist
(I had to create a gist because of formatting issues)
Using sed you can do that:
sed '/^-----BEGIN PGP/,/^-----END PGP/d' file
In short: you define a range of lines between two patterns /pat1/,/pat2/ that are deleted (d).
Exporting from .org to .md (using either ox-gfm or normal markdown) org-mode adds unwanted backslashes (\) before each acute accent (`). So
`path/file` becomes \`path/file\`.
Any idea how I can turn that off?
Thanks, F
The backtick (grave accent) in Markdown is used to delimit code samples.
The equivalent in org-mode is the equal sign. For example, the following orgmode:
The file is at =/tmp/toto=
Exports as Markdown to:
The file is at `/tmp/toto`
If you want a backtick in Markdown, you have to escape it, and that is precisely what the org-mode exporter is doing.
I have some source code like example.py --help that i want to fit into a heading and export to pdf.
Unfortunately org-mode exports --help to LaTeX without escaping so I end up with an equivalent to \ndash{}help, a long dash and not to separate dashes.
I tried to escape the dashes --help which ended up like spaces in the LaTeX file and therefor as well in the pdf.
I tried to write {-}{-}help which would give me --help in the pdf and not the ligature of two dashes (long dash). But when I export {-}{-}help from org-mode, the braces will be escaped to {-}{-}help in the LaTeX export, which leads to {-}{-}help in the pdf.
I tried then to write {-}{-}help which let to {-}{-}help in the LaTeX code, hence the pdf output is {-}{-}help.
Has anyone a clue how to escape -- from org-mode the correct way?
I suceeded, but ended up with a really ugly solution:
**** example.py
#+BEGIN_LATEX
{-}{-}help
#+END_LATEX
- foo
- bar
The answer was found here: http://orgmode.org/manual/Quoting-LaTeX-code.html#Quoting-LaTeX-code
The answer from fniessen is far more practical since it does not blow up the org-file:
**** =example.py --help=
- foo
- bar
should do it. Or the version with ~ instead of =.
Normally,
=example.py --help=
should do it. Or the version with ~ instead of =.
What is the intended difference between ~code~ and =verbatim= markup in Org-mode? Exporting to HTML in both cases yields <code> tags.
Same for LaTeX...
Though, as they are fontified differently in your buffer, you can use them for different semantics.
Personally, I use "code" for var/func names, commands to be typed, etc; and "verbatim" for paths or file names.
I would have loved to have the same number of markups as there are in TeX Info, but that's not the case...
In Org 8.0 (ox-* exporters) there are a few differences.
In LaTeX
Code comes out as `\verb{sep}content{sep} where {sep} is found as an appropriate delimiter.
Verbatim comes out as \texttt{content} with certain characters escaped/protected.
In HTML and ODT
Code and Verbatim are treated identically
In TeXInfo
The same behaviour is followed as in LaTeX.