emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Sectioning in LaTeX export
@ 2009-04-08  1:52 Mark Elston
  2009-04-08  2:16 ` Mark Elston
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Elston @ 2009-04-08  1:52 UTC (permalink / raw)
  To: Org Mode List

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sectioning in LaTeX export
  2009-04-08  1:52 Sectioning in LaTeX export Mark Elston
@ 2009-04-08  2:16 ` Mark Elston
  2009-04-08  6:17   ` Manish
       [not found]   ` <9135.1239160927@gamaville.dokosmarshall.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Elston @ 2009-04-08  2:16 UTC (permalink / raw)
  To: Org Mode List

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.

Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

* 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

* Re: Sectioning in LaTeX export
       [not found]   ` <9135.1239160927@gamaville.dokosmarshall.org>
@ 2009-04-08 14:57     ` Mark Elston
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Elston @ 2009-04-08 14:57 UTC (permalink / raw)
  To: org-mode emacs-orgmode

Nick Dokos wrote:
> Mark,
> 
> I tried (on Org-mode version 6.25b) the following simple test and it
> seems to work OK (see attached tex.file) - note that (at least afaik)
> there is a one-one correspondence between the heading level and the
> LaTeX construct: that is controlled in a limited way by the variable
> org-export-latex-classes (see below).
> 
> * main file book.org:
> 
> ,----
> | #+TITLE:  My Tasks
> | #+OPTIONS: H:5 num:t d:nil
> | #+LaTeX_CLASS: book
> | 
> | 
> | * Part 1
> | #+INCLUDE: "ch1.org"
> | 
> | #+INCLUDE: "ch2.org"
> `----
> 

It appears that the key is in this file.  This file *must* have
a headline of level 1 or nothing else works.  Who knew?  (Except
Carsten, of course)  :)

> 
> * Chapter 1 file:
> 
> ,----
> | ** First chapter
> | *** Introduction
> | *** Elaboration
> | *** Proof
> | **** Subsection 3.1
> | **** Subsection 3.2
> | *** Summary
> `----
> 
> * Chapter 2 file:
> 
> ,----
> | ** Chapter 2
> | *** Section 1
> | *** Section 2
> | **** Subsection 2.1
> | **** Subsection 2.2
> | *** Section 3
> | *** Section 4
> `----
> 
> But you'll have to compromise a bit: 
> 
> o you'll have to make the chapters at least level 1 - but you can
>   use M-S-<right> or M-S-<left> to demote/promote the whole tree,
>   as long as the top level is >= 1.
> 

Your example doesn't show this as both have level 2 trees, but, yes,
if the main file has a level 1 headline *before* including any further
files then the structure is honored.

This is a little awkward but not too bad.

> o you can edit the book portion of org-export-latex-classes to change the
>   correspondence of level to LaTeX construct:
> 

Yeah, I am using a custom org-export-latex-classes so I can use memoir
and do some further customizations.

> ...
> o Note also that the H:5 setting controls not only the tocdepth
> in LaTeX but it also affects how levels >= (H value) correspond
> to LaTeX constructs - what would become a subsection given a high
> enough value for H, actually becomes an \itemize for a lower value.
> I observer this experimentally and I have no idea if there is some
> other way of getting around it.
> 

I am going to play around with this.  I looked at the code for the latex
exporting and had trouble following it (I am not a lisp expert by any
means).

Thanks for discovering this.  I would not have tried this as I am
keeping different kinds of information in different files and simply
using a 'main' file to group them for 'pretty-printing'.  It's not
really a book.  It is my notes of ongoing tasks for my team that I use
for my 'Management by Walking Around' style... :)  One chapter is for
ongoing tasks, one chapter for bugs, one chapter for project schedule
items, etc.  They are short chapters but having it all collected
simplifies my life when I go into meetings and need to report on the
progress of any particular item.

Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-08 14:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-08  1:52 Sectioning in LaTeX export Mark Elston
2009-04-08  2:16 ` Mark Elston
2009-04-08  6:17   ` Manish
     [not found]   ` <9135.1239160927@gamaville.dokosmarshall.org>
2009-04-08 14:57     ` Mark Elston

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).