Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasHoelsch committed Jul 15, 2024
2 parents ea159ef + 3f0cab1 commit 822e696
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 6 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/BuildPDFs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Build LaTeX document
name: Build LaTeX PDFs
on:
push:
paths:
- '**.tex'
workflow_dispatch:

jobs:
Expand All @@ -14,13 +16,17 @@ jobs:
with:
scheme: full
run: |
cd exercise
python3 build.py
cd ..
cd lecture
python3 build.py
- name: Upload PDF file
uses: actions/upload-pages-artifact@v3 #actions/upload-artifact@v4
with:
name: github-pages
path: lecture/built/
path: built/


deploy:
needs: build_latex
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Fundamentals of electrical machines and drives course

[![Build Status](https://github.com/IAS-Uni-Siegen/EMD_Course/actions/workflows/BuildPDFs.yml/badge.svg)](https://github.com/IAS-Uni-Siegen/EMD_Course/actions/workflows/BuildPDFs.yml)
[![CC BY 4.0][cc-by-shield]][cc-by]
[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)
[![made-with-latex](https://img.shields.io/badge/Made%20with-LaTeX-1f425f.svg)](https://www.latex-project.org/)

This work is licensed under a
[Creative Commons Attribution-ShareAlike 4.0 International License][cc-by].
Expand All @@ -12,4 +15,16 @@ This work is licensed under a
[cc-by-shield]: https://img.shields.io/badge/License-CC%20BY%204.0-lightgrey.svg

## Lecture slides (click on preview picture)
<a href="https://ias-uni-siegen.github.io/EMD_Course/main.pdf" class="image fit"><img src="misc/Slide_preview.png" alt=""></a>
<a href="https://ias-uni-siegen.github.io/EMD_Course/lecture.pdf" target="_blank" class="image fit"><img src="misc/Slide_preview.png" alt=""></a>

The covered topics are:
- An initial overview of electrical machines and drives
- Fundamental electromagnetic principles and magnetic materials
- DC machines
- Transformers
- Rotating field theory
- Induction machine
- Synchronous machine

## Exercise tasks (click on preview picture)
<a href="https://ias-uni-siegen.github.io/EMD_Course/exercise.pdf" target="_blank" class="image fit"><img src="misc/Exercise_preview.png" alt=""></a>
42 changes: 42 additions & 0 deletions exercise/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import fileinput
from subprocess import call

#os.makedirs('built', exist_ok=True)
call_pdflatex_l = ['pdflatex', '-synctex=1',
'-interaction=nonstopmode', 'main.tex']


def clear_tex_binaries():
# clean misc files
for file in os.listdir('.'):
if file.startswith('main'):
if not file.endswith(('.tex', '.pdf')):
os.remove(file)


# build main pdf
clear_tex_binaries()
with fileinput.input('main.tex', inplace=True) as f:
for line in f:
if 'includeonly{' in line:
# comment out includeonly flag
print(f'%{line}', end='')
#check if the line including '\documentclass' has the parameter 'solution' - if not add it
elif '{exerciseClass}' in line:
if 'solution' not in line:
print(line.replace('{exerciseClass}', ', [solution]{exerciseClass}'), end='')
else:
print(line, end='')
else:
print(line, end='')

call(call_pdflatex_l)
call(call_pdflatex_l)
#os.replace('main.pdf', os.path.join('built', 'exercise.pdf'))

# go into the parent directory
os.chdir('..')
os.makedirs('built', exist_ok=True)
#take main.pdf from the exercise folder and move it to the parent folder
os.replace('exercise/main.pdf', os.path.join('built', 'exercise.pdf'))
2 changes: 1 addition & 1 deletion exercise/main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%Lecture Include Only%%%
\includeonly{tex/exercise06}
%\includeonly{tex/exercise05}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
Expand Down
17 changes: 16 additions & 1 deletion lecture/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,23 @@ def clear_tex_binaries():
if 'includeonly{' in line:
# comment out includeonly flag
print(f'%{line}', end='')
#check if the line including '\documentclass' has the parameter 'handout' - if not add it
elif ']{beamer}' in line:
if 'handout' not in line:
print(line.replace(']{beamer}', ', handout]{beamer}'), end='')
else:
print(line, end='')
else:
print(line, end='')

call(call_pdflatex_l)
call(call_pdflatex_l)
os.replace('main.pdf', os.path.join('built', 'main.pdf'))
#os.replace('main.pdf', os.path.join('built', 'lecture.pdf'))

#os.replace('main.pdf', os.path.join('built', 'exercise.pdf'))

# go into the parent directory
os.chdir('..')
os.makedirs('built', exist_ok=True)
#take main.pdf from the exercise folder and move it to the parent folder
os.replace('lecture/main.pdf', os.path.join('built', 'lecture.pdf'))
2 changes: 1 addition & 1 deletion lecture/main.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%% Very basic document style settings %%%%%%%%%
\documentclass[aspectratio=169, usepdftitle=false, handout]{beamer}
\documentclass[aspectratio=169, usepdftitle=false]{beamer}
\usetheme{Madrid}
\usefonttheme{professionalfonts}
\setbeamertemplate{itemize items}[triangle]
Expand Down
Binary file added misc/Exercise_preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 822e696

Please sign in to comment.