Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to replicate this page layout using context, but I am struggling.

I have read the context manual and tried changing parameters to see what happens, but I was unable to sort out the logic.

Can anyone give me some pointers?

share|improve this question
    
Did you read the wiki page as well as the manual chapter on page design? –  phg May 16 '12 at 10:15
    
phg - Thanks. I managed to get the overall layout, but aligning the chapter/section numbers left is a challenge. –  user14644 May 16 '12 at 11:15
    
afaict left aligning the structure numbers in the inner margin isn’t directly available as an option, but you can define your own placement method to fit your needs. –  phg May 16 '12 at 11:45
1  
To align the number in the space occupied by margindistance use: \setupheads[alternative=margin,numbercommand=\rlap] –  Marco May 16 '12 at 11:50
    
phg - I used your macro which gives the desired results. I also tried the numbercommand=\rlap, but decided not to use it. –  user14644 May 16 '12 at 15:14

1 Answer 1

Aligning the structure number in the margin can easily be achieved by means of a placement method. These are ordinary macros that take two arguments -- one for the number, the second for the heading text -- and determine how they are typeset in the body matter context. This way the presentation of structurals is limited only by your imagination and TEX skills. For this to work, the setup key alternative needs to be set to command and the key command to your macro. Also, the left margin will have to be configured so as to match the required flush left alignment. (For further information see the structural rendering source, strc-ren.mkiv.)

% macros=mkvi
\unprotect
%% 1. Create a placement alternative, i. e. a dyadic macro. % ······· %
\unexpanded\def\left_margin_placement#number#content{%
  \vbox{%
    \localheadsetup\begstrut\dontleavehmode
    \ifconditional\headshownumber\inleftmargin{#number}\fi
    {#content}%
  }
}

%% 2. Setup the alignment within the margin. % ······················ %
\setupmargindata [left]            [align=flushleft]
\setuplayout     [leftmargin=1cm]

%% 3. Hook the new method into the structurals. % ··················· %
\setuphead       [chapter,section] [
  alternative=\v!command,
  \c!command=\left_margin_placement,
]
\protect

%% 4. ... Profit?
\starttext % ························································ %
  \chapter{foo}
  \section{bar}
  \input knuth
\stoptext % ························································· %

Demonstration of flush left margin number for structurals.

share|improve this answer
    
That should be \c!command=... rather than \v!command=.... BTW, how is this different from alternative=inmargin? –  Aditya Jul 20 '12 at 17:43
    
Compare the definitions (strc-ren.mkiv, l. 619): this one will actually respect the flushleft settings for the margin content. Thanks for the fix! –  phg Jul 20 '12 at 18:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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