% -*- mode: tex -*-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                STANDARD                                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\enabletrackers[fonts.missing]
\definefontfeature[default][default]
                  [protrusion=quality,
                    expansion=quality,
                    script=latn]
\setupalign[hz,hanging]
\setuptolerance[tolerant]
\setbreakpoints[compound]
\setupindenting[yes,1em]
\setupfootnotes[way=bychapter,align={hz,hanging}]
\setupbodyfont[modern] % this is a stinky workaround to load lmodern
\setupbodyfont[libertine,11pt]

\setuppagenumbering[alternative=singlesided,location={footer,middle}]
\setupcaptions[width=fit,align={hz,hanging},number=no]

\startmode[a4imposed,a4imposedbc,letterimposed,letterimposedbc,a5imposed,%
  a5imposedbc,halfletterimposed,halfletterimposedbc]
  \setuppagenumbering[alternative=doublesided]
\stopmode

\setupbodyfontenvironment[default][em=italic]


\setupheads[%
  sectionnumber=no,number=no,
  align=flushleft,
  align={flushleft,nothyphenated,verytolerant,stretch},
  indentnext=yes,
  tolerance=verytolerant]

\definehead[awikipart][chapter]

\setuphead[awikipart]
          [%
            number=no,
            footer=empty,
            style=\bfd,
            before={\blank[force,2*big]},
            align={middle,nothyphenated,verytolerant,stretch},
            after={\page[yes]}
          ]

% h3
\setuphead[chapter]
          [style=\bfc]

\setuphead[title]
          [style=\bfc]


% h4
\setuphead[section]
          [style=\bfb]

% h5
\setuphead[subsection]
          [style=\bfa]

% h6
\setuphead[subsubsection]
          [style=bold]


\setuplist[awikipart]
          [alternative=b,
            interaction=all,
            width=0mm,
            distance=0mm,
            before={\blank[medium]},
            after={\blank[small]},
            style=\bfa,
            criterium=all]
\setuplist[chapter]
          [alternative=c,
            interaction=all,
            width=1mm,
            before={\blank[small]},
            style=bold,
            criterium=all]
\setuplist[section]
          [alternative=c,
            interaction=all,
            width=1mm,
            style=\tf,
            criterium=all]
\setuplist[subsection]
          [alternative=c,
            interaction=all,
            width=8mm,
            distance=0mm,
            style=\tf,
            criterium=all]
\setuplist[subsubsection]
          [alternative=c,
            interaction=all,
            width=15mm,
            style=\tf,
            criterium=all]


% center

\definestartstop
  [awikicenter]
  [before={\blank[line]\startalignment[middle]},
   after={\stopalignment\blank[line]}]

% right

\definestartstop
  [awikiright]
  [before={\blank[line]\startalignment[flushright]},
   after={\stopalignment\blank[line]}]


% blockquote

\definestartstop
  [blockquote]
  [before={\blank[big]
    \setupnarrower[middle=1em]
    \startnarrower
    \setupindenting[no]
    \setupwhitespace[medium]},
  after={\stopnarrower
    \blank[big]}]

% verse

\definestartstop
  [awikiverse]
  [before={\blank[big]
      \setupnarrower[middle=2em]
      \startnarrower
      \startlines},
    after={\stoplines
      \stopnarrower
      \blank[big]}]

\definestartstop
  [awikibiblio]
  [before={%
      \blank[big]
      \setupnarrower[left=1em]
      \startnarrower[left]
        \setupindenting[yes,-1em,first]},
    after={\stopnarrower
      \blank[big]}]
                
% same as above, but with no spacing around
\definestartstop
  [awikiplay]
  [before={%
      \setupnarrower[left=1em]
      \startnarrower[left]
        \setupindenting[yes,-1em,first]},
    after={\stopnarrower}]



