* Re: Sectioning in LaTeX export
2009-04-08 2:16 ` Mark Elston
@ 2009-04-08 6:17 ` Manish
[not found] ` <9135.1239160927@gamaville.dokosmarshall.org>
1 sibling, 0 replies; 4+ messages in thread
From: Manish @ 2009-04-08 6:17 UTC (permalink / raw)
To: Mark Elston; +Cc: Org Mode List
On Wed, Apr 8, 2009 at 7:46 AM, Mark Elston wrote:
> Mark Elston wrote:
>>
>> I have an org file I use specifically for exporting a collection of
>> other org files to pdf (using LaTeX). However, the resulting output
>> is not very much like I would like it to be.
>>
>> I am using the book class for now but will likely add my own LaTeX_CLASS
>> entry later once I get this all figured out.
>>
>> Ideally, each included file should form its own chapter. Within that
>> chapter each level 1 heading would be a section, level 2 headings would
>> be subsections, etc.
>>
>> I cannot get this to happen. Every level 1 heading is always an itemize
>> item and level 2 and below just show up as "** <heading>" lines.
>>
>> Currently, at the top of my top-level org file I have the following:
>>
>> #+TITLE: My Tasks
>> #+OPTIONS: H:4 num:t d:t
>> #+LaTeX_CLASS: book
>>
>> The title and class seem to work but the options line seems to be
>> ignored.
>>
>> How can I enforce some structure to my resulting latex code?
>>
>> Mark
>
> I forgot to mention that, right now, I am including the 'chapter' org
> files with the following approach:
>
> #+LaTeX: \chapter{Ch 1 Name}
> #+INCLUDE: "~/org/ch1.org"
>
> #+LaTeX: \chapter{Ch 2 Name}
> #+INCLUDE: "~/org/ch2.org"
>
> etc. This was the only way I could think of to get chapter divisions.
Hello Mike,
My setup is far from being ideal but it has been working for me
satisfactorily. I am sharing it below. Some large pieces have been
commented out during as part of my earlier experiments but I am
leaving them in.
- All content for a document is kept in a single file, each heading
being a chapter.
- There is a header file I include to add packages, fonts, standard
confidentiality notice, footer, page number information etc.
- I am using a report class but I wanted to title headings like
chapters etc. So a custom Latex class is defined using
org-export-latex-classes in .emacs and is used in the document using
#+LaTeX_Class directive. I forgot where I picked this up from (may
be it was a Russel Adam's post.)
- Disclaimer: I do not know Latex well at all. I just managed to
assemble a reasonably working system thing together. Integration
with Org made made it all worthwhile since I just have to adjust
header.tex for each new document and write in super-intuitive Org
style. May be I can utilize new {{{TITLE}}} like macros sometime..
Sample document
--8<---------------cut here---------------start------------->8---
#+LaTeX_Class: myreport
* Executive summary
* Assumptions
*** Assumptions set 1
*** Assumption set 2
* Phase 1
* Phase 2
* Conclusion
--8<---------------cut here---------------end--------------->8---
The sample document above when published as PDF from Org:
- has each level 1 heading turned into a chapter, level 2 heading into
a section and so on. Section and subsections are marked in 1.1.1
format. Personally I found splitting a document in different files
unnecessary with Org's folding goodness (splitting could still be
useful if the pieces can be reused.)
- has a cover page with title and author name (pulled from
header.tex - appears later in this email.)
- has a confidentiality notice and document version control page
(mandatory at my workplace.)
- has footer marking document classification (again mandatory.)
- has page numbers in the right hand corner in "current of last"
format except for on the chapter title pages.
- has a table of contents will page numbers as hyperlinks
- left top corner of the page prints the document title and right top
corner prints current chapter.
- list of figures and tables can also be added by uncommenting a
couple of lines near the end of the header.tex
header.tex
--8<---------------cut here---------------start------------->8---
%\documentclass[a4paper,11pt]{article}
\documentclass[a4paper,11pt]{report}
%\documentclass[a4paper,11pt]{memoir} % doesn't work yet
\makeatletter
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
% \if@mainmatter% remove this line if using report
\huge\bfseries \thechapter\space
% \fi% remove this line if using report
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\makeatother
\usepackage[pdftex]{graphicx,color}
\usepackage[lmargin=1.20in,%
rmargin=1.20in,%
tmargin=1.20in,%
bmargin=1.20in,%
pdftex]{geometry}
\usepackage{bookman} % coolest font I have been able to make work
%\usepackage{kpfonts} % part of TexLive not in Cygwin
%\usepackage[T1]{fontenc}
%\usepackage{pxfonts}
%\usepackage{palatino}
%\usepackage{pslatex}
%\usepackage{times} % looks bad
%\usepackage{ae,aecompl} % good, but too light
%\usepackage{helvet}
%\usepackage{lmodern}
%\usepackage{textcomp}
%\usepackage{palatcm}
% \usepackage{showkeys} % shows label in final document..
useful when drafting a document.
\usepackage{makeidx}
\makeindex
\usepackage{colortbl}
\usepackage{longtable}
\usepackage[table]{xcolor}
\usepackage{lastpage}
%\usepackage{lscape}
\usepackage{pdflscape}
\usepackage{cmap}
\usepackage{chngpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\lhead[lh-even]{\small{Cloud Computing}}
\lfoot[lf-even]{}
\chead[ch-even]{}
\cfoot[cf-even]{\small{Confidential}}
\rhead[rh-even]{\small{\rightmark}}
\rfoot[rf-even]{\small{\thepage~ of \pageref{LastPage}}}
\usepackage{float} % very cool package.. allows precise control of
floats.. even in multicol environments.
\floatstyle{plain}
\usepackage{indentfirst} % to indent the first para (British style)
\usepackage{multicol}
\usepackage[plainpages=false,colorlinks,%
pdftoolbar=true,%
pdfmenubar=false,%
pdftitle={Document title goes here},%
pdfauthor={Your name},%
linktocpage=true,%
bookmarks=true,%
plainpages=false,%
pdffitwindow=false,%
colorlinks=true,%
linkcolor=blue,%
urlcolor=blue,%
% pdfpagemode=FullScreen,%
% pdfstartpage=3,%
pdfdisplaydoctitle=true,%
% frenchlinks=true,%
pdftex]{hyperref}
%=-=-=-=-=-=-=-=-=-=-=-=-
% for that huge landscaped image
\newenvironment{changemargin}[2]{%
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}%
}%
\item[]}{\end{list}}
%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
%% \usepackage{tikz}
%% %\usepackage[colorinlistoftodos]{todonotes}
%% % Command for inserting a todo item
%% \newcommand{\todo}[1]{%
%% % Add to todo list
%% \addcontentsline{tdo}{todo}{\protect{#1}}%
%% %
%% \begin{tikzpicture}[remember picture, baseline=-0.75ex]%
%% \node [coordinate] (inText) {};
%% \end{tikzpicture}%
%% %
%% % Make the margin par
%% \marginpar{%
%% \begin{tikzpicture}[remember picture]%
%% \definecolor{orange}{rgb}{1,0.5,0}
%% \draw node[draw=black, fill=orange, text width = 3cm] (inNote)
%% {#1};%
%% \end{tikzpicture}%
%% }%
%% %
%% \begin{tikzpicture}[remember picture, overlay]%
%% \draw[draw = orange, thick]
%% ([yshift=-0.2cm] inText)
%% -| ([xshift=-0.2cm] inNote.west)
%% -| (inNote.west);
%% \end{tikzpicture}%
%% %
%% }%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \usepackage[style=altlist,toc,number=section,hypertoc,acronym]{glossary}
% \makeglossary
% \makeacronym
% \storeglosentry{bt}{name=business transaction,
% description={e.g. AP, AR etc.}}
% \storeglosentry{cp}{name=concurrent,
% description={non-interactive and relatively long running program
submitted as a batch job}}
% \newacronym{CS}{Clinical Services}{description=Clinical Services}
% \newacronym{DI}{Digital Imaging}{description=Digital Imaging}
% \newacronym{US}{Ultra Sound}{description=Ultra Sound}
% \newacronym{TPM}{Transaction Per Minute}{description=Transactions Per Minute}
%\newacronym{}{}{description=}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Document title goes here\\
\rule{\linewidth}{0.25cm}}
% \author{\href{http://www.yourcommany.com/}{Your Name}}
\author{Your Name}
\date{}
\renewcommand{\baselinestretch}{1.25}
\begin{document}
\maketitle
\begin{center}
\textbf{\Large{NOTICE}}
\end{center}
{\large The information contained in this document is not to be used
for any purpose other than the purposes for which this document is
furnished by YourCompany, nor is this document (in whole or in part) to
be reproduced or furnished to other YourCompany employees without a need
to know, or to any third party or made public without the prior
express written permission of YourCompany. }
\begin{center}
\textbf{\Large{Version Control}}
\end{center}
\begin{center}
\begin{tabular}{|p{1.5cm}|p{2cm}|p{3cm}|p{2.5cm}|p{2.5cm}|} \hline
Version no. & Version Date & Type of changes & Author & Date of
review/expiry \\ \hline
\scriptsize{1.0} & \scriptsize{2009.04.05} & \scriptsize{Initial
creation} & \scriptsize{\href{http://www.yourcompany.com/}{Your Name}}
& \scriptsize{2009.05.01} \\ \hline
\end{tabular}
\end{center}
%\pagebreak
%\pagenumbering{roman}
\tableofcontents
% \listoffigures
% \listoftables
%\pagebreak
%% \chapter{Pending Items}
%% \listoftodos
--8<---------------cut here---------------end--------------->8---
excerpt from .emacs
--8<---------------cut here---------------start------------->8---
'(org-export-latex-classes (quote (("myreport" "% BEGIN My Report Defaults
%\\documentclass[10pt,a4paper]{report}
\\input{/home/zms/personal.git/header.tex}
% END My Report Defaults
" ("\\chapter{%s}" . "\\chapter{%s}") ("\\section{%s}" .
"\\section{%s}") ("\\subsection{%s}" . "\\subsection{%s}")
("\\subsubsection{%s}" . "\\subsubsection{%s}") ("\\paragraph{%s}" .
"\\paragraph{%s}") ("\\subparagraph{%s}" . "\\subparagraph{%s}"))
("article" "\\documentclass[11pt,a4paper]{article}
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{hyperref}" ("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" .
"\\subsubsection*{%s}") ("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")) ("report"
"\\documentclass[11pt,a4paper]{report}
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{hyperref}" ("\\part{%s}" . "\\part*{%s}")
("\\chapter{%s}" . "\\chapter*{%s}") ("\\section{%s}" .
"\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")) ("book"
"\\documentclass[11pt,a4paper]{book}
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{hyperref}" ("\\part{%s}" . "\\part*{%s}")
("\\chapter{%s}" . "\\chapter*{%s}") ("\\section{%s}" .
"\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")))))
--8<---------------cut here---------------end--------------->8---
I also wanted to place images and charts appearing in the document in
the sequence they appear in my original document but LaTeX floated
them where it wished. This was irritating. Then I found
"\usepackage{float}". With this I can add an image like below and it
would appear where I wanted it due to that new [H] option instead of
[htb]. I had to edit org-export-latex.el to add that as default
though since images added via org will automatically get [htb].
Org
--8<---------------cut here---------------start------------->8---
#+CAPTION: Hourly Trend of Concurrent Jobs
#+LABEL: fig:conc-trend-over-hours
[[./conc-trend-over-hours.png]]
#+ATTR_LaTeX: scale=0.65
--8<---------------cut here---------------end--------------->8---
LaTeX
--8<---------------cut here---------------start------------->8---
\begin{figure}[H]
\centering \includegraphics[scale=0.65]{conc-trend-over-hours.png}
\caption{Hourly Trend of Concurrent Jobs}\label{fig:conc-trend-over-hours}}
\end{figure}
--8<---------------cut here---------------end--------------->8---
Patch
--8<---------------cut here---------------start------------->8---
---
lisp/org-export-latex.el | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lisp/org-export-latex.el b/lisp/org-export-latex.el
index 06f9f0f..a120966 100644
--- a/lisp/org-export-latex.el
+++ b/lisp/org-export-latex.el
@@ -1179,7 +1179,7 @@ The conversion is made depending of
STRING-BEFORE and STRING-AFTER."
(concat
(if longtblp
(concat "\\begin{longtable}{" align "}\n")
- (if floatp "\\begin{table}[htb]\n"))
+ (if floatp "\\begin{table}[H]\n"))
(if (or floatp longtblp)
(format
"\\caption{%s%s}"
@@ -1303,7 +1303,7 @@ The conversion is made depending of
STRING-BEFORE and STRING-AFTER."
(cond ((and imgp (plist-get org-export-latex-options-plist
:inline-images))
(insert
(concat
- (if floatp "\\begin{figure}[htb]\n")
+ (if floatp "\\begin{figure}[H]\n")
(format "\\centerline{\\includegraphics[%s]{%s}}\n"
(or attr org-export-latex-image-default-option)
(if (file-name-absolute-p raw-path)
--
1.6.1.2
--8<---------------cut here---------------end--------------->8---
I realize it might look some Rube Goldgergian setup, probably more
complex and messy than it needs to be. Sorry about that. Comments
and suggestions will be highly appreciated.
HTH somehow.
--
Manish
^ permalink raw reply related [flat|nested] 4+ messages in thread