Apply a start/stop command pair to certain subsections
Hello, I'm a new Context user, and I have a question about conditional formatting of paragraphs. I'm typsetting a CV. I am using pandoc to generate the .tex file from Markdown before compiling the pdf with context. Because pandoc inserts the body of the document from one variable ($body), I would like to avoid using e.g. \startmycommand and then \stopmycommand to modify individual subsections. What I can do from Markdown is tag the headings, so that (for example) the "Publications" subsection starts as "\subsection[pubs]{Publications}". I would like to know if there is a way to automatically apply a start/stop command pair to the "pubs" subsection(s), or if it better to do this with an external script that modifies the .tex file before I call context. Below is an example where I can get the output I'm looking for (paragraphs in the "pubs" subsection have a hanging indent) by defining a start/stop command pair and manually applying it to the "pubs" subsection. If anyone has any tips to apply this automatically to the "pubs" subsection(s) but not the "text" subsections, I'd appreciate it! I have searched the wiki, read through the "Context: an excursion" document and looked around in the mail archive and stackexchange, but I didn't find exactly what I want. Many thanks for reading, Tom Harrop ---Example below--- \definestartstop [negindent] [ before={% \startnarrower[left]% \setupindenting[-\leftskip,yes,first]% \setuphead[subsection][indentnext=yes]% }, after=\stopnarrower, ] \starttext \subsection[text]{Normal text} I would like the text in this subsection to appear without indents. In the following subsection I need hanging indents. \startnegindent \subsection[pubs]{Publications} Jaynes, Julian. {\os 1990}. {\em The Origin of Consciousness in the Breakdown of the Bicameral Mind}. New York City: Houghton Mifflin Company. Pye, David. {\os 1995}. {\em The Nature and Art of Workmanship}. London: The Herbert Press. Persson, Tomas. {\os 2008}. {\em Pictorial Primates: A Search for Iconic Abilities in Great Apes}. Lund: Lund University Cognitive Studies. \stopnegindent \subsection[text]{More text} This subsection should be back to normal. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \stoptext
You could take a look at my fork of Pablo's pandoc-xhtml: https://github.com/aksdb/pandoc-xhtml The basic idea is to use another step in between the generation: Pandoc -> XML -> PDF (since ConTeXt can read XML natively, given the appropriate environment file). As you can see in the example Makefile, you should use pandoc with --section-divs which will (in my fork of pandoc-xhtml, not in the original) cause the use of \startchapter...\stopchapter, \startsection...\stopsection etc. Therefore you can then also use \setuphead[chapter][insidesection=..., aftersection=...] and similar setups. Best regards Andreas Am 2016-03-10 12:08, schrieb Tom Harrop:
Hello,
I'm a new Context user, and I have a question about conditional formatting of paragraphs.
I'm typsetting a CV. I am using pandoc to generate the .tex file from Markdown before compiling the pdf with context. Because pandoc inserts the body of the document from one variable ($body), I would like to avoid using e.g. \startmycommand and then \stopmycommand to modify individual subsections.
What I can do from Markdown is tag the headings, so that (for example) the "Publications" subsection starts as "\subsection[pubs]{Publications}". I would like to know if there is a way to automatically apply a start/stop command pair to the "pubs" subsection(s), or if it better to do this with an external script that modifies the .tex file before I call context.
Below is an example where I can get the output I'm looking for (paragraphs in the "pubs" subsection have a hanging indent) by defining a start/stop command pair and manually applying it to the "pubs" subsection.
If anyone has any tips to apply this automatically to the "pubs" subsection(s) but not the "text" subsections, I'd appreciate it! I have searched the wiki, read through the "Context: an excursion" document and looked around in the mail archive and stackexchange, but I didn't find exactly what I want.
Many thanks for reading,
Tom Harrop
---Example below---
\definestartstop [negindent] [ before={% \startnarrower[left]% \setupindenting[-\leftskip,yes,first]% \setuphead[subsection][indentnext=yes]% }, after=\stopnarrower, ]
\starttext
\subsection[text]{Normal text}
I would like the text in this subsection to appear without indents.
In the following subsection I need hanging indents.
\startnegindent
\subsection[pubs]{Publications}
Jaynes, Julian. {\os 1990}. {\em The Origin of Consciousness in the Breakdown of the Bicameral Mind}. New York City: Houghton Mifflin Company.
Pye, David. {\os 1995}. {\em The Nature and Art of Workmanship}. London: The Herbert Press.
Persson, Tomas. {\os 2008}. {\em Pictorial Primates: A Search for Iconic Abilities in Great Apes}. Lund: Lund University Cognitive Studies.
\stopnegindent
\subsection[text]{More text}
This subsection should be back to normal.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\stoptext
participants (2)
-
Andreas Schneider
-
Tom Harrop