% interaction
% we start the interaction only if it's not an imposed format.
\startnotmode[a4imposed,a4imposedbc,letterimposed,letterimposedbc,a5imposed,%
  a5imposedbc,halfletterimposed,halfletterimposedbc]
  \setupinteraction[state=start,color=black,contrastcolor=black,style=bold]
  \placebookmarks[awikipart,chapter,section,subsection,subsubsection][force=yes]
  \setupinteractionscreen[option=bookmark]
\stopnotmode



\setupexternalfigures[%
  maxwidth=\textwidth,
  maxheight=\textheight,
  factor=fit]

\setupitemgroup[itemize][each][packed][indenting=no]

\definemakeup[titlepage][pagestate=start,doublesided=no]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                IMPOSER                                       %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\startusercode

function optimize_signature(pages,min,max)
   local minsignature = min or 40
   local maxsignature = max or 80
   local originalpages = pages

   -- here we want to be sure that the max and min are actual *4
   if (minsignature%4) ~= 0 then
      global.texio.write_nl('term and log', "The minsig you provided is not a multiple of 4, rounding up")
      minsignature = minsignature + (4 - (minsignature % 4))
   end
   if (maxsignature%4) ~= 0 then
      global.texio.write_nl('term and log', "The maxsig you provided is not a multiple of 4, rounding up")
      maxsignature = maxsignature + (4 - (maxsignature % 4))
   end
   global.assert((minsignature % 4) == 0, "I suppose something is wrong, not a n*4")
   global.assert((maxsignature % 4) == 0, "I suppose something is wrong, not a n*4")

   --set needed pages to and and signature to 0
   local neededpages, signature = 0,0

   -- this means that we have to work with n*4, if not, add them to
   -- needed pages 
   local modulo = pages % 4
   if modulo==0 then
      signature=pages
   else
      neededpages = 4 - modulo
   end

   -- add the needed pages to pages
   pages = pages + neededpages
   
   if ((minsignature == 0) or (maxsignature == 0)) then 
      signature = pages -- the whole text
   else
      -- give a try with the signature
      signature = find_signature(pages, maxsignature)
      
      -- if the pages, are more than the max signature, find the right one
      if pages>maxsignature then
	 while signature<minsignature do
	    pages = pages + 4
	    neededpages = 4 + neededpages
	    signature = find_signature(pages, maxsignature)
	    --         global.texio.write_nl('term and log', "Trying signature of " .. signature)
	 end
      end
      global.texio.write_nl('term and log', "Parameters:: maxsignature=" .. maxsignature ..
		   " minsignature=" .. minsignature)

   end
   global.texio.write_nl('term and log', "ImposerMessage:: Original pages: " .. originalpages .. "; " .. 
	 "Signature is " .. signature .. ", " ..
	 neededpages .. " pages are needed, " .. 
	 pages ..  " of output")
   -- let's do it
   tex.print("\\dorecurse{" .. neededpages .. "}{\\page[empty]}")

end

function find_signature(number, maxsignature)
   global.assert(number>3, "I can't find the signature for" .. number .. "pages")
   global.assert((number % 4) == 0, "I suppose something is wrong, not a n*4")
   local i = maxsignature
   while i>0 do
      -- global.texio.write_nl('term and log', "Trying " .. i  .. "for max of " .. maxsignature)
      if (number % i) == 0 then
	 return i
      end
      i = i - 4
   end
end

\stopusercode

