0

I am thinking of writing a class file for this, but a basic problem is stumping me.

I have a document with numbered sections in which a particular section (say section 23) always contains a certain content (which may be dynamically generated from data provided by the user - say a histogram).

To make it concrete (this is for a grant proposal class - its not all code):


23. Deliverables and timelines

\begin{figure}[!h]
\includegraphics[width=\textwidth]{ganttchart.pdf}
\caption{Gantt chart for the proposal.}
\label{fig:gantt}
\end{figure}

< A table summarizing some fixed information regarding the proposal. >

One user supplied sentence relating requested financial support to the deliverables.

I want to write a class file that automatically generates such sections (there are several) for the user. How does one go about something like this? I have written classes before, so I am not entirely unschooled in this, but how does LaTeX handle something like this? ("This" being creating a section at the correct location in the document and placing predefined elements in it.).

user2751530
  • 1,102
  • 1
    How does LaTeX handle something like this? I think I still haven't understood what exactly is this. – Manuel Jun 30 '14 at 08:09
  • 2
    @Manuel I hope that the following will help. It is IT, not THIS, but seems to be simillar. ;-) ,,"Edwin and Morcar, the earls of Mercia and Northumbria, declared for him: and even Stigand, the patriotic archbishop of Canterbury, found it advisable—"'

    'Found WHAT?' said the Duck.

    'Found IT,' the Mouse replied rather crossly: 'of course you know what "it" means.'

    'I know what "it" means well enough, when I find a thing,' said the Duck: 'it's generally a frog or a worm. The question is, what did the archbishop find?' ''

    – Przemysław Scherwentke Jun 30 '14 at 08:41
  • Edited the post. – user2751530 Jun 30 '14 at 09:20
  • @user2751530 Mmm… not enough (for me at least). That little explanation you added, I think I need more than that (I already understood that by “this” you referred to that :P). “Correct location”? You mean that regardless of the rest of the sections, section 23 must be that one you already predefined somewhere? “Predefined elements”? Where and how should you define those? My first comment was more like I think it's a bit unclear what you want, could you expand? By the way, how does the “creation of the class for this” influence this question and your objective? Is it necessary? – Manuel Jun 30 '14 at 09:53
  • I think, the OP rather wants a LaTeX code generator instead of a class? –  Jun 30 '14 at 13:58
  • I think it needs to be a class (I have other things in mind for this document) but a code generator (is that just a fancy word for a conditional \newcommand?)? Please expound. – user2751530 Jun 30 '14 at 16:00
  • @user2751530: I fear, as you stated your question, it is not clear what you mean. It could be a code generator, some kind similar of TYPO3 script to guarantee content management (that is the content of your section number 23 (or whatever))... –  Jun 30 '14 at 17:31
  • @Manuel Yes, I mean that regardless of what else I add, section 23 must be that information. So, if I have written 22 sections, the next \section should start section 25. – user2751530 Jun 30 '14 at 17:56
  • You can do this in a number of ways: (1) Require that the entire document structure be fixed (that way you always know what to expect); (2) Require that the user insert something like \printme where they want the specified stuff to reside (akin to \tableofcontents or \printbibliography). This would include setting up some content in the preamble (say) (akin to \title and \author); (3) Patch your sectioning command to perform (2) exactly at the right time... – Werner Jun 30 '14 at 18:05
  • @user2751530 You should give us more detailed information. That way is more likely that you get help. – Manuel Jun 30 '14 at 18:22

1 Answers1

1

Tis is just an example of how can you do that (it's not clean, not really checked if it works in other different cases, and has no “proper interface” for you, but just to give you an idea).

\documentclass{scrartcl}

\makeatletter
\let\svsection\section
\def\section{\ifnum\c@section=6
        \expandafter\sectionseven
    \fi\svsection}
\def\sectionseven{\svsection{Section seven (7)}
    And the contents. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.}
\makeatother

\begin{document}

\section{A section}
\section{A section}
\section{A section}
\section{A section}
\section{A section}
\section{A section}
\section{A section}
\section{A section}
\section{A section}
\section{A section}

\end{document}

But I can't offer more, since I don't fully understand what (and why) you want.

enter image description here

Manuel
  • 27,118