Compare commits
3 commits
41f51bf6fe
...
fb80c61139
Author | SHA1 | Date | |
---|---|---|---|
fb80c61139 | |||
7230d87f6b | |||
bf46105db8 |
4 changed files with 92 additions and 16 deletions
|
@ -76,9 +76,18 @@
|
|||
\fncount=1
|
||||
\def\fnmark{\superscript{\the\fncount}}
|
||||
\def\fn#1{\footnote\fnmark{#1}\advance\fncount by 1}
|
||||
\def\section#1#2{\vfil\eject{\parskip1em\settextsize{20}\bf #1\kern 1em #2}}
|
||||
\def\subsection#1#2{{\parskip1em\settextsize{18}\bf #1\kern 1em #2}}
|
||||
\def\subsubsection#1#2{{\parskip1em\settextsize{16}\bf #1\kern 1em #2}}
|
||||
\def\section#1#2{
|
||||
\vfil\eject{\parskip1em\settextsize{20}\bf #1\kern 1em #2}
|
||||
\addtoc\tocsection{#1}{}{#2}
|
||||
}
|
||||
\def\subsection#1#2{
|
||||
{\parskip1em\settextsize{18}\bf #1\kern 1em #2}
|
||||
\addtoc\tocsubsection{#1}{}{#2}
|
||||
}
|
||||
\def\subsubsection#1#2{
|
||||
{\parskip1em\settextsize{16}\bf #1\kern 1em #2}
|
||||
\addtoc\tocsubsubsection{#1}{}{#2}
|
||||
}
|
||||
\def\subsubsubsection#1#2{{\parskip1em\settextsize{14}\bf #1\kern 1em #2}}
|
||||
\def\subsubsubsubsection#1#2{{\parskip1em\settextsize{12}\bf #1\kern 1em #2}}
|
||||
\def\subsubsubsubsubsection#1#2{{\parskip1em\settextsize{10}\bi #1\kern 1em #2}}
|
||||
|
@ -191,3 +200,17 @@
|
|||
}}}
|
||||
}}
|
||||
|
||||
|
||||
|
||||
|
||||
% Obsah a odkazy
|
||||
\newwrite\tocfile
|
||||
\immediate\openout\tocfile=toc-new.aux
|
||||
|
||||
% Voláme: \addtoc\tocmacro{number}{asterisks}{title}
|
||||
\long\def\addtoc#1#2#3#4{
|
||||
\edef\brum{
|
||||
\write\tocfile{\string#1{\noexpand\the\noexpand\count0}{#2}{#3}{#4}}
|
||||
}
|
||||
\brum
|
||||
}
|
23
src/formatitko/tex/table_of_contents.tex
Normal file
23
src/formatitko/tex/table_of_contents.tex
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
|
||||
\def\pagelink#1{#1}
|
||||
\def\toclink#1#2{%
|
||||
#2
|
||||
}
|
||||
|
||||
\def\stdskip{\vskip 3pt}
|
||||
\def\tocsection#1#2#3#4{
|
||||
\line{\settextsize{14}\bf\hbox to 2em{#2\hfil}#4~\hfil\pagelink{#1}}\stdskip
|
||||
}
|
||||
\def\tocsubsection#1#2#3#4{
|
||||
\line{\bf\hskip 1.5cm \hbox to 3em{#2\hfil}#4~\hfil\pagelink{#1}}\stdskip
|
||||
}
|
||||
\def\tocsubsubsection#1#2#3#4{
|
||||
\line{\bf\hskip 3cm \hbox to 4em{#2\hfil}#4~\hfil\pagelink{#1}}\stdskip
|
||||
}
|
||||
\def\tocpicture#1#2#3#4{}
|
||||
|
||||
\vskip 1cm
|
||||
\input toc.aux
|
||||
|
||||
}
|
18
src/formatitko/tex/table_of_contents_pictures.tex
Normal file
18
src/formatitko/tex/table_of_contents_pictures.tex
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
|
||||
\def\pagelink#1{#1}
|
||||
\def\toclink#1#2{%
|
||||
#2
|
||||
}
|
||||
|
||||
\def\stdskip{\vskip 3pt}
|
||||
\def\tocsection#1#2#3#4{}
|
||||
\def\tocsubsection#1#2#3#4{}
|
||||
\def\tocsubsubsection#1#2#3#4{}
|
||||
\def\tocpicture#1#2#3#4{
|
||||
\line{\hbox to 2em{#2\hfil}#4~\hfil\pagelink{#1}}\stdskip
|
||||
}
|
||||
|
||||
\vskip 1cm
|
||||
\input toc.aux
|
||||
}
|
|
@ -27,19 +27,25 @@ class UCWTexGenerator(OutputGenerator):
|
|||
super().__init__(output_file, *args, **kwargs)
|
||||
|
||||
def escape_special_chars(self, text: str) -> str:
|
||||
text = text.replace("&", r"\&")
|
||||
text = text.replace("%", r"\%")
|
||||
text = text.replace("$", r"\$")
|
||||
text = text.replace("#", r"\#")
|
||||
text = text.replace("_", r"\_")
|
||||
text = text.replace("{", r"\{")
|
||||
text = text.replace("}", r"\}")
|
||||
text = text.replace("~", r"\textasciitilde{}")
|
||||
text = text.replace("^", r"\textasciicircum{}")
|
||||
text = text.replace("\\", r"\textbackslash{}")
|
||||
text = text.replace(" ", "~") # We use unicode no-break spaces to force nbsp in output
|
||||
text = text.replace("", "")
|
||||
return text
|
||||
if '\\' in text:
|
||||
print("ESCAPE", text)
|
||||
out = ""
|
||||
for char in text:
|
||||
out += {
|
||||
'&': r"\&",
|
||||
'%': r"\%",
|
||||
'$': r"\$",
|
||||
'#': r"\#",
|
||||
'_': r"\_",
|
||||
'{': r"\{",
|
||||
'}': r"\}",
|
||||
'~': r"\textasciitilde{}",
|
||||
'^': r"\textasciicircum{}",
|
||||
'\\': r"\textbackslash{}",
|
||||
' ': r"~",
|
||||
'': r"",
|
||||
}.get(char, char)
|
||||
return out
|
||||
|
||||
def generate(self, e: Union[Element, ListContainer]):
|
||||
if hasattr(e, "attributes") and "only" in e.attributes and e.attributes["only"] != "tex":
|
||||
|
@ -164,6 +170,12 @@ class UCWTexGenerator(OutputGenerator):
|
|||
if 'number' in e.attributes:
|
||||
self.writeln(f"Obrázek {e.attributes['number']}:")
|
||||
self.generate(e.caption)
|
||||
if 'number' in e.attributes:
|
||||
self.writeln(r"\addtoc\tocpicture{"+str(e.attributes['number'])+"}{}{")
|
||||
self.indent_more()
|
||||
self.generate(e.caption.content)
|
||||
self.indent_less()
|
||||
self.writeln("}")
|
||||
self.indent_less()
|
||||
self.writeln(r"}{}")
|
||||
self.ensure_empty(2)
|
||||
|
|
Loading…
Reference in a new issue