emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Manish <mailtomanish.sharma@gmail.com>
To: Mark Elston <m_elston@comcast.net>
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: Sectioning in LaTeX export
Date: Wed, 8 Apr 2009 11:47:42 +0530	[thread overview]
Message-ID: <e7cdbe30904072317i2c83d84dy8afc5caf6e71f756@mail.gmail.com> (raw)
In-Reply-To: <49DC08FB.5000808@comcast.net>

  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

--8<---------------cut here---------------start------------->8---
%\documentclass[a4paper,11pt]{memoir} % doesn't work yet

  {\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
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@

\usepackage{bookman}            % coolest font I have been able to make work
%\usepackage{kpfonts}           % part of TexLive not in Cygwin
%\usepackage{times}             % looks bad
%\usepackage{ae,aecompl}        % good, but too light

% \usepackage{showkeys}         % shows label in final document..
useful when drafting a document.


\lhead[lh-even]{\small{Cloud Computing}}
\rfoot[rf-even]{\small{\thepage~ of \pageref{LastPage}}}

\usepackage{float} % very cool package.. allows precise control of
floats.. even in multicol environments.

\usepackage{indentfirst}        % to indent the first para (British style)

  pdftitle={Document title goes here},%
  pdfauthor={Your name},%
%  pdfpagemode=FullScreen,%
%  pdfstartpage=3,%
%  frenchlinks=true,%
% for that huge landscaped image


%% \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}

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Document title goes here\\
% \author{\href{http://www.yourcommany.com/}{Your Name}}
\author{Your Name}




{\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.  }

\textbf{\Large{Version Control}}

\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

% \listoffigures
% \listoftables

%% \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
% 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{hyperref}" ("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" .
"\\subsubsection*{%s}") ("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")) ("report"
\\usepackage{hyperref}" ("\\part{%s}" . "\\part*{%s}")
("\\chapter{%s}" . "\\chapter*{%s}") ("\\section{%s}" .
"\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")) ("book"
\\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].

--8<---------------cut here---------------start------------->8---
#+CAPTION: Hourly Trend of Concurrent Jobs
#+LABEL: fig:conc-trend-over-hours
#+ATTR_LaTeX: scale=0.65
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
  \centering \includegraphics[scale=0.65]{conc-trend-over-hours.png}
  \caption{Hourly Trend of Concurrent Jobs}\label{fig:conc-trend-over-hours}}
--8<---------------cut here---------------end--------------->8---

--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
                      (if longtblp
                          (concat "\\begin{longtable}{" align "}\n")
-                       (if floatp "\\begin{table}[htb]\n"))
+                       (if floatp "\\begin{table}[H]\n"))
                      (if (or floatp longtblp)
@@ -1303,7 +1303,7 @@ The conversion is made depending of
        (cond ((and imgp (plist-get org-export-latex-options-plist
-               (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)
--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.

  reply	other threads:[~2009-04-08  6:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-08  1:52 Sectioning in LaTeX export Mark Elston
2009-04-08  2:16 ` Mark Elston
2009-04-08  6:17   ` Manish [this message]
     [not found]   ` <9135.1239160927@gamaville.dokosmarshall.org>
2009-04-08 14:57     ` Mark Elston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e7cdbe30904072317i2c83d84dy8afc5caf6e71f756@mail.gmail.com \
    --to=mailtomanish.sharma@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=m_elston@comcast.net \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).