• No results found

Modular LaTeX Documents: modular Daniel Thomas Sank 2016 December 27

N/A
N/A
Protected

Academic year: 2021

Share "Modular LaTeX Documents: modular Daniel Thomas Sank 2016 December 27"

Copied!
3
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Modular LaTeX Documents: modular

Daniel Thomas Sank

2016 December 27

Contents

1

What problem does this solve?

Suppose you write an article about octopuses. This article might have a sec-tions “Life cycle” and “Habitat”. Now suppose you want to write an article on sea animals and you want to have a section on octopuses. Obviously, we would like to import the octopus article we already wrote as a section of the sea animals article, but this is nontrivial because we need to somehow con-vert the habitat and lifecycle sections into subsections only when importing the octopus sub-document into the sea animal article! This package provides the subimportlevel macro to make that possible.

For a very detailed discussion on the issue of modularity and how this pack-age solves it, seehttps://danielsank.github.io/tex modularity.

2

Prerequisite: coseoul

This package builds on the coseoul package and works in concert with the macros defined in coseoul. We recommend reading the coseoul documentation to at least get an idea of how it works before reading further here, but we also give a brief review.

Commands like section are absolute, i.e. the level depth is determined entirely by the command itself. The coseoul package introduces levelstay, leveldown, levelup, and levelmultiup commands. These do exactly what they sound like, e.g. levelstay makes a new heading at the same level you’re at when you call the command. Here’s a simple example:

(2)

\end{ document }

See the coseoul documentation for details, but that’s all there really is to coseoul.

3

coseoul limitations

All listings here are taken directly from files included with this package so that you can access those files and build them yourself to see the examples in action. All paths are relative to documentation/example.

Suppose we write an octopus article with two sections:1

octopus/article.tex \documentclass{ a r t i c l e } \usepackage{ c o s e o u l } \usepackage{ import } \ t i t l e { Oc to pu se s } \ begin { document } \ m a k e t i t l e T h i s i s an a r t i c l e about o c t o p u s e s . \ s ub i m po r t ∗ { . / } { c o n t e n t . t e x } \end{ document } octopus/content.tex \ s ub i m po r t ∗ { . / } { h a b i t a t . t e x } \ s ub i m po r t ∗ { . / } { l i f e c y c l e . t e x } octopus/habitat.tex \ l e v e l s t a y { H a b i t a t } O c t o p u s e s l i v e i n t h e o c e a n . octopus/lifecycle.tex \ l e v e l s t a y { L i f e c y c l e }

O c t o p u s e s s t a r t o u t a s p l a n k t o n , but can grow t o hundreds o f pounds .

This works great. Now let’s try to use the octopus article as a sub-part of an article on sea animals:

article fail.tex \documentclass{ a r t i c l e }

\usepackage{ c o s e o u l }

1build octopus/article.tex to see the article yourself.

(3)

\usepackage{ import } \ t i t l e { Sea Animals } \ begin { document } \ m a k e t i t l e T h i s i s an a r t i c l e about s e a a n i m a l s . The f i r s t s e c t i o n i s about o c t o p u s u s . \ l e v e l s t a y { Oc to pu se s } \ s ub i m po r t ∗ { . / o c t o p u s /}{ c o n t e n t . t e x } \end{ document }

As you can see by building article fail.tex yourself, the habitat and lifecycle parts come in as sections instead of subsections.

4

modular to the rescue

The modular package provides the subimportlevel macro to solve our problem: article.tex \documentclass{ a r t i c l e } % modular must b e i n s t a l l e d f o r % t h i s e x a m p l e t o b u i l d . I f i t ’ s % n o t i n y o u r LaTeX d i s t r i b u t i o n , % i n s t a l l t h e . s t y f i l e m a n u a l l y . \usepackage{ modular } \ t i t l e { Sea Animals } \ begin { document } \ m a k e t i t l e T h i s i s an a r t i c l e about s e a a n i m a l s . The f i r s t s e c t i o n i s about o c t o p u s u s . \ l e v e l s t a y { Oc to pu se s } \ s u b i m p o r t l e v e l { . / o c t o p u s /}{ c o n t e n t . t e x }{1} \end{ document }

When you build article.tex you’ll see that the habitat and lifecycle bits are subsections under the octopus section, just as we wanted!

The subimportlevel macro takes three arguments:

• The relative path of the directory containing the file to import. • The file to import

• The number of levels to go down when importing. Usually, this will be 0 or 1.

Referenties

GERELATEERDE DOCUMENTEN

population the next year, probably because more foxes move in to contest the vacant area than were there in the first place. 19 , culling won't target individual foxes that

The actor playing Bond talks himself up with every word uttered but makes no mention, of course, of recent release 'Dream House' ─ surely a contender for The Worst Film Ever

• Spreken over “jihadistisch terrorisme” bergt het gevaar in zich dat etnische en religieuze minderheden zullen worden gediscrimineerd;.. • Zij worden tot

unconstrained optimization, functions of complex variables, quasi-Newton, BFGS, L-BFGS, nonlinear conjugate gradient, nonlinear least squares, Gauss–Newton,

unconstrained optimization, functions of complex variables, quasi-Newton, BFGS, L-BFGS, nonlinear conjugate gradient, nonlinear least squares, Gauss–Newton,

Notwithstanding the relative indifference toward it, intel- lectual history and what I will suggest is its necessary complement, compara- tive intellectual history, constitute an

Thus, if we select the significant effects from many tests of things that certainly have no true effect, we will fail to replicate about 95% of them.. The Open Science Collaboration

hij/zij kwam iemand/Mary Woolford tegen (in de supermarkt) die hij/zij liever niet had gezien. 31 B 32 maximumscore 3 1 niet 2 niet 3 niet 4 wel 5 niet 3 2 1 indien