summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/thalie/thalie.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/thalie/thalie.dtx')
-rw-r--r--macros/latex/contrib/thalie/thalie.dtx173
1 files changed, 150 insertions, 23 deletions
diff --git a/macros/latex/contrib/thalie/thalie.dtx b/macros/latex/contrib/thalie/thalie.dtx
index 53230be775..ec07177168 100644
--- a/macros/latex/contrib/thalie/thalie.dtx
+++ b/macros/latex/contrib/thalie/thalie.dtx
@@ -1,5 +1,5 @@
% \iffalse meta-comment
-% Copyright 2010-2019 Louis Paternault
+% Copyright 2010-2021 Louis Paternault
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -25,7 +25,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{thalie}
%<*package>
- [2019/07/31 v0.10b A package to typeset drama plays]
+ [2021/09/26 v0.10c A package to typeset drama plays]
%</package>
%
%<*driver>
@@ -34,6 +34,7 @@
\CodelineIndex
\RecordChanges
\usepackage{array}
+\usepackage{csquotes}
\usepackage{enumerate}
\usepackage{multirow}
\usepackage{hyperref}
@@ -42,6 +43,7 @@
\usepackage{listings}
\usepackage{xcolor}
\usepackage{manfnt}
+\usepackage[normalem]{ulem}
\lstset{
language=[LaTeX]TeX,
numbers=left,
@@ -137,7 +139,7 @@
% This document corresponds to \textsf{thalie}~\fileversion, dated \filedate.
% Home page, bug requests, etc. at \url{http://framagit.org/spalax/thalie}
% }\\A package to typeset drama plays}
-% \author{Louis Paternault\\ \texttt{spalax+ctan(at)gresille(dot)org}}
+% \author{Louis Paternault\\ \texttt{spalax(at)gresille(dot)org}}
%
% \maketitle
%
@@ -247,7 +249,7 @@
% \item Download the lastest archive :
% \begin{description}
% \item[Stable version] \url{http://mirrors.ctan.org/install/macros/latex/contrib/thalie.tds.zip}
-% \item[Development version] \url{https://framagit.org/spalax/thalie/repository/archive.zip?ref=master}
+% \item[Development version] \url{https://framagit.org/spalax/thalie/repository/archive.zip?ref=main}
% \end{description}
% \item Unzip the archive.
% \item If you got the archive from CTAN (stable version), move file \texttt{tex/latex/thalie/thalie.sty} in a \LaTeX{} path.
@@ -998,15 +1000,15 @@ No! It's a bit short, young man\ldots
% \character[cmd={hermia}]{Hermia}
% \character[cmd={theseus}]{Theseus}
% \end{dramatis}
+% \setthalieoptions{characterstyle=imprimerie-verse}
% \begin{LTXexample}[pos=b]
-\adjustverse{-7em}
-
\hermia
So is Lysander.\pauseverse
\theseus
\resumeverse In himself he is.
% \end{LTXexample}
+% \setthalieoptions{characterstyle=simple}
% \iffalse
%</example>
% \fi
@@ -1024,6 +1026,31 @@ So is Lysander.\pauseverse
% \character[cmd={theseus}]{Theseus}
% \end{dramatis}
% \begin{LTXexample}[pos=b]
+\adjustverse{-7em}
+
+\hermia
+So is Lysander.\pauseverse
+
+\theseus
+\resumeverse In himself he is.
+% \end{LTXexample}
+% \iffalse
+%</example>
+% \fi
+% \caption{Example of commands to adjust splitted verse}
+% \label{fig:splitverse-adjusted}
+% \end{figure}
+%
+% \begin{figure}[p]
+% \centering
+% \iffalse
+%<*example>
+% \fi
+% \begin{dramatis}[hidden]
+% \character[cmd={hermia}]{Hermia}
+% \character[cmd={theseus}]{Theseus}
+% \end{dramatis}
+% \begin{LTXexample}[pos=b]
\hermia
So is Lysander.
@@ -1038,23 +1065,12 @@ So is Lysander.
% \end{figure}
%
% \danger
-% Warning: I do not understand the code behind this feature. I copied-pasted code by David Carlisle\footnote{Originally written as an answer to a StackExchange question: see \url{https://tex.stackexchange.com/a/107727}.} without understanding it. There are probably bugs, but I won't be able to solve them.
-% This feature can also be implemented using the \lstinline|\phantom| command (see figure \ref{fig:splitverse-phantom} for an example, page \pageref{fig:splitverse-phantom}).
-% It is far less user-friendly, but it also less error prone. Choose wisely…
+% Warning: this is still experimental. I present several recipes to achieve this, but they all have their pros and cons.
%
% \DescribeMacro{\pauseverse}
% \DescribeMacro{\resumeverse}
-% \DescribeMacro{\adjustverse}
-%
-% Command \lstinline|\pauseverse| is used at the end of the verse to be continued,
-% while command \lstinline|\resumeverse| is used at the beginning of the continuing
-% verse.
-% Let us face it: these commands are kind of a hack, and sometimes, the lines
-% are not aligned the way one would expect them to. To correct this, command
-% \lstinline|\adjustverse|\marg{length} can be used to add an extra (possibly negative)
-% space when calling \lstinline|\resumeverse|, to get a correct alignment.
-% See figure \ref{fig:splitverse}, page \pageref{fig:splitverse}, for an
-% example of those three commands.
+% The recipes presented below all implement macros \lstinline|\pauseverse| and \lstinline|\resumeverse|.
+% Command \lstinline|\pauseverse| is used at the end of the verse to be continued, while command \lstinline|\resumeverse| is used at the beginning of the continuing verse. See figure \ref{fig:splitverse} (page \pageref{fig:splitverse}) for an example.
%
% When writing a play in verse, one can use a lot of those commands, which can
% be tedious because of their long names. So, defining ``shortcuts'' of those
@@ -1071,10 +1087,120 @@ So is Lysander.
%</example>
% \fi
%
-% This is not done by default, because short command names are a scare ressource
+% This is not done by default, because short command names are a scarce ressource
% in \LaTeX, so, defining these commands by default might conflict with other
% packages, while most of |thalie| users will not use them.
%
+% \subsubsection{Which recipe should I use?}
+%
+% As I have already stated, there are several ways to achieve this, but none of them is perfect.
+%
+% \begin{itemize}
+% \item Do try the first recipe (section \ref{split-latex}). If it works, stick to it. Otherwise…
+% \item If you do not mind loading the \texttt{TikZ} package, use it (section \ref{split-tikz}). As far as I know, from a user point of view, it is the easiest recipe to use, with the less bugs. Otherwise…
+% \item You can try building you own commands (section \ref{split-hanging}). Otherwise…
+% \item The last recipe (section \ref{split-phantom}) always works. It is far less user-friendly, but it does the job.
+% \end{itemize}
+%
+% \subsubsection{Recipe 1 : Pure \LaTeX}
+% \label{split-latex}
+
+% \danger
+% Warning: I do not understand the code behind this feature. I copied-pasted code by David Carlisle\footnote{Originally written as an answer to a StackExchange question: see \url{https://tex.stackexchange.com/a/107727}.} without understanding it. There are \sout{probably} bugs\footnote{One on them lead to the next recipe.}, but I won't be able to solve them.
+%
+% The implemented macros \lstinline|\pauseverse| and \lstinline|\resumeverse| are written in pure \LaTeX (without any external package). For backward compatibility reasons, this will remain the default implementation for some time…
+%
+% \DescribeMacro{\adjustverse}
+% If the character names are displayed on the same line as the verse, the lines
+% are not aligned the way one would expect them to. To correct this, command
+% \lstinline|\adjustverse|\marg{length} can be used to add an extra (possibly negative)
+% space when calling \lstinline|\resumeverse|, to get a correct alignment.
+% See figure \ref{fig:splitverse-adjusted}, page \pageref{fig:splitverse-adjusted}, for an
+% example of those three commands.
+%
+% The young inexperienced fool\footnote{Me…} who originally wrote those commands had not noticed that \lstinline|\adjustverse| is needed because \lstinline|\resumeverse| does not take into account the length of the character names, in styles where it appears on the same line as the verse. This (probably) won't be fixed, because some people might be using this, and fixing this might break their document.
+%
+% If you encounter the same issue, you might prefer one of the other recipes.
+%
+% \subsubsection{Recipe 2 : With package \texttt{hanging}}
+% \label{split-hanging}
+%
+% \danger
+% Warning: This is a do-it-yourself recipe.
+%
+% The bug announced at the end of the previous recipe, has been spotted and partially corrected by egreg on StackExchange\footnote{\url{https://tex.stackexchange.com/a/545326}}. He proposes the following code to fix this.
+%
+% \iffalse
+%<*example>
+% \fi
+% \begin{lstlisting}
+\usepackage{hanging}
+
+\newlength{\brokenverse}
+\renewcommand*{\speakswithoutdirection}[1]{%
+ \settowidth{\brokenverse}{\textsc{#1}.}%
+ \hangpara{2\parindent}{1}\noindent\textsc{#1}.%
+}
+\makeatletter
+\renewcommand{\resumeverse}{%
+ \hspace{\@verseadjust}\hspace{\dimexpr\dimen\@ne-\brokenverse-2em}
+}
+\makeatother
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% This code ignores the choosen style (it actually redesigns it), and it only works with lines without character directions. If needed, you should also define a \lstinline|\speakswithdirection| command to implement the same feature.
+%
+% \subsubsection{Recipe 3 : With package \texttt{TikZ}}
+% \label{split-tikz}
+%
+% % As far as I know, this recipe is the best one, from a user point of view. But it loads the \texttt{TikZ} package, which is a huge package to implement such a tiny feature\footnote{In French, we would say : \enquote{\foreignlanguage{french}{Un marteau-pilon pour écraser une mouche}} (a far too heavy solution for a tiny problem).}.
+%
+% \iffalse
+%<*example>
+% \fi
+% \begin{lstlisting}
+\usepackage{tikz}
+\usetikzlibrary{tikzmark}
+\usetikzlibrary{math}
+\newcounter{thalieverse}
+\tikzset{tikzmark suffix=-\thethalieverse}%
+\renewcommand{\pauseverse}{%
+ \stepcounter{thalieverse}
+ \tikzmark{thaliepauseverse}
+}
+\renewcommand{\resumeverse}{%
+ \tikzmark{thalieresumeverse}%
+ \iftikzmark{thaliepauseverse}{%
+ \begin{tikzpicture}[remember picture]%
+ % Uncomment to see "pause" and "resume" tikz marks.
+ %\draw[overlay,green, ultra thick] (pic cs:thaliepauseverse) -- (pic cs:thalieresumeverse);%
+ \tikzmath{
+ coordinate \c;
+ \c1 = (pic cs:thaliepauseverse);
+ \c2 = (pic cs:thalieresumeverse);
+ \width = max(0, \cx1 - \cx2);
+ }
+ % Set opacity to 1 to see the space
+ \draw[opacity=0, black, line width=1ex] (0, 0) -- (\width pt, 0);
+ \end{tikzpicture}%
+ }{}%
+}
+\end{lstlisting}
+% \iffalse
+%</example>
+% \fi
+%
+% This recipe is implemented in the \href{https://framagit.org/spalax/thalie/-/blob/main/examples/henry.tex}{\texttt{examples/henry.tex}} file in the repository of this project.
+%
+% \subsubsection{Recipe 4 : With \texttt{\textbackslash{}phantom\{\}}}
+% \label{split-phantom}
+%
+% At last, if nothing else workd, this feature can also be implemented using the \lstinline|\phantom| command (see figure \ref{fig:splitverse-phantom} for an example, page \pageref{fig:splitverse-phantom}).
+% It is far less user-friendly, but it is also less error prone. Choose wisely…
+%
% \section{Localization and Internationalization}
% \label{sec:i18n}
%
@@ -1173,10 +1299,10 @@ So is Lysander.
\character[cmd=eve]{Eve}
\end{dramatis}
}]
-\alice
+\bob
Let's open it.
-\disposablecharacter{\bobname and \evename}
+\disposablecharacter{\alicename and \evename}
No!
% \end{LTXexample}
% \iffalse
@@ -1953,6 +2079,7 @@ One!
% \subsection{Splitting verses}
% \begin{macro}{\pauseverse}
% \changes{v0.7}{2015/12/28}{New commands \texttt{\bbackslash{}pauseverse}, \texttt{\bbackslash{}resumeverse}, \texttt{\bbackslash{}adjustverse}.}
+% \changes{v0.10c}{2021/09/26}{Document other implementations of \texttt{\bbackslash{}pauseverse} and \texttt{\bbackslash{}resumeverse}}
% \begin{macro}{\resumeverse}
% \begin{macro}{\adjustverse}
% Commands to split a verse between several characters.