7

I want make a title page like this:

\setuphead[title][style={\ss\bfd},align=middle]
\definemakeup[titlepage][align=middle]

\starttext

\startfrontmatter
\startmakeup[titlepage]
\title{My very awesome title}
{\ss\tfa Author Name}
\stopmakeup
\stopfrontmatter

\stoptext

According to the documentation, makeup by default centers the text vertically. However, this seems not to be the case:

The title is quite far from being vertically centered. What am I doing wrong?

6

You are using the wrong command. The \title command creates an unnumbered chapter in ConTeXt (contrary to LaTeX where you set the document title this way).

To my knowledge, there is no predefined mechanism like \maketitle in ConTeXt, so you have to make up the titlepage on your own. To still have some kind of abstraction you can define styles to hold the visual modifiers to be applied to the text.

\definemakeup[titlepage][align=middle]

\definealternativestyle[titlestyle][\ss\bfd][]
\definealternativestyle[authorstyle][\ss\tfa][]

\starttext

\startfrontmatter
  \startmakeup[titlepage]
    \titlestyle{My very awesome title}
    \blank[big]
    \authorstyle{Author Name}
  \stopmakeup
\stopfrontmatter

\stoptext

enter image description here


Addendum: I still think there is no mechanism for document titles in the core but there is Wolfgang's third party module title.

\usemodule[title]

\starttext

\startfrontmatter
  \startstandardmakeup
    \placetitle
      [
        title={My very awesome title},
        author={Author Name},
        date=\currentdate,
      ]
  \stopstandardmakeup
\stopfrontmatter

\stoptext
  • The first option does not work nicely once the title is longer than one line. There is no spacing whatsoever between the title lines, even though I do \setupinterlinespace[medium]. Is this easily fixable? Else I would use the module. – flyx Oct 6 '16 at 21:30
  • 1
    @flyx To have adapted linespacing use, as you said, \definealternativestyle[titlestyle][\ss\bfd\setupinterlinespace][] and then do \titlestyle{...\par}. TeX applies things like baselineskip only on complete paragraphs, therefore you nedd to end the paragraph using \par before switching back the font size. – Henri Menke Oct 6 '16 at 21:34
7

As Henri Menke explained, ConTeXt does not provide a default mechanism for typesetting document titles. It is assumed that the writer (or a module writer, for modules used to typeset journal articles) is responsible for providing an appropriate mechanism.

To generate titles for my documents, I hook into the \startdocument and \stopdocument macros, which can be used to setup pdf metadata. For example, if you compile the following document:

\setupinteraction[state=start]
\startdocument
    [
      metadata:title=A sample document,
      metadata:author=Some author,
      metadata:keyword=ConTeXt example,
    ]


A sample document

\stopdocument

then pdfinfo filename.pdf gives:

Title:          A sample document
Keywords:       ConTeXt example
Author:         Some author
Creator:        LuaTeX + ConTeXt MkIV
Producer:       LuaTeX-1.0.0
CreationDate:   Thu Oct  6 20:28:56 2016
ModDate:        Thu Oct  6 20:28:56 2016
Tagged:         no
Form:           none
Pages:          1
Encrypted:      no
Page size:      595.276 x 841.89 pts (A4)
Page rot:       0
File size:      5964 bytes
Optimized:      no
PDF version:    1.7

Ideally, I like to use the same interface to generate the title page as well. To do so, I simply set the before key of \setupdocument to a setup that generates the title page. For example, to generate the titlepage that you want:

\startsetups document:title
  \startstandardmakeup[align=middle]
     {\ss\bfd\setupinterlinespace
       \documentvariable{metadata:title} \endgraf}
     \blank[big]
     {\ss\tfb\setupinterlinespace
       \documentvariable{metadata:author} \endgraf}
     \blank[medium]
     {\ss\tf\setupinterlinespace
       \documentvariable{metadata:date} \endgraf}
  \stopstandardmakeup
\stopsetups

\setupdocument[before=\setups{document:title}]

Then, the above \startdocument ... \stopdocument snippet will generate the title page and set the pdf metadata. Here is the complete minimal example:

\setupinteraction[state=start]

\startsetups document:title
  \startstandardmakeup[align=middle]
     {\ss\bfd\setupinterlinespace
       \documentvariable{metadata:title} \endgraf}
     \blank[big]
     {\ss\tfb\setupinterlinespace
       \documentvariable{metadata:author} \endgraf}
     \blank[medium]
     {\ss\tf\setupinterlinespace
       \documentvariable{metadata:date} \endgraf}
  \stopstandardmakeup
\stopsetups

\setupdocument[before=\setups{document:title}]

\startdocument
    [
      metadata:title=A sample document,
      metadata:author=Some author,
      metadata:keyword=ConTeXt example,
      metadata:date=\currentdate,
    ]


A sample document

\stopdocument
  • I usually use ConTeXt's project structure to organise my documents and there I don't have \start...\stopdocument. How would I do it there? – Henri Menke Oct 7 '16 at 6:25
  • @HenriMenke: start-stop document is just a wrapper around start-stop text. So use it at the top level of the document. – Aditya Oct 7 '16 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.