Skip to content

Commit

Permalink
Adding command to insert pdf easily.
Browse files Browse the repository at this point in the history
  • Loading branch information
Clément committed Dec 23, 2024
1 parent f1a3fc3 commit 421991c
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 9 deletions.
28 changes: 23 additions & 5 deletions md_version/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,35 @@ You can easily represent formal proofs using \LaTeX's ebproof or bussproof packa
\end{prooftree}
\end{center}

# Figures, Tables, (Code) Listings and Landscape Pages
# Inserting PDFs, Figures, Tables and (Code) Listings

## Figures
## Inserting PDFs

PDF documents can be inserted using `pdfpages`'s `\includepdf` command.
For commodity, a `\modifiedincludepdf` is provided:

```tex
\modifiedincludepdf{options for includepdf}%
{label}%
{full path to the document}%
{title of the document}%
{"level" (e.g., section, subsection, etc.)}
```

Note that using `label.x` will refer to the page `x` of the inserted document (starting with 1): refer to the source code of this current document for an example usage.
We insert [in the following pages](#pdf:Gluck13) (p. \pageref{pdf:Gluck13.1}--\pageref{pdf:Gluck13.9}) an article as an example of PDF insertion.

\modifiedincludepdf{}{pdf:Gluck13}{pdf/simulation_of_two_ways_pushdown_automata_revisited.pdf}{A paper proving concisely a result in automata theory that helped solve a real programming problem~\cite{DBLP:journals/corr/Gluck13}}{subsection}

## Inserting Figures

Markdown only
~ You can easily insert [images and figures](https://pandoc.org/MANUAL.html#images) using Pandoc, as in \autoref{fig:d_un_autre_age}, a painting by [Jérôme Minard](http://jeromeminard.com/travaux/) under [copyleft](https://forceg.jimdofree.com/licence-art-libre/).

![_D'un autre âge_\label{fig:d_un_autre_age}](pictures/D_un_autre_age.jpg){width=80%}


## Tables
## Inserting Tables

Markdown only
~ You can write tables using [pandoc's syntax*es*](https://pandoc.org/MANUAL.html#tables), as in Tables \ref{tbl:demo1}, \ref{tbl:demo2} and \ref{tbl:demo3} (all borrowed from <https://www.flutterbys.com.au/stats/tut/tut17.3.html>).
Expand Down Expand Up @@ -241,7 +259,7 @@ Markdown only
+---------------+---------------+--------------------+
: The price and advantages of fruits \label{tbl:demo3}

## Code Listings
## Inserting Code Listings

Code is displayed using the listings package.
Check the "Table 1: Predefined languages" of the listings package documentation to see the list of supported languages by default.
Expand Down Expand Up @@ -278,7 +296,7 @@ for num in {000..2}; do echo "$num"; done
\lstinputlisting[language=C, caption={"\emph{Hello World}" in C}, label={lst:demo3}]{code/hello_world.c}


## Landscape Pages
# Landscape Pages

You can obtain landscape pages using the landscape package in \LaTeX.

Expand Down
Binary file modified md_version/main.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion md_version/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ clean:
tex: main.md
@pandoc $(PANDOC_OPTIONS) -s $< -o main.tex
@mkdir -p ../tex_version/
@cp -r main.tex fonts/ references/ pictures/ code/ ../tex_version/
@cp -r main.tex fonts/ references/ pictures/ pdf/ code/ ../tex_version/
@echo "Your .tex version is available at ../tex_version/. Compile with latexmk -pdf -xelatex main.tex"

Binary file not shown.
21 changes: 21 additions & 0 deletions md_version/references/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,24 @@ @online{gradschool_policies
url = {https://www.augusta.edu/gradschool/student-resources.php},
urldate = {2021-11-01}
}
@inproceedings{DBLP:journals/corr/Gluck13,
author = {Robert Gl{\"{u}}ck},
editor = {Anindya Banerjee and
Olivier Danvy and
Kyung{-}Goo Doh and
John Hatcliff},
title = {Simulation of Two-Way Pushdown Automata Revisited},
booktitle = {Semantics, Abstract Interpretation, and Reasoning about Programs:
Essays Dedicated to David A. Schmidt on the Occasion of his Sixtieth
Birthday, Manhattan, Kansas, USA, 19-20th September 2013},
series = {{EPTCS}},
volume = {129},
pages = {250--258},
year = {2013},
url = {https://doi.org/10.4204/EPTCS.129.15},
doi = {10.4204/EPTCS.129.15},
timestamp = {Sun, 02 Jun 2019 20:54:28 +0200},
biburl = {https://dblp.org/rec/journals/corr/Gluck13.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}

66 changes: 63 additions & 3 deletions md_version/templates/head_c.tex
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
\normalsize
}

%%%%%
% Emoji support for latex
%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Emoji support for latex %
%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[verbose]{newunicodechar}

Expand Down Expand Up @@ -297,3 +297,63 @@
% We recommend using the more modern ebproof over
% the more "traditional" bussproofs,
\usepackage{ebproof}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Nice frames, for the documents we will be including %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[breakable]{tcolorbox} % Will be used for frame around included documents.
% https://tex.stackexchange.com/a/66156
\DeclareRobustCommand\titleforcurrentframe{temp} % Title for the current page of the frame.
% This macro is re-defined in \modifiedincludepdf
% and \modifiedincludetxt
\newcommand{\mybox}[1]{%
\begin{tcolorbox}[
colframe=augustablue,
colback=white,
width={\dimexpr\textwidth},
breakable,
adjusted title={\hypersetup{citecolor=white}\titleforcurrentframe}
]
#1
\end{tcolorbox}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Commands to include pdf %
%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{pdfpages}
% https://tex.stackexchange.com/questions/198091/get-number-of-pages-of-external-pdf/198095#198095
\newcommand*{\numberofpages}[1]{%
\the\XeTeXpdfpagecount"#1" %
}

% Counter to add label to individual pages of the pdf.
% https://tex.stackexchange.com/a/25113
\newcounter{currentpagecounter}
\newcounter{totaldocpages}
% Command to include pdf document.
% Usage:
% \modifiedincludepdf{options for includepdf}{label}{full path to the document}{title of the document}{"level" (e.g., section, subsection, etc.)}
\newcommand{\modifiedincludepdf}[6]{
\let\fbox\mybox % includepsf, with the option "frame", use \fbox
% to draw the frame. We change the command, to use
% our custom frame, that uses tcolorbox.
\setcounter{currentpagecounter}{0}
\setcounter{totaldocpages}{\numberofpages{#3}}
\renewcommand{\titleforcurrentframe}{#4 (p.\ \thecurrentpagecounter\ / \thetotaldocpages) \hfill #6} % #6 acts as a subtitle
\includepdf[#1,%
width=\textwidth,%
pages=-,%
frame,
clip,
pagecommand={
\stepcounter{currentpagecounter} % We increment the counter for the number of pages.
\label{#2.\thecurrentpagecounter}% We add a label of the form "label.pagenumber".
},
link = true,
linkname = {#2},
addtotoc={1, #5, 1, #4, #2} % We add an entry to the table of content.
]{#3}
}
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Please, refer to the [Thesis/PhD Dissertation Preparation Booklet](https://www.a
- This template uses and redistributes the [TeX Gyre Termes](http://www.gust.org.pl/projects/e-foundry/tex-gyre/termes) font (version 2.004), placed under the [GUST Font License](https://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt), which is an extension of the [The LaTeX Project Public License](https://www.latex-project.org/lppl.txt).
- This template uses and redistributes the [Symbola](http://web.archive.org/web/20180307012615/http://users.teilar.gr/~g1951d/Symbola.zip) font (version 10.24), which is "free for any use".
- The file code/hello_world.c is courtesy of Brian Kernighan.
- The file pdf/simulation_of_two_ways_pushdown_automata_revisited.pdf is courtesy of Robert Glück and under Creative Commons Attribution License.
- The file pictures/D_un_autre_age.jpg is courtesy of [Jérôme Minard](http://jeromeminard.com/travaux/) and under [copyleft](https://forceg.jimdofree.com/licence-art-libre/).
- Unless otherwise noted, this template is under [Creative Commons Attribution 4.0 International](LICENSE.md).
- © [Our contributors](https://github.com/the-au-forml-lab/au_ccs_dissertation_template/graphs/contributors), 2021-2025

0 comments on commit 421991c

Please sign in to comment.