Compare commits

..

No commits in common. "cc88aff49b88c4ccaed61ae34ce7be4cf8620490" and "5a9cc630bbdebc6dc6e689b9ba7a44dff810051a" have entirely different histories.

17 changed files with 34 additions and 106 deletions

View File

@ -34,6 +34,18 @@
\rule{\widefigurewidth}{0.4pt} \rule{\widefigurewidth}{0.4pt}
} }
% Listings mode
% =============
% The listings mode can be chosen by writing one of the following to the listings-mode.tex file before compilation:
% \newcommand\listingsmode{default} % to use lstlistings
% \newcommand\listingsmode{minted} % for a script with exercises only
% The following lines include that file or make \listingsmode default to 'default' so that any derivatives of this project will work even without the file.
%\IfFileExists{listings-mode.tex}{
% \input{listings-mode.tex}
%}{
% \newcommand\listingsmode{default}
%}
% Shell command % Shell command
% ============== % ==============
% Mono-spaced text without syntax highlighting. % Mono-spaced text without syntax highlighting.

View File

@ -2,30 +2,22 @@
for D in listings/*; do for D in listings/*; do
if [ -d "${D}" ]; then if [ -d "${D}" ]; then
# Compile without cropping. # Compile without cropping.
# References to other files are interpreted relative to the
# root directory.
for F in ${D}/*_page.tex; do for F in ${D}/*_page.tex; do
if [ -f "${F}" ]; then if [ -f "${F}" ]; then
echo "###### Compiling ${F} ######" echo "###### Compiling ${F} ######"
pdflatex --shell-escape --output-directory "${D}" "${F}" pdflatex --output-directory "${D}" "${F}"
fi fi
done done
# Compile with cropping. # Compile with cropping.
# Careful: References to other files are interpreted relative
# to the file, not to the root directory.
for F in ${D}/*_crop.tex; do for F in ${D}/*_crop.tex; do
if [ -f "${F}" ]; then if [ -f "${F}" ]; then
echo "###### Compiling and cropping ${F} ######" echo "###### Compiling and cropping ${F} ######"
pushd "${D}" pdflatex --output-directory "${D}" "${F}"
pdflatex --shell-escape "$(basename $F)" pdfcrop "${D}/$(basename -s .tex ${F}).pdf" \
pdfcrop "$(basename -s .tex ${F}).pdf" \ "${D}/$(basename -s .tex ${F}).pdf"
"$(basename -s .tex ${F}).pdf"
popd
fi fi
done done
# Compile with BibTeX and cropping. # Compile with BibTeX and cropping.
# References to other files are interpreted relative to the
# root directory.
for F in ${D}/*_bib.tex; do for F in ${D}/*_bib.tex; do
if [ -f "${F}" ]; then if [ -f "${F}" ]; then
echo "###### Compiling and cropping ${F} ######" echo "###### Compiling and cropping ${F} ######"

View File

@ -6,9 +6,10 @@ On some operating systems, Python comes pre-installed, in which case entering th
If Python is yet to be installed, then you can find the installation files on the project website\footnote{Available at \url{https://www.python.org/downloads/}.}. If Python is yet to be installed, then you can find the installation files on the project website\footnote{Available at \url{https://www.python.org/downloads/}.}.
There are extensive articles that cover all relevant steps to install Python on There are extensive articles that cover all relevant steps to install Python on
Windows,\footnote{Pawandeep, How to install Python in Windows?. Tutorialspoint. March 10, 2021. Available at Windows,\footnote{Jason Fitzpatrick, How to Install Python on Windows. How-To
\url{https://www.tutorialspoint.com/how-to-install-python-in-windows}. Geek. July 11, 2017. Available at
Windows users will have to adjust the system path during the installation process. Forgetting this step has \url{https://www.howtogeek.com/197947/how-to-install-python-on-windows/}.
Windows users will have to adjust the system path. Forgetting this step has
been the number one installation problem in past workshops.} been the number one installation problem in past workshops.}
Linux,\footnote{\url{https://docs.python-guide.org/starting/install3/linux/}} Linux,\footnote{\url{https://docs.python-guide.org/starting/install3/linux/}}
or macOS.\footnote{\url{https://docs.python-guide.org/starting/install3/osx/}} or macOS.\footnote{\url{https://docs.python-guide.org/starting/install3/osx/}}
@ -53,43 +54,19 @@ Therefore, do not compile downloaded documents with the shell-escape flag if you
We are finally ready to marvel at the aesthetic quality of the listings \pkg{minted} produces. We are finally ready to marvel at the aesthetic quality of the listings \pkg{minted} produces.
You can define listings using a dedicated environment: You can define listings using a dedicated environment:
% Render listing directly, if minted is available. \example{lst:minted-environment}{source-code-listings/minted-environment}{Exemplary source code listing}
% Otherwise, include pre-rendered images.
\ifthenelse{\equal{\listingsmode}{minted}}{%
\example{lst:minted-environment}{source-code-listings/minted-environment}{Exemplary source code listing}
}{%
\Example{lst:minted-environment}{source-code-listings/minted-environment}{source-code-listings/minted-environment_crop}{Exemplary source code listing}
}
% Render listing directly, if minted is available. \example{lst:minted-variants}{source-code-listings/minted-variants}{Shorthand and inline listing}
% Otherwise, include pre-rendered images.
\ifthenelse{\equal{\listingsmode}{minted}}{%
\example{lst:minted-variants}{source-code-listings/minted-variants}{Shorthand and inline listing}
}{%
\Example{lst:minted-variants}{source-code-listings/minted-variants}{source-code-listings/minted-variants_crop}{Shorthand and inline listing}
}
\noindent There is also a shorthand and an inline variant of the command (cf.\ \cref{lst:minted-variants}). \noindent There is also a shorthand and an inline variant of the command (cf.\ \cref{lst:minted-variants}).
To avoid redundancy, it may be practical to import source code directly from the source file. To avoid redundancy, it may be practical to import source code directly from the source file.
To accomplish this, we only have to pass the programming language and the file path to the \code{latex}{\textbackslash inputminted} command (cf.\ \cref{lst:minted-external}). To accomplish this, we only have to pass the programming language and the file path to the \code{latex}{\textbackslash inputminted} command (cf.\ \cref{lst:minted-external}).
% Render listing directly, if minted is available. \example{lst:minted-external}{source-code-listings/minted-import}{Including from a separate file}
% Otherwise, include pre-rendered images.
\ifthenelse{\equal{\listingsmode}{minted}}{%
\example{lst:minted-external}{source-code-listings/minted-import}{Including from a separate file}
}{%
\Example{lst:minted-external}{source-code-listings/minted-import}{source-code-listings/minted-import_crop}{Including from a separate file}
}
\subsection{Configuring minted} \subsection{Configuring minted}
Optional parameters allow us to add line numbers, line breaks, and colors. Optional parameters allow us to add line numbers, line breaks, and colors.
Moreover, there are numerous themes available (\cref{lst:minted-external-styled}). Moreover, there are numerous themes available (\cref{lst:minted-external-styled}).
The introduction on Overleaf and the package documentation\footnote{Available at \url{https://www.overleaf.com/learn/latex/Code_Highlighting_with_minted} and \url{https://ctan.kako-dev.de/macros/latex/contrib/minted/minted.pdf}, respectively.} give an extensive overview. The introduction on Overleaf and the package documentation\footnote{Available at \url{https://www.overleaf.com/learn/latex/Code_Highlighting_with_minted} and \url{https://ctan.kako-dev.de/macros/latex/contrib/minted/minted.pdf}, respectively.} give an extensive overview.
% Render listing directly, if minted is available. \example{lst:minted-external-styled}{source-code-listings/minted-import-styled}{Themes and further options}
% Otherwise, include pre-rendered images.
\ifthenelse{\equal{\listingsmode}{minted}}{%
\example{lst:minted-external-styled}{source-code-listings/minted-import-styled}{Themes and further options}
}{%
\Example{lst:minted-external-styled}{source-code-listings/minted-import-styled}{source-code-listings/minted-import-styled_crop}{Themes and further options}
}

View File

@ -13,3 +13,5 @@ There are very helpful resources\footnote{If you would like to specify your own
\input{./content/source-code-listings-minted} \input{./content/source-code-listings-minted}
\input{./content/source-code-listings-listings} \input{./content/source-code-listings-listings}
\todo{Are the files minted.done.tex and listings.done.tex available in the solution-free zip? They should not.}

View File

@ -30,8 +30,4 @@ If you have questions, consult the \pkg{minted} or \pkg{listings} package docume
\end{enumerate} \end{enumerate}
\exercisematerial{exercises/source-code-listings/source-code-listings} \exercisematerial{exercises/source-code-listings/source-code-listings}
\usemintedstyle{} % Reset experiments from exercise material
% Reset experiments from exercise material if minted is used
\ifthenelse{\equal{\listingsmode}{minted}}{%
\usemintedstyle{}
}{}

View File

@ -1,13 +0,0 @@
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{minted}
\begin{document}
\thispagestyle{empty}
\begin{minted}{haskell}
[x^2 | x <- [1..200], even x]
\end{minted}
\end{document}

View File

@ -1,15 +0,0 @@
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{minted}
\begin{document}
\thispagestyle{empty}
\usemintedstyle{monokai}
\definecolor{bg}{rgb}{0.1,0.1,0.2}
\inputminted[
breaklines=true,
bgcolor=bg
]{java}{Test.java}
\end{document}

View File

@ -1 +1,3 @@
\inputminted{java}{listings/source-code-listings/Test.java} \inputminted{java}
{listings/source-code-listings/Test.java}

View File

@ -1,10 +0,0 @@
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{minted}
\begin{document}
\thispagestyle{empty}
\inputminted{java}{Test.java}
\end{document}

View File

@ -1,14 +0,0 @@
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{minted}
\begin{document}
\thispagestyle{empty}
% Shorthand
Despite it is a shorthand, \mint{html}|<h2>LaTeX im Studium</h2>| will be rendered on its own line.
% Inline variant
The method call \mintinline{java}{o.doSomething();} on the other hand will appear inline.
\end{document}

View File

@ -1,7 +1,6 @@
\input{setup.tex} % Setup \input{setup.tex} % Setup
\input{praeamble.tex} % Preamble \input{praeamble.tex} % Preamble
\input{commands.tex} % Custom commands \input{commands.tex} % Custom commands
\title{Script for the Fachschaft \acro{WIAI} \LaTeX{} Workshop} \title{Script for the Fachschaft \acro{WIAI} \LaTeX{} Workshop}
\author{Evelyn Fradtschuk \and Florian Knoch \and Christian Kremitzl \and Bernhard Luedtke} \author{Evelyn Fradtschuk \and Florian Knoch \and Christian Kremitzl \and Bernhard Luedtke}

View File

@ -36,7 +36,7 @@
\usepackage{todonotes} \usepackage{todonotes}
\usepackage{changes} \usepackage{changes}
% Source code listings % Sourcecode listings
\usepackage{listings} \usepackage{listings}
\ifthenelse{\equal{\listingsmode}{minted}}{\usepackage{minted}}{} \ifthenelse{\equal{\listingsmode}{minted}}{\usepackage{minted}}{}

View File

@ -3,10 +3,10 @@
% The listings mode can be chosen by writing one of the following to the % The listings mode can be chosen by writing one of the following to the
%listings-mode.tex file before compilation: %listings-mode.tex file before compilation:
% \newcommand\listingsmode{default} % to use lstlistings % \newcommand\listingsmode{default} % to use lstlistings
% \newcommand\listingsmode{minted} % to use minted % \newcommand\listingsmode{minted} % for a script with exercises only
% The following lines include that file or make \listingsmode default to % The following lines include that file or make \listingsmode default to
% 'default' so that any derivatives of this project will work even without the %'default' so that any derivatives of this project will work even without the
% file. %file.
\IfFileExists{listings-mode.tex}{ \IfFileExists{listings-mode.tex}{
\input{listings-mode.tex} \input{listings-mode.tex}
}{ }{