I have an orgmode document with a latex codeblock:
So:
#+BEGIN_SRC latex
Hello
#+END_SRC
But when I generate a pdf, I get:
How can I remove this "Latex" description, and have only "So: Hello" shown?
Thank you!
From the comment, I don't think that org-latex-classes is quite correct. In
particular, the \usepackage* bit doesn't look correct.
The C-h v for that variable states
Alist of LaTeX classes and associated header and structure.
If #+LATEX_CLASS is set in the buffer, use its value and the
associated information. Here is the structure of each cell:
(class-name
header-string
(numbered-section . unnumbered-section)
...)
The header string
-----------------
The HEADER-STRING is the header that will be inserted into the
LaTeX file. It should contain the \documentclass macro, and
anything else that is needed for this setup. To this header, the
following commands will be added:
- Calls to \usepackage for all packages mentioned in the
variables ‘org-latex-default-packages-alist’ and
‘org-latex-packages-alist’. Thus, your header definitions
should avoid to also request these packages.
- Lines specified via "#+LATEX_HEADER:" and
"#+LATEX_HEADER_EXTRA:" keywords.
If you need more control about the sequence in which the header
is built up, or if you want to exclude one of these building
blocks for a particular class, you can use the following
macro-like placeholders.
[DEFAULT-PACKAGES] \usepackage statements for default packages
[NO-DEFAULT-PACKAGES] do not include any of the default packages
[PACKAGES] \usepackage statements for packages
[NO-PACKAGES] do not include the packages
[EXTRA] the stuff from #+LATEX_HEADER(_EXTRA)
[NO-EXTRA] do not include #+LATEX_HEADER(_EXTRA) stuff
So a header like
\documentclass{article}
[NO-DEFAULT-PACKAGES]
[EXTRA]
\providecommand{\alert}[1]{\textbf{#1}}
[PACKAGES]
will omit the default packages, and will include the
#+LATEX_HEADER and #+LATEX_HEADER_EXTRA lines, then have a call
to \providecommand, and then place \usepackage commands based
on the content of ‘org-latex-packages-alist’.
So I don't think you should have that \packages* line in there. Also, you are
better off either using the custom interface to set this variable or put it as a
setq in your init file. I don't think there is any reason to have to load it
inside an eval-after-load call.
Use the org variables mentioned in the docs above to add/remove packages. You
need to be careful with this as I've found this to be one area org-mode can be a
little fragile - there are some package dependencies which kick in differently
depending on whether your exporting a whole org file as latex, part of a
file/tree or a block.
Related
I am using Scribble to write assignments and would like to have the ability to include common text snippets somewhere in the document. For example:
#lang scribble/manual
#section{Some section}
#include-file["common-pretext.scrbl"] #; my imaginary command
Some additional text after the pretext
#section{Next section}
More text...
I would like #include-file to include the contents of common-pretext.scrbl just as if I had copy/pasted its contents at the specified position. That is, I would like its contents to be part of Some section and also properly handle Scribble commands occurring in common-pretext.scrbl.
I know that Scribble has #include-section, which is similar to what I want. However, #include-section always starts a new section and text following it until the next section is silently dropped (I am not sure why this happens, but presumably because of how the document is constructed). I also tried Racket's #include, but then the contents are not shown at all. Lastly, I tried building a macro that does what I want, but failed to make it work (if a macro is the way to go, then I am happy to share my attempts so far).
Is there such a command already and if not how can I build one?
This question is pretty old, but if you are still looking, this package does what you want:
https://docs.racket-lang.org/scribble-include-text/index.html
I have recently switched all my doc writing to org-mode. The outlining framework works for my flow and the markdown syntax allows me to write in rich text.
The default export options are, however, horrible. The default Latex template especially. The first paragraph is not indented but the rest are, the preform text blocks are cutoff at the right margin, the font is ugly, etc.
I did find a free template that I liked, but it was an elisp file. It has no instructions to install. How do I use it for exporting my documents?
This is more a matter of LaTeX customization than org-mode. The basics of e.g., using the koma classes rather than the default LaTeX classes are described in Tom Dye's document: http://orgmode.org/worg/org-tutorials/org-latex-export.html#orgheadline4 (note that the document describes the old exporter - pre-8.0 - but this particular section applies to the new exporter as well).
Alternatively, you can keep the default classes but change all the things you don't like by introducing explicit LaTeX customization in your org document. E.g., changing the font is just a matter of adding something like this to your document:
#+LATEX_HEADER: \usepackage{times}
Changing the default paragraph style can be done with
#+LATEX_HEADER: \usepackage{indentfirst}
and so on. Note that you have to know something about what LaTeX packages are available, what they do and how to install them, but that is definitely not an org-mode question.
You can define some global LaTeX class settings like this:
(setq org-export-latex-classes
(quote
(("article" "\\documentclass[11pt]{scrartcl}
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{graphicx}
\\usepackage{longtable}
\\usepackage{listings}
\\usepackage[ngerman]{babel}
\\usepackage{float}
\\usepackage{soul}
\\usepackage{amssymb}
\\usepackage{hyperref}"
("\\section{%s}" . "\\section{%s}")
("\\subsection{%s}" . "\\subsection{%s}")
("\\subsubsection{%s}" . "\\subsubsection{%s}")
("\\paragraph{%s}" . "\\paragraph{%s}")
("\\subparagraph{%s}" . "\\subparagraph{%s}")))
))
See also: The Org-article LaTeX class
I'd like to have links with the syntax [[foo bar]] go to files with the name foo bar.org. This would make using org-mode much more like using a personal local wiki.
Is this possible without breaking existing link functionality? I'd also ideally still be able to export to html, etc. with standard org-mode tools.
The best I've been able to do is something like: (setq org-link-abbrev-alist '(("o" . "file:%s.org")))
This lets me use the syntax [[o:foo bar]], but that is more verbose, and looks distractingly ugly inline. For example: The quick brown o:fox jumps over the o:lazy_dog. And [[o:foo bar][foo bar]] is even more verbose to type and edit (though it reads fine in org mode).
I don't have a ready made solution and am not a programmer, but this part is self-documenting in org.el, you can write a dedicated link search function. I cite:
"List of functions to execute a file search triggered by a link.
Functions added to this hook must accept a single argument, the search
string that was part of the file link, the part after the double
colon. The function must first check if it would like to handle this
search, for example by checking the `major-mode' or the file
extension. If it decides not to handle this search, it should just
return nil to give other functions a chance. If it does handle the
search, it must return a non-nil value to keep other functions from
trying.
Each function can access the current prefix argument through the
variable `current-prefix-arg'. Note that a single prefix is used to
force opening a link in Emacs, so it may be good to only use a numeric
or double prefix to guide the search function.
In case this is needed, a function in this hook can also restore the
window configuration before `org-open-at-point' was called using:
(set-window-configuration org-window-config-before-follow-link)")
See also Hyperlinks :: Custom Searches # gnu.org
When I do C-c C-e l to export an Org file to LaTeX it produces a document with a particular preamble. Instead of this particular preamble I would like it to use a preamble of my choice. Say that I want it to use the following preamble:
% Don't forget to qpdf --linearize the final copy
\RequirePackage[l2tabu,orthodox]{nag}% Old habits die hard. All the same, there are commands, classes and packages which are outdated and superseded. nag provides routines to warn the user about the use of those.
\immediate\write18{sh ./vc}
\input{vc}% Version control macros (for \VCDateISO in \date) http://www.ctan.org/pkg/vc
\documentclass[a4paper,12pt]{article}% pt? doublepage?
%\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}% Latin Modern (derivate of Knuth's CM)
\usepackage{fixltx2e}% \textsubscript and bugfixes for LaTeX
\usepackage{microtype}
\usepackage[strict=true]{csquotes}% Context-sensistive quotes. \enquote "" \enquote* ''. Use the integrated commands \textcquote and \blockcquote rather than biblatex internal commands to get contex sensistive quotes for them too. s/babel/autostyle in new version.
\usepackage[bookmarks,pdfborder={0 0 0}]{hyperref}% links and pdfinfo. MUST BE LOADED LAST!
\hypersetup{% Setup for hyperref
pdftitle = {[Title from #+TITLE]},
pdfauthor = {[Author from #+AUTHOR]}
}
I know that you can manipulate which packages are used on a per file basis as described in the manual but I want this preamble to be used for all files unless ) specify otherwise. The preamble I want to use includes the following:
deactivated packages (such as geometry above)
packages loaded by RequirePackage
input macros
\immediate\write18 macros
comments after usepackage macros
a hypersetup macro that recognizes #+TITLE and #+AUTHOR from Org-mode files
Deactivated packages (such as geometry above)
Org-mode recognizes LaTeX syntax inside LaTeX code-blocks, as well as when including LaTeX files in the content. (See Quoting LaTeX code.)
Packages loaded by RequirePackage
As above.
Input macros
As above.
\immediate\write18 macros
I believe this should also be as above, however there is an alternate method of dealing with this. If you create a source code block of type sh with the command within it, Org will evaluate it on export and produce the desired behaviour. You have to enable sh as a babel language type for it to work however.
(require 'ob-shell)
You can also include sh as one of the languages loaded by babel by adding it to org-babel-load-languages
(acons 'sh 't org-babel-load-languages)
Then use a code block similar to the following to run your ./vc
#+name: Test
#+begin_src sh :results output silent :exports results
./vc
#+end_src
As long as this comes before your \input{vc} line it should run the code and then include it. Simply follow the code-block with
#+LATEX: \input{vc}
And your content should be included.
Comments after usepackage macros
If the code is within a LaTeX block it should recognize it as LaTeX.
A hypersetup macro that recognizes #+TITLE and #+AUTHOR from Org-mode files.
This will have to be included within each document rather than separate. The following will provide what you desire for your macros. It will not be within the preamble, however it will end up at the top of the document and the export does behave as expected (however it will not behave as expected if added through #+INCLUDE: from org.
#+begin_latex
\hypersetup{% Setup for hyperref
pdftitle = {{{{TITLE}}}}, %Org macro to take from #+TITLE
pdfauthor = {{{{AUTHOR}}}} %Org macro to take from #+AUTHOR
}
#+end_latex
Creating your own Latex export class
If you follow the instructions in the worg tutorials (See Org Latex Export) you can create your own export-class. If you want to have full control over the packages in the preamble you would simply need to:
(add-to-list 'org-export-latex-classes
'("<CLASS NAME>"
"\\documentclass{article}
[NO-DEFAULT-PACKAGES]
[NO-PACKAGES]"
<insert desired sectioning configuration>))
You can also add in your desired packages between the \\documentclass and [NO-DEFAULT-PACKAGES] lines. The alternative would be to add them to the file itself using:
#+LATEX_CLASS: <CLASS NAME>
#+LATEX_HEADER: \usepackage{package}
...
As a third option, you can simply create a custom .sty file with the desired packages etc and include it as a single #+LATEX_HEADER:.
This doesn't answer your question, but it does allow you to do what you want.
(defun headless-latex ()
"exports to a .tex file without any preamble"
(interactive)
(org-export-as-latex 3 nil nil nil t nil)
)
This function exports the content of your ORG-mode file without any preamble. You can then \input it into a file with your desired preamble. Further reading.
I use a different method to get things done :
Define a class (I call it per-file-class for some strange reason. You can call it something else). Put this code in your .emacs :
;; per-file-class with minimal packages
(unless (find "per-file-class" org-export-latex-classes :key 'car
:test 'equal)
(add-to-list 'org-export-latex-classes
'("per-file-class"
"\\documentclass{article}
[NO-DEFAULT-PACKAGES]
[EXTRA]"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
Use this class in your org file :
#+LaTeX_CLASS: per-file-class
#+LaTeX_CLASS_OPTIONS: [10pt, a4paper]
I'm not allowed to comment (bad reputation or something ;-)) so I will post an answer. A previous answer had a very nice snippet of code for a headless export function. That code needs updating for later versions of org:
(defun headless-latex ()
"exports to a .tex file without any preamble"
(interactive)
(org-latex-export-as-latex nil nil nil t nil)
)
I would like to tell emacs to treat some keywords (or regular expressions even better) as syntactic whitespace, or, in other words, to ignore them.
For example: emacs highlighting and cedet misinterpret the code
void function() some_compiler_specific_modifier(){
...
}
as some_compiler_specific_modifier being the function name.
I have a list of the modifiers so I would love it if emacs could just ignore them whenever it finds them.
EDIT: the most important part is to make the cedet parser ignore these keywords...
To do this, you can modify semantic-lex-c-preprocessor-symbol-map to include the symbols you want to have disappear. Since you have lots of macros, and some of those macros apparently take an argument, you are probably better off create some new header, such as:
goofy.h:
#define some_compiler_specific_modifier(A)
#define some_other_compiler_modifier(B)
// ...
and then add that to semantic-lex-c-preprocessor-symbol-file.
After modifying those variables, you may need to then call semantic-c-reset-preprocessor-symbol-map to get the changes to take effect.
Alternately, use the ede-cpp-root-project type and specify the above info via the configuration in that project style. (See the doc for more on that.)