\define[1]\fillthesignature{
  \usercode{optimize_signature(#1, 40, 80)}}


\define\alibraryflushpages{
  \page[yes] % reset the page
  \fillthesignature{\the\realpageno}
}


% various papers 
\definepapersize[halfletter][width=5.5in,height=8.5in]
\definepapersize[halfafour][width=148.5mm,height=210mm]
\definepapersize[quarterletter][width=4.25in,height=5.5in]
\definepapersize[halfafive][width=105mm,height=148mm]
\definepapersize[generic][width=210mm,height=279.4mm]

%% this is the default ``paper'' which should work with both letter and a4

\setuppapersize[generic][generic]
\setuplayout[%
  backspace=42mm,
  topspace=31mm,% 176 / 15
  height=195mm,%130mm,
  footer=9mm, %
  header=0pt, % no header
  width=126mm] % 10.5 x 11

\startmode[libertine]
  \usetypescript[libertine]
  \setupbodyfont[libertine,11pt]
\stopmode

\startmode[pagella]
  \setupbodyfont[pagella,11pt]
\stopmode

\startmode[antykwa]
  \setupbodyfont[antykwa-poltawskiego,11pt]
\stopmode

\startmode[iwona]
  \setupbodyfont[iwona-medium,11pt]
\stopmode

\startmode[helvetica]
  \setupbodyfont[heros,11pt]
\stopmode

\startmode[century]
  \setupbodyfont[schola,11pt]
\stopmode

\startmode[modern]
  \setupbodyfont[modern,11pt]
\stopmode

\startmode[charis]
  \setupbodyfont[charis,11pt]
\stopmode        

\startmode[mini]
  \setuppapersize[S33][S33] % 176 × 176 mm
  \setuplayout[%
    backspace=20pt,
    topspace=15pt,% 176 / 15
    height=280pt,%130mm,
    footer=20pt, %
    header=0pt, % no header
    width=260pt] % 10.5 x 11
\stopmode

% for the plain A4 and letter, we use the classic LaTeX dimensions
% from the article class
\startmode[a4]
  \setuppapersize[A4][A4]
  \setuplayout[%
    backspace=42mm,
    topspace=45mm,
    height=218mm,
    footer=10mm,
    header=0pt, % no header
    width=126mm]
\stopmode

\startmode[letter]
  \setuppapersize[letter][letter]
  \setuplayout[%
    backspace=44mm,
    topspace=46mm,
    height=199mm,
    footer=10mm,
    header=0pt, % no header
    width=126mm]
\stopmode


% A4 imposed (A5), with no bc

\startmode[a4imposed]
% DIV=15 148 × 210: these are meant not to have binding correction,
  % but just to play safe, let's say 1mm => 147x210
  \setuppapersize[halfafour][halfafour]
  \setuplayout[%
    backspace=10.8mm, % 146/15 = 9.8 + 1
    topspace=14mm, % 210/15 =  14
    height=182mm, % 14 x 12 + 14 of the footer
    footer=14mm, %
    header=0pt, % no header
    width=117.6mm] % 9.8 x 12
\stopmode

% A4 imposed (A5), with bc
\startmode[a4imposedbc]
  \setuppapersize[halfafour][halfafour]
  \setuplayout[% 14 mm was a bit too near to the spine, using the glue binding
    backspace=17.3mm,  % 140/15 + 8 =
    topspace=14mm, % 210/15 =  14
    height=182mm, % 14 x 12 + 14 of the footer
    footer=14mm, %
    header=0pt, % no header
    width=112mm] % 9.333 x 12
\stopmode


\startmode[letterimposedbc] % 139.7mm x 215.9 mm
  \setuppapersize[halfletter][halfletter]
  % DIV=15 8mm binding corr, => 132 x 216
  \setuplayout[%
    backspace=16.8mm, % 8.8 + 8
    topspace=14.4mm, % 216/15 =  14.4
    height=187.2mm, % 15.4 x 11 + 15 of the footer
    footer=14.4mm, %
    header=0pt, % no header
    width=105.6mm] % 8.8 x 12
\stopmode

\startmode[letterimposed] % 139.7mm x 215.9 mm
  \setuppapersize[halfletter][halfletter]
  % DIV=15, 1mm binding correction. => 138.7x215.9
  \setuplayout[%
    backspace=10.3mm, % 9.24 + 1
    topspace=14.4mm, % 216/15 =  14.4
    height=187.2mm, % 15.4 x 11 + 15 of the footer
    footer=14.4mm, %
    header=0pt, % no header
    width=111mm] % 9.24 x 12
\stopmode

%%% new formats for mini books
%%% \definepapersize[halfafive][width=105mm,height=148mm]

\startmode[a5imposed]
% DIV=12 105x148 : these are meant not to have binding correction,
  % but just to play safe, let's say 1mm => 104x148
  \setuppapersize[halfafive][halfafive]
  \setuplayout[%
    backspace=9.6mm,
    topspace=12.3mm,
    height=123.5mm, % 14 x 12 + 14 of the footer
    footer=12.3mm, %
    header=0pt, % no header
    width=78.8mm] % 9.8 x 12
\stopmode

% A5 imposed (A6), with bc
\startmode[a5imposedbc]
% DIV=12 105x148 : with binding correction,
  % let's say 8mm => 96x148
  \setuppapersize[halfafive][halfafive]
  \setuplayout[%
    backspace=16mm,
    topspace=12.3mm,
    height=123.5mm, % 14 x 12 + 14 of the footer
    footer=12.3mm, %
    header=0pt, % no header
    width=72mm] % 9.8 x 12
\stopmode

%%% \definepapersize[quarterletter][width=4.25in,height=5.5in]

% DIV=12 width=4.25in (108mm),height=5.5in (140mm) 
\startmode[halfletterimposed] % 107x140
  \setuppapersize[quarterletter][quarterletter]
  \setuplayout[%
    backspace=10mm,
    topspace=11.6mm,
    height=116mm,
    footer=11.6mm,
    header=0pt, % no header
    width=80mm] % 9.24 x 12
\stopmode

\startmode[halfletterimposedbc]
  \setuppapersize[quarterletter][quarterletter]
  \setuplayout[%
    backspace=15.4mm,
    topspace=11.6mm,
    height=116mm,
    footer=11.6mm,
    header=0pt, % no header
    width=76mm] % 9.24 x 12
\stopmode

\startmode[quickimpose]
  \setuppapersize[A5][A4,landscape]
  \setuparranging[2UP]
  \setuppagenumbering[alternative=doublesided]
  \setuplayout[% 14 mm was a bit too near to the spine, using the glue binding
    backspace=17.3mm,  % 140/15 + 8 =
    topspace=14mm, % 210/15 =  14
    height=182mm, % 14 x 12 + 14 of the footer
    footer=14mm, %
    header=0pt, % no header
    width=112mm] % 9.333 x 12
\stopmode

\startmode[tenpt]
  \setupbodyfont[10pt]
\stopmode

\startmode[twelvept]
  \setupbodyfont[12pt]
\stopmode

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                            DOCUMENT BEGINS                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\mainlanguage[en]


\starttext

\starttitlepagemakeup
  \startalignment[middle,nothanging,nothyphenated,stretch]


  \switchtobodyfont[18pt] % author
  {\bf \em

Anonymous  \par}
  \blank[2*big]
  \switchtobodyfont[24pt] % title
  {\bf

The Black Flag

\par}
  \blank[big]
  \switchtobodyfont[20pt] % subtitle
  {\bf 

\par}
  \vfill
  \stopalignment
  \startalignment[middle,bottom,nothyphenated,stretch,nothanging]
  \switchtobodyfont[global]

August 12 1883

  \stopalignment
\stoptitlepagemakeup



\page[yes,right]

The “Black Flag”, {\em Le Drapeau Noir}, No. 1, August 12 1883.


 


To live free working or die fighting.


 



\startblockquote

It’s not just as another challenge to bourgeois society that we gave the title {\em Drapeau Noir} [Black Flag] to this newspaper—bound to continue the struggle of the {\em Lutte}—and that we print here the immortal motto of our brothers the Canuts [in Lyon].  We also wanted to keep this glorious workers’ insurrection alive; to remind those who have already forgotten and to inform those who might still be ignorant.  We wanted to warn the bourgeoisie that the only flag under which we will stand together now is the same one that poverty and desperation raised up in the streets of Croix-Rousse on November 21 1831 and that until the coming victory, we will have no other.


\stopblockquote

\startblockquote

Our enemies couldn’t care less and our readers and supporters might give us a hard time, so they have to know—and we don’t have the right to keep them ignorant—why we are flying this flag, why we are adopting this emblem, why we are accepting what has, until now, been considered only a historical curiosity but absolutely inoffensive from a revolutionary standpoint.


\stopblockquote

\startblockquote

We are not afraid to admit it, it will cost us—dearly—to abandon the scarlet banner of those defeated in May, to renounce the red flag of the brave men and woman of ’71, [in the Paris Commune], because we still shed tears for them and they still inspire us.  We hold dear the stirring reminders of good times on those glorious anniversaries and the hate and vengeance that rises up on the dark dates.  We haven’t forgotten those living in exile and prison, we whisper praise to them and dream of the coming triumph.


\stopblockquote

\startblockquote

But there is something more convincing than all these ideas, stronger than principles, more powerful than theories.


\stopblockquote

\startblockquote

What happens everyday clearly shows us that the red flag, so glorious in defeat, can in victory hide the ambitious dreams of the lowliest schemers in its blazing folds, as we see it has already cloaked a government and served as the banner of constitutional authority.  That’s how we knew that for us, mutinous everyday, rebellious every hour, it could provide nothing but confusion and illusion.


\stopblockquote

\startblockquote

Of course, if we still wanted to fight out in the open, in the organized battles that until now the revolutionaries have always had the naïve pretension to engage in with their enemies, the red flag could become ours.  It is, in fact, all pretty and scarlet, a fitting banner for such fights and battles.  A good representation, like feudal coats or arms talking, of getting rid of the privileged castes in the huge mass of people, the complete disappearance of social inequality, the unification of all classes into one class of workers.


\stopblockquote

\startblockquote

But this is not enough anymore.  We’re done with the misguided ways of the past regarding the purely practical domain of revolutionary action, just as in the speculative realm, perhaps, of emblems and symbols.


\stopblockquote

\startblockquote

What we want now—and we say it without fearing of reprisal in any way—is a partisan war, the combat of the “lost children” in the streets, as relentless as they are dissipated, fighting in the shadows, but hitting the mark, the only logical war, the civil war—the only worthwhile war—the social war.


\stopblockquote

\startblockquote

Therefore, it is to those who are suffering, to those who are holding their breaths under the ever-increasing burden of poverty whom we call.  Let those who have had enough of exploitation and slavery, those who want to put an end to the political and economic domination that is crushing us, those who want to break forever the iron chians that bind and keep us separate forever, come to us.


\stopblockquote

\startblockquote

We distance ourselves from all sentimentalism and all compromise.  We are staring a duel to the death with bourgeois society.  They cannot win.  And by taking the Black Flag, by unfurling to the winds the dark folds of desperation, it is more than a warning, it is better than a call, it is the death of the old world that we are displaying, it is the inevitable promise of its coming end and it is, at the same time, for all the poor and wretched, for those wallowing in misery, for all those dying of hunger, the definite announcement of an era of happiness, justice, liberty and peace:  it is ANARCHY.


\stopblockquote
 


 









\page[yes]

%%%% backcover

\startmode[a4imposed,a4imposedbc,letterimposed,letterimposedbc,a5imposed,%
  a5imposedbc,halfletterimposed,halfletterimposedbc,quickimpose]
\alibraryflushpages
\stopmode

\page[blank]

\startalignment[middle]
{\tfa The Anarchist Library
\blank[small]
Anti-Copyright}
\blank[small]
\currentdate
\stopalignment

\blank[big]
\framed[frame=off,location=middle,width=\textwidth]
       {\externalfigure[logo][width=0.25\textwidth]}



\vfill
\setupindenting[no]
\setsmallbodyfont

\startalignment[middle,nothyphenated,nothanging,stretch]

\blank[line]
% \framed[frame=off,location=middle,width=\textwidth]
%       {\externalfigure[logo][width=0.25\textwidth]}


Anonymous



The Black Flag






August 12 1883


\stopalignment
\blank[line]

\startalignment[hyphenated,middle]


The Black Flag from Le Drapeau Noir, No.1, August 12 1883. (Translated from the French by Michael Shreve)



http://michaelshreve.wordpress.com/2013/05/09/the-black-flag/


\stopalignment

\stoptext


