\documentclass[DIV=12,%
               BCOR=0mm,%
               headinclude=false,%
               footinclude=false,open=any,%
               fontsize=11pt,%
               oneside,%
               paper=210mm:11in]%
               {scrbook}






\usepackage[noautomatic]{imakeidx}



\usepackage{microtype}
\usepackage{graphicx}
\usepackage{alltt}
\usepackage{verbatim}
\usepackage[shortlabels]{enumitem}
\usepackage{tabularx}
\usepackage[normalem]{ulem}
\def\hsout{\bgroup \ULdepth=-.55ex \ULset}
% https://tex.stackexchange.com/questions/22410/strikethrough-in-section-title
% Unclear if \protect \hsout is needed. Doesn't looks so
\DeclareRobustCommand{\sout}[1]{\texorpdfstring{\hsout{#1}}{#1}}
\usepackage{wrapfig}

% avoid breakage on multiple <br><br> and avoid the next [] to be eaten
\newcommand*{\forcelinebreak}{\strut\\*{}}

\newcommand*{\hairline}{%
  \bigskip%
  \noindent \hrulefill%
  \bigskip%
}

% reverse indentation for biblio and play

\newenvironment*{amusebiblio}{
  \leftskip=\parindent
  \parindent=-\parindent
  \smallskip
  \indent
}{\smallskip}

\newenvironment*{amuseplay}{
  \leftskip=\parindent
  \parindent=-\parindent
  \smallskip
  \indent
}{\smallskip}

\newcommand*{\Slash}{\slash\hspace{0pt}}


% http://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-url
\PassOptionsToPackage{hyphens}{url}\usepackage[hyperfootnotes=false,hidelinks,breaklinks=true]{hyperref}
\usepackage{bookmark}

\usepackage[english,shorthands=off]{babel}
\babelfont{rm}[Path=/usr/share/fonts/truetype/cmu/,%
 BoldFont=cmunbx.ttf,%
 BoldItalicFont=cmunbi.ttf,%
 ItalicFont=cmunti.ttf]{cmunrm.ttf}
\babelfont{tt}[Scale=MatchLowercase,%
 Path=/usr/share/fonts/truetype/cmu/,%
 BoldFont=cmuntb.ttf,%
 BoldItalicFont=cmuntx.ttf,%
 ItalicFont=cmunit.ttf]{cmuntt.ttf}
\babelfont{sf}[Scale=MatchLowercase,%
 Path=/usr/share/fonts/truetype/cmu/,%
 BoldFont=cmunsx.ttf,%
 BoldItalicFont=cmunso.ttf,%
 ItalicFont=cmunsi.ttf]{cmunss.ttf}



\renewcommand*{\partpagestyle}{empty}


% global style

\pagestyle{plain}




\usepackage{indentfirst}

% remove the numbering
\setcounter{secnumdepth}{-2}

% remove labels from the captions
\renewcommand*{\captionformat}{}
\renewcommand*{\figureformat}{}
\renewcommand*{\tableformat}{}
\KOMAoption{captions}{belowfigure,nooneline}
\addtokomafont{caption}{\centering}







\deffootnote[3em]{0em}{4em}{\textsuperscript{\thefootnotemark}~}


\addtokomafont{disposition}{\rmfamily}
\addtokomafont{descriptionlabel}{\rmfamily}


\frenchspacing
% avoid vertical glue
\raggedbottom

% this will generate overfull boxes, so we need to set a tolerance
% \pretolerance=1000
% pretolerance is what is accepted for a paragraph without
% hyphenation, so it makes sense to be strict here and let the user
% accept tweak the tolerance instead.
\tolerance=200
% Additional tolerance for bad paragraphs only
\setlength{\emergencystretch}{30pt}

% (try to) forbid widows/orphans
\clubpenalty=10000
\widowpenalty=10000





% given that we said footinclude=false, this should be safe
\setlength{\footskip}{2\baselineskip}
\setlength{\parindent}{15pt}

\title{Rare AmuseWiki text markup problems \& fixes}
\date{}
\author{}
\subtitle{}






% https://groups.google.com/d/topic/comp.text.tex/6fYmcVMbSbQ/discussion
\hypersetup{%
pdfencoding=auto,
pdftitle={Rare AmuseWiki text markup problems \& fixes},%
pdfauthor={},%
pdfsubject={},%
pdfkeywords={Introductory Documents}%
}


\begin{document}









  \begin{titlepage}


  \strut\vskip 2em
  \begin{center}

  {\usekomafont{title}{\huge Rare AmuseWiki text markup problems \& fixes\par}}%
  \vskip 1em
  
  \vskip 2em
  
  \vskip 1.5em



   
   \vfill



  
    \strut\par
  


  \end{center}


     \end{titlepage}
     
     \cleardoublepage





\tableofcontents
% start a new right-handed page

\cleardoublepage



\chapter{Fixing unmarked footnotes}


\begin{enumerate}[1.]
\item\relax 
In word365 find and replace '\^{}p' with '\^{}p\#\#\#', in order to preserve the text when you copy into a spreadsheet later, so it doesn't delete apostrophes and quote marks at the beginning of paragraphs.



\item\relax 
Click Edit -> Select -> Select All



\item\relax 
Cut and paste into a notepad to preserve the paragraph spacing.



\item\relax 
Cut and paste into google sheets column B.



\item\relax 
In 'Cell A1', type '1'.



\item\relax 
In 'Cell A2', type '=A1+1'.



\item\relax 
Then 'shift+Ctrl+down' and 'Ctrl+D' to highlight the rest of the column and create a column of numbers.



\item\relax 
Then 'ctrl+c', right click and click paste as plain text.



\item\relax 
Then highlight both column 1 and 2, and sort by column 2.



\item\relax 
Then mark all the cells beginning with numbers, by putting an 'x' in column 3.



\item\relax 
Then sort by column 1 to check what numbers you marked.



\item\relax 
Scroll down column 3 with a mix of 'ctrl+down arrow key' and the mouse wheel, deleting numbers that aren't footnotes.



\item\relax 
Then sort by column 3 to reveal just the footnotes.



\item\relax 
Ctrl highlight the footnotes in column 2, and copy paste them into column 4.



\item\relax 
Then from the toolbar click 'Data' -> split text to columns -> and click 'period' in the seperator.



\item\relax 
Ctrl+highlight the remaining numbers and 3 hashes, then find and replace the hashes.



\item\relax 
Ctrl+highlight the 4 columns connected to the footnotes and sort by column 4.



\item\relax 
In 'cell A4' type '=replace(A2+1,3,"[")



\item\relax 
Hold 'Ctrl+down' then 'Ctrl+D' to continue the formula for the rest of the text.



\item\relax 
Ctrl+highlight that group of text, then right click 'cell A1' and click 'paste as plain text'.



\item\relax 
In 'cell A4' type '=replace(A2+2,1,"] ")'



\item\relax 
Hold 'Ctrl+down' then 'Ctrl+D' to continue the formula for the rest of the text.



\item\relax 
Go back to the top and check where the footnotes go from the number '9' to '10' and change the second part of the replace formula from a '2' to a '3', so '=replace(A2+3,1,"] ")'



\item\relax 
Repeat if the footnotes go up to 100, 1000, etc. by changing from a '3', to a '4', etc.



\item\relax 
Ctrl+highlight that group of text, then right click 'cell A1' and click 'paste as plain text'.



\item\relax 
highlight all text on the sheet by clicking the top left corner and sort by column 1.



\item\relax 
highlight the text and copy paste into a notepad.



\item\relax 
Find and replace delete the rest of the \#\#\# and you're done.




\end{enumerate}


\bigskip

\chapter{Quote Indents}


This takes a long time, but if you have a lot of books you want to bulk upload perfectly with quote indents, you can do them this way and all at the same time so it's worth it:


So if I have the document open in LibreOffice, I hit File -> Export -> and chose MediaWiki format in the 'Save as' drop down menu.


Then I open up the new file and copy paste it back into an office word document. All the indents will look something like this: "<div style="margin-left:1.251cm;margin-right:0cm;">\_\_\_<\Slash{}div>


Then I find and replace all the "<div style\dots{}" and<\Slash{}div> into amusewiki code <quote>and<\Slash{}quote> .


Then replace single line quotes into block quotes by doing find and replace "<\Slash{}quote>\^{}p\^{}p<quote>" with simply "\^{}p\^{}p".



\bigskip

\chapter{Rearranging Footnotes}


If you have a long book with chapter specific footnotes, like so:


\begin{alltt}
** Chapter 1

[1] Blah.

[2] Blah.

** Chapter 2

[1] Blah.

[2] Blah.
\end{alltt}


Then you can fix them under "Filters", by checking the box that says "Rearrange footnotes".


If it throws up an error such as:


\begin{alltt}
@@ -413,6 +413,7 @@
 \{17\}
 \{18\}
 \{19\}
+\{8\}
 \{20\}
 \{21\}
 \{22\}

@@ -447,13 +448,11 @@
 \{51\}
 \{52\}
 \{1\}
-\{2\}
 \{3\}
 \{4\}
 \{5\}
 \{6\}
 \{7\}
-\{8\}
 \{9\}
 \{10\}
 \{11\}
\end{alltt}


Then what it's saying is the first number after the '@@' is the current paragraph number in the 'text change difference script'. The second number after the '@@' and ',' is the number of current footnotes shown below it. The third and fourth numbers are what the paragraph number and footnote number should be after error correcting.



\bigskip


The line prefixed with '-' come from the footnotes, the '+' from the references in the body


So, what it's saying is if you search that page for \{19\} or \{8\} you'll see that the body has a spurious \{8\}.


And later on it's missing a \{2\} and a \{8\}. So you could check through your \{1\}'s and \{7\}'s and scroll down each time to find the missing \{2\} \& \{8\}.



\bigskip


Typing Ctrl+F, then '[1]' can sometimes help you speed up looking for where in the text the footnote error is, because where it says e.g. "found 767 footnotes ([1] [2] [1] [8] [2]) ... found 766 footnote references in the body ([1] [2] [1] [8] [2])", you'll be able to see which set of chapter footnotes the error is in, so in that example, in the second set.


Finally, for a really hard to find number, you can copy all of them from the list of 'found footnotes and references' and paste them into a spreadsheet to see them along side each other.



\bigskip

\chapter{Primary Footnotes in the Secondary Footnotes}


If you have a long book with two sets of footnotes like so:



\begin{quote}


Blah blah blah.\textsuperscript{a}


a. Blah.\textsuperscript{1}


1. Blah.



\end{quote}


Then after converting the document, the footnotes might end up looking like below, but it'll be broken:


\begin{alltt}
Blah blah blah.\{1\}

[1] Blah.

\{1\} Blah.[1]
\end{alltt}


To fix this, you could copy paste the text into a word document and use 'find and replace' a tonne of times to swap them round, like so:


\begin{itemize}
\item\relax 
Find '\{' replace with '@@@'



\item\relax 
\} -> \&\&\&



\item\relax 
[1 -> \{1



\item\relax 
[2 -> \{2



\item\relax 
0] -> 0\}



\item\relax 
1] -> 1\}



\item\relax 
\dots{}



\item\relax 
@@@ -> [



\item\relax 
\&\&\& -> ]




\end{itemize}


\bigskip

\chapter{Copying over amusewiki texts from other libraries}


This is what I do to quickly copy over texts from other amusewiki libraries:


\begin{itemize}
\item\relax 
Click 'add new text'



\item\relax 
Copy paste the end of the URL after \Slash{}library\Slash{} (e.g. "black-rose-anarchist-federation-turning-the-tide") from the doc into the title box, so that it automatically generates a URL based on the title, and hit 'Create'



\item\relax 
Then once in the edit box, delete everything other than the \#pubdate



\item\relax 
Click 'plain text source' on the doc



\item\relax 
Zoom out, highlight all the text, then cut and paste into the edit box.



\item\relax 
Delete the old \#pubdate



\item\relax 
Save and publish.




\end{itemize}








% begin final page

\clearpage



% new page for the colophon

\thispagestyle{empty}

\begin{center}

The Ted K Archive





\strut

\end{center}

\strut

\vfill

\begin{center}




Rare AmuseWiki text markup problems \& fixes






\bigskip



   

       

       

       

       

       

       

   



\bigskip
\textbf{www.thetedkarchive.com}


\end{center}

% end final page with colophon


% end closing pages



\end{document}


% No format ID passed.



