Skip to content

Commit f7f224d

Browse files
committed
fix: nu fungerar både footnote och ref
1 parent 1bde7df commit f7f224d

File tree

2 files changed

+67
-42
lines changed

2 files changed

+67
-42
lines changed

lectures/latex/latex.tex

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ \section{Slutsatser}
369369

370370
\ti{Fotnoter är lätta att skriva:}
371371

372-
\begin{exlatex}
372+
\begin{exlatexhide}
373373
Om man använder \LaTeX
374374
\footnote{uttalas
375375
``lah-tekh''} så
@@ -378,7 +378,7 @@ \section{Slutsatser}
378378
% snyggt
379379
professionellt
380380
utformade.
381-
\end{exlatex}
381+
\end{exlatexhide}
382382

383383
\blankline
384384
\begin{itemize}
@@ -506,7 +506,7 @@ \section{Slutsatser}
506506
507507
\begin{exlatex}
508508
\begin{table}[t]
509-
\begin{tabular}{lcr}
509+
\begin{tabular}{|l|c|r|}
510510
Produkt & Typ & Pris \\
511511
\hline
512512
Skruvar & stora & 0.18~kr \\
@@ -638,8 +638,9 @@ \section{Slutsatser}
638638
639639
\blankline
640640
\begin{itemize}
641-
\ii{I löpande text: \code{\$ \dots\ \$}}
642-
\ii{På egen rad: \texttt{\textbackslash begin\{displaymath\} \dots\ \textbackslash end\{displaymath\}}}
641+
\ii{I löpande text: \code{\$ \dots\ \$} eller \code{\textbackslash( \dots\ \textbackslash)} (mer robust i vissa sammanhang.)}
642+
\ii{På egen rad: \texttt{\textbackslash begin\{displaymath\} \dots\ \textbackslash end\{displaymath\}}\\
643+
eller \code{\textbackslash [ \dots\ \textbackslash ]} }
643644
\ii{Numrerad formel: \code{\textbackslash begin\{equation\} \dots\ \textbackslash end\{equation\}}}
644645
\ii{Etikett och referens: \code{\textbackslash label} och \code{\textbackslash ref}}
645646
\end{itemize}
@@ -652,13 +653,15 @@ \section{Slutsatser}
652653
\vspace{2em}
653654
654655
\begin{exlatex}
655-
Formeln $x=3y-2$ står inne i texten. Däremot står
656+
Formeln \(x=3y-2\) står inne i texten. Däremot står
656657
\begin{displaymath}
657-
x=3y-2
658+
x_1 = 3y - 2
658659
\end{displaymath}
659-
för sig själv precis som
660+
för sig själv, precis som
661+
\[x_2 = -0.6e^{2-y} + \frac{9.3}{\pi}\]
662+
och detta är en numrerad ekvation:
660663
\begin{equation}
661-
x=3y-2
664+
x_3 = 2y^2 + 7y - 2a + 3
662665
\label{xochy}
663666
\end{equation}
664667
@@ -680,11 +683,11 @@ \section{Slutsatser}
680683
\vspace{1cm}
681684
682685
\begin{exlatex}
683-
\begin{displaymath}
686+
\[
684687
x_{k+1} =
685688
x_{k} -
686689
\frac{f(x_{k})}{f'(x_{k})}
687-
\end{displaymath}
690+
\]
688691
\end{exlatex}
689692
\end{frame}
690693
@@ -693,18 +696,18 @@ \section{Slutsatser}
693696
\vspace{2em}
694697
695698
\begin{exlatex}
696-
\begin{displaymath}
699+
\[
697700
e^x = 1+x+x^2/2!+x^3/3!+\cdots
698-
\end{displaymath}
701+
\]
699702
\end{exlatex}
700703
701704
\vspace{1cm}
702705
703706
\begin{exlatex}
704-
\begin{displaymath}
707+
\[
705708
x_{1,2}=\frac{p}{2}\pm
706709
\sqrt{\frac{p^2}{4}-q}
707-
\end{displaymath}
710+
\]
708711
\end{exlatex}
709712
710713
\end{frame}
@@ -716,18 +719,18 @@ \section{Slutsatser}
716719
\vspace{2em}
717720
718721
\begin{exlatex}
719-
\begin{displaymath}
722+
\[
720723
\int_{-\infty}^{\infty}
721724
e^{-x^2} dx
722-
\end{displaymath}
725+
\]
723726
\end{exlatex}
724727
725728
\vspace{1cm}
726729
727730
\begin{exlatex}
728-
\begin{displaymath}
731+
\[
729732
\sum_{k=1}^n\frac{1}{a_k}
730-
\end{displaymath}
733+
\]
731734
\end{exlatex}
732735
733736
\end{frame}
@@ -737,9 +740,9 @@ \section{Slutsatser}
737740
\vspace{2em}
738741
739742
\begin{exlatex}
740-
\begin{displaymath}
743+
\[
741744
\sin^2 x + \cos^2 x = 1
742-
\end{displaymath}
745+
\]
743746
\end{exlatex}
744747
\end{frame}
745748
@@ -748,7 +751,7 @@ \section{Slutsatser}
748751
\vspace{2em}
749752
750753
\begin{exlatex}
751-
\begin{displaymath}
754+
\[
752755
A=\left(
753756
\begin{array}{cccc}
754757
a_{11} & a_{12} & \cdots & a_{1n} \\
@@ -757,7 +760,7 @@ \section{Slutsatser}
757760
a_{n1} & a_{n2} & \cdots & a_{nn} \\
758761
\end{array}
759762
\right)
760-
\end{displaymath}
763+
\]
761764
\end{exlatex}
762765
\end{frame}
763766
@@ -803,25 +806,6 @@ \section{Slutsatser}
803806
\end{figure}
804807
Från text kan vi nu referera till figur~\ref{fig:exempelbild}.
805808
\end{exlatex}
806-
% \begin{exsrc}
807-
% \begin{figure}
808-
% \centering
809-
% \includegraphics[height=40mm]
810-
% {images/bild.pdf}
811-
% \caption{Exempelbild}
812-
% \label{fig:exempelbild}
813-
% \end{figure}
814-
% Från text kan vi nu referera till figur~\ref{fig:exempelbild}.
815-
% \end{exsrc}
816-
% \begin{exresult}
817-
% \begin{figure}
818-
% \centering
819-
% \includegraphics[height=30mm]{images/enkelmodell.pdf}
820-
% \caption{Exempelbild}
821-
% \label{fig:exempelbild2}
822-
% \end{figure}
823-
% Från text kan vi nu referera till figur~\ref{fig:exempelbild2}.
824-
% \end{exresult}
825809
826810
\end{frame}
827811

lectures/latex/latex_utils.sty

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,47 @@
9999

100100

101101
\newenvironment{exlatex}{%
102+
\only<1>{
103+
\stepcounter{exlatexctr}% Stega upp räknaren
104+
}
105+
\VerbatimEnvironment
106+
\begin{VerbatimOut}{ex/ex.\theexlatexctr}%
107+
}{%
108+
\end{VerbatimOut}
109+
\noindent
110+
\begin{minipage}[t]{.48\textwidth}%
111+
\ti{{\tiny\textbf\texttt\sc KÄLLKOD:}}
112+
113+
\vspace{1mm}
114+
\only<.->{
115+
\lstinputlisting[style=latexex]{ex/ex.\theexlatexctr}% Rå LaTeX-kod
116+
}
117+
\end{minipage}%
118+
\hfill
119+
\only<.->{%
120+
\vrule
121+
}
122+
\hfill
123+
\begin{minipage}[t]{.48\textwidth}%
124+
% Ändra fotnotssymboler till siffror i detta minipage
125+
\makeatletter
126+
\renewcommand{\thempfootnote}{\arabic{mpfootnote}}
127+
\makeatother
128+
129+
\ts{{\tiny\textbf\texttt\sc RESULTAT:}}
130+
131+
\vspace{1mm}
132+
\uncover<+->{
133+
{\footnotesize\input{ex/ex.\theexlatexctr}} % Kompilerad LaTeX-kod
134+
}
135+
136+
\end{minipage}%
137+
}
138+
139+
% Hack: \only ovan fungerar för footnote men inte för referenser
140+
% Detta är en kopia som istället använder \uncover, vilket fungerar för
141+
% referenser men inte för footnote
142+
\newenvironment{exlatexhide}{%
102143
\only<1>{
103144
\stepcounter{exlatexctr}% Stega upp räknaren
104145
}

0 commit comments

Comments
 (0)