I have 2 different types of block quotes: from literature and from interview transcripts. Since the interviews have several speakers some of the transcript quotes will have a change of speakers and I use initials (A: … B:…) to indicate who is speaking. I would like for those quotes to be formatted such that the initials are aligned and the content of their speech is indented and aligned.
In LaTeX previously simply used the enumitem package and generated a list type of my own choosing with two arguments, so that I could copy the transcript into a list of this type:
How would I do that in a Scrivener → MMD → Pandoc → LaTex workflow? I am guessing styles cannot take any arguments and I am uncertain whether MMD/Pandoc handle own list types or whether this is best inserted in LaTeX syntax (or a minimal version of it, with the rest being substituted through the compile replacements). Any help is much appreciated!
…do not include the option to override the list marker or repeat list markers. You can restart numbering using different formatting however, so you can switch between e.g. latin numerals and letters like so (a trick if you want to quickly check how pandoc may transform something is you can run pandoc/MMD using standard input, enter text to it via the commandline and when you want to see the output, press CTRL+D to process it):
> pandoc -t latex
This is a test.
I) Here we are
A) Yes we are
II) Here we are
B) Yes we are
End of test.
CTRL+D
This is a test.
\begin{enumerate}
\def\labelenumi{\Roman{enumi})}
\tightlist
\item
Here we are
\end{enumerate}
\begin{enumerate}
\def\labelenumi{\Alph{enumi})}
\tightlist
\item
Yes we are
\end{enumerate}
\begin{enumerate}
\def\labelenumi{\Roman{enumi})}
\setcounter{enumi}{1}
\tightlist
\item
Here we are
\end{enumerate}
\begin{enumerate}
\def\labelenumi{\Alph{enumi})}
\setcounter{enumi}{1}
\tightlist
\item
Yes we are
\end{enumerate}
End of test.
But this would create new list per entry, which may make too much white space or require changing the formatting. And you would need to reset the counters using a script, not so easy. BUT perhaps a definition list could be used?
➜ pandoc -t latex
This is a test.
A
: This is some text.
B
: More text.
A
: This is text too.
B
: The end.
Some normal text...
CTRL+D
This is a test.
\begin{description}
\tightlist
\item[A]
This is some text.
\item[B]
More text.
\item[A]
This is text too.
\item[B]
The end.
\end{description}
Some normal text\ldots{}
This looks like this as a LaTeX PDF output (default Pandoc template):
[attachment=0]Screen Shot 2021-03-09 at 14.28.13.png[/attachment]
If this still doesn’t look as you want, then I’d stick to using the compiler to generate raw latex…
This is looking promising - thanks so much! I don’t like for the list items /speaker initials to be bold but I’ll tinker around with it to see if i can change it.
If I do end up using the compiler to add raw latex , how would you go about it in the most elegant fashion? With replacements and/or a custom style? I would probably still have to mark the list items in the Scrivener editor more clearly than"A:", “B:” because I could imagine there might be wrong replacements (although I am not sure in what kind of sentence, reference, etc. you would ever use a semicolon after a capital letter…) …
A style will get you a paragraph > latex environment conversion and line prefixes and if you cheat a bit with the text:
[attachment=1]Screen Shot 2021-03-10 at 12.06.28.png[/attachment]
… using a compile style that adds prefix=\begin{itemize} / suffix = \end{itemize} and paragraph prefix = \item[ produces a working latex list:
begin{itemize}
\item[A:] This is some info.
\item[B:] Some more info.
\item[A:] More stuff.
end{itemize}
[attachment=0]Screen Shot 2021-03-10 at 12.14.02.png[/attachment]
But it isn’t really elegant, in that we are putting the ] in the editor directly. A replacement would make this a bit more elegant, you’d specify a unique tag to replace…
I’m wondering what kind of tag you mean and how this would be any more elegant than typing something like:] directly into Scrivener… It would still have to be a similarly unique combination of characters, so the replacement works right?
And one other thing I’ve wondered about:
If I set up the compile format to add prefixes and suffixes around a style in LaTeX syntax, how would that work with a multi-output kind of workflow using scrivomatic? Surely the LaTeX syntax would end up in the md file and hence all output files (HTML, docx, etc.) that are converted via pandoc from there, right?
Here is an example regex replacement using a template of a #+uppercase letter+colon+space, it is completely subjective which is more or less elegant — in your case the ] could represent the brackets that are common in list formats anyway so it doesn’t look too bad…
Yes, using raw latex is not ideal for multiple-output workflows. If you were good at programming, you could create a Pandoc filter that could translate the RAW latex depending on the output format (an example for pagebreaks: github.com/pandoc/lua-filters/t … /pagebreak). If multiple formats is your priority then I’d stick with definition lists and use the template to try to customise their appearance…
Just to follow up on this- I’ve implemented this and it’s working just fine. The only thing I’m wondering about: how can i add a line break in the compile style prefix/suffix so that \begin{itemize} and \end{itemize} are on a separate line before the actual content of the style?
If you’re on a Mac, you can use Opt-Return and Opt-Tab to insert whitespace into special fields like this. For simple stuff like keeping environment commands on their own line, that is fine, though once you start doing that, it’s good to keep in mind you’ve done it, since starting a suffix with an empty line will cause the field to look empty in the future, until you arrow around in a bit.
For more complex multi-line stuff (or even just long commands) I will copy and paste out to a text editor (scratch pad may work nice if you just need a quick place to do this), edit it there, and then bring it back in when I’m done. This is the only way to do it on Windows at the moment.