5

Since I am about to quit using orgmode for my PHD I am wondering whether something like a synopsis package exists (google didn't give me an answer about that).

What I need: I have a short synopsis of every chapter, section subsection... for myself to structure the dosument. Normally I do not want to export these. From time to time I'd like to read my document in it's full structure with only the synopses in it.

How it could be achieved (I am not into creating styles and doing wierd things in latex): - write the synopsis as comments and only process headings and comments during - have some special environment synopsis and porcess only outline and synopsis environment.

Any packages out there? Ideas of yours?

lockstep
  • 250,273
louis cypher
  • 1,333

1 Answers1

4

(See earlier edits if needed, but this is my cleanest version yet. References: Polyglot note-keeping?, comment package, TeX FAQ: Conditional compilation and “comments”)

This can be solved with a combination of the verbatim and extract packages. While building the PDF, the extract package will simultaneously create a synopsis.tex file with just the synopses and document divisions extracted. Build this synopsis.tex file, and you'll have your outline.

Original document source:

\documentclass{article}
% In this file, make a new comment-like environment named 'synopsis':
\usepackage{verbatim}
\let\synopsis\comment
\let\endsynopsis\endcomment
% Extract synopsis environments, \section commands, and \tableofcontents
% commands into a separate synopsis.tex file. In that file, a synopsis
% environment will be a simple semantic environment with no extra decoration.
\usepackage[active,
  generate=synopsis,
  extract-env={synopsis},
  extract-cmd={section},
  extract-cmdline={tableofcontents}]{extract}
\begin{extract}
\newenvironment{synopsis}{}{}
\end{extract}

% Here is the real document, with inline synopses: \begin{document} \tableofcontents \section{Fourier Series} \begin{synopsis} A Fourier series is periodic, and made up of orthogonal $\sin$ and $\cos$ functions. \end{synopsis} The Fourier series has the form: [ \frac{a_0}{2} + \sum_{n=1}^{\infty} \left[ a_n \cos {\frac{2 n \pi}{T} t} + b_n \sin {\frac{2 n \pi}{T} t} \right] ] where $a_n$ and $b_n$ are called Fourier coefficients of the Fourier series of the function $f(x)$. \end{document}

Resulting PDF:

enter image description here

Generated synopsis.tex:

%% 
%% This is file, `synopsis.tex',
%% generated with the extract package.
%% 
%% Generated on :  2012/04/02,18:26
%% From source  :  50099.tex
%% Using options:  active,generate=synopsis,extract-env={synopsis},extract-cmd={section},extract-cmdline={tableofcontents}
%% 
\documentclass{article}
\newenvironment{synopsis}{}{}

\begin{document}

\tableofcontents

\section{Fourier Series}

\begin{synopsis} A Fourier series is periodic, and made up of orthogonal $\sin$ and $\cos$ functions. \end{synopsis}

\end{document}

and PDF:

enter image description here

David Carlisle
  • 757,742
Mike Renfro
  • 20,550
  • Sounds good to me. Do I need to define a "full" environment or is it enough to define the excludecomment? If I have to define environments of such length I will for sure run into trouble. I'll dowload the documentation anyway. Tanks a lot! – louis cypher Mar 30 '12 at 17:09
  • If you really want either synopses or the rest of the material, but never both, then the comment package would require a full environment as shown. Anything not in a comment-style environment would be included in both versions of the document. In the polyglot example, the math stayed outside the comment environment and was present in both documents, but the explanations were in one or the other comment types. – Mike Renfro Mar 30 '12 at 18:12
  • Hmm, that is what I found in the docu also. That does not look like a usable solution for me. I for sure will forget the \end{full} after several pages and mess the document up. If \begin{synopsis}would automatically close the full environment (it isn't an environment according to the docu.) BTW that package and it's docu seems to be ancient ;-/ – louis cypher Mar 30 '12 at 18:57
  • It is an environment, the extra \comment and \endcomment type of commands are how environments work on a lower level. Try \itemize \item Foo \enditemize in a regular document to see. Regardless, I don't know if there's any way of convincing LaTeX to suppress otherwise untagged content by default. – Mike Renfro Mar 31 '12 at 00:54
  • Thanks, I mixed up grouping and environment. So looks like there is something left to do for me when I finished my thesis ;-) Shouldn't be to much work to change the comment package (said by somebody who is even struggling writing a 10 lines macro ;-) – louis cypher Mar 31 '12 at 07:28
  • 1
    See also this: http://tex.stackexchange.com/questions/18616/how-can-i-ignore-everything-except-a-specified-environment – mbork Apr 01 '12 at 09:24
  • After @mbork mentioned xcomment, I found this page in the TeX FAQ, and added a second version to my answer that should match the requirements. – Mike Renfro Apr 01 '12 at 22:58
  • @MikeRenfro: very nice, I forgot about the extract package! – mbork Apr 01 '12 at 23:12
  • Ok, finally have a cleaner version using extract and verbatim packages. – Mike Renfro Apr 02 '12 at 23:37
  • @MikeRenfro: I have some trouble with your solution. Can you give me a hint what is wrong? '%% Using options: active,generate=synopsis,extract-env={synopsis},extract-cmd={section},extract-cmdline={tableofcontents}' '%% \documentclass[b5paper,11pt,DIV=calc,BCOR=8mm,parskip=false,hidelinks]{scrbook}' '\newenvironment{synopsis}{}{}'

    '\begin{document}'

    '\tableofcontents'

    '\section[Heading 1]{\Sectionformat {Heading 1}{1}}'

    – louis cypher Apr 05 '12 at 15:40
  • Not sure. I assume my solution works as-is with your TeX installation. If not, you may have some out of date packages. If mine works, but doesn't work when adapted to scrbook or your other settings, then you'll need to edit your question to include a minimal working example (MWE) showing the problem you're running into, or post a second question about this specific problem. – Mike Renfro Apr 05 '12 at 15:46
  • @MikeRenfro Just to let you know: I ran at trouble with that solution in a bigger document since the extract package eats up another to writes. – louis cypher Apr 15 '12 at 19:54
  • @MikeRenfro I still love to use your environment but run into trouble with additional {\Sectionformat {title of the section}{section number}}. Any idea how to get rid of those? – louis cypher Jan 08 '16 at 17:36
  • No idea. I don't normally use Koma classes, but using \sectionformat instead of \Sectionformat, I can't make a MWE fail with my setup. You really need to make a MWE that shows the error, and probably make a new question (I'm the only one who's likely to see this, and your new question can link this one for context). – Mike Renfro Jan 09 '16 at 01:07
  • @MikeRenfro I opened a new question here http://tex.stackexchange.com/questions/287121/extract-package-question-not-present-sectionformat-statement-is-extracted. It has a MWE also. Please note that the Sectionformat- statement does not exist in the original document and the document is not using koma script. – louis cypher Jan 14 '16 at 18:42