-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tex
314 lines (259 loc) · 10.8 KB
/
main.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Structured General Purpose Assignment
% LaTeX Template
%
% This template has been downloaded from:
% http://www.latextemplates.com
%
% Original author:
% Ted Pavlic (http://www.tedpavlic.com)
% Modified by:
% Joe Del Rocco (https://joe.delrocco.org)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------------------------------------------------------------------------------------
% PACKAGES AND CONFIGURATION
%----------------------------------------------------------------------------------------
\documentclass[fleqn]{article}
\usepackage{xargs}
\usepackage{geometry}
\usepackage{fancyhdr} % For custom headers
\usepackage{lastpage} % To determine the last page for the footer
\usepackage{extramarks} % For headers and footers
\usepackage[most]{tcolorbox} % For problem answer sections
\usepackage{graphicx} % For inserting images
\usepackage{xcolor} % For link coloring
\usepackage[hidelinks]{hyperref} % For URL links (no box or color name)
\usepackage[permil]{overpic}
\usepackage{pict2e} % for drawing polygons
\usepackage{listings}
% Margins
\geometry{
a4paper,
tmargin=1in,
bmargin=1in,
lmargin=1in,
rmargin=1in,
textwidth=6.5in,
textheight=9.0in,
headsep=0.25in
}
% Header and footer
\pagestyle{fancy}
\lhead{\myName} % Top left header
\chead{\myAssignment} % Top center header
\rhead{\firstxmark} % Top right header
\lfoot{\lastxmark} % Bottom left footer
\cfoot{} % Bottom center footer
\rfoot{Page\ \thepage\ of\ \pageref{LastPage}} % Bottom right footer
\renewcommand\headrulewidth{0.4pt} % Size of the header rule
\renewcommand\footrulewidth{0.4pt} % Size of the footer rule
% Other configurations
\setlength\parindent{0pt} % Removes all indentation from paragraphs
\setlength\parskip{1pt} % Ensures paragraphs are still recognizable as such
\setcounter{secnumdepth}{0} % Removes default section numbers
\setcounter{tocdepth}{3} % Sets depth of table of contents
\linespread{1.1}
% Code highlight
\definecolor{light-gray}{gray}{0.9}
\newcommand{\code}[1] {\colorbox{light-gray}{\texttt{#1}}}
% Template values
\newcommand{\myLogo}{img/starfleet.jpg}
\newcommand{\myName}{Jean-Luc Picard}
\newcommand{\myJobTitle}{Cadet, First Class}
\newcommand{\myCompany}{Starfleet Academy}
\newcommand{\myLocation}{1701 Lincoln Blvd, San Francisco}
\newcommand{\myURL}{www.starfleet.edu}
\newcommand{\myEmail}{jpicard@student.starfleet.edu}
\newcommand{\myCourse}{COT\ 6410}
\newcommand{\mySection}{Spring 2325}
\newcommand{\myTeacher}{Dr. Vassbinder}
\newcommand{\myAssignment}{Using \LaTeX{} Package \code{overpic}}
\newcommand{\myDueDate}{Thursday,\ February\ 26,\ 2325}
%----------------------------------------------------------------------------------------
% DOCUMENT STRUCTURE (MACROS & ENVIRONMENTS)
%----------------------------------------------------------------------------------------
% Colored links macro
\newcommand{\hrefcol}[3] {\href{#1}{\textcolor{#3}{#2}}}
% Creates a counter to keep track of the number of problems
\newcounter{homeworkProblemCounter}
% Macro for custom title page signature header
\newsavebox{\myTitleSignature}
\sbox{\myTitleSignature}{%
\begin{tabular*}{\textwidth}{@{}l@{}|@{\extracolsep{0.125in}}l@{}}%
\parbox{4.25in}{\raggedright{\includegraphics{\myLogo}}} &
\parbox[c][]{2.25in}{{\textbf{\myName} \par}
{\small \myJobTitle \par}
{\small \myCompany \par}
{\small \myLocation \par}
{\small \hrefcol{https://\myURL}{\myURL}{blue} \par}
{\small \hrefcol{mailto:\myEmail}{\myEmail}{blue}} \par}
\end{tabular*}}
% Header and footer for when a page split occurs within a problem environment
\newcommand{\enterProblemHeader}[1]{%
\nobreak%\extramarks{#1}{#1 continued on next page\ldots}\nobreak%
\nobreak%\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak%
}
% Header and footer for when a page split occurs between problem environments
\newcommand{\exitProblemHeader}[1]{%
\nobreak%\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak%
\nobreak%\extramarks{#1}{}\nobreak%
}
\newcommand{\homeworkProblemName}{} % Argument = name of problem; default = "Problem #"
\newenvironment{homeworkProblem}[1][Problem \arabic{homeworkProblemCounter}]{%
\stepcounter{homeworkProblemCounter}% % Increase counter for number of problems
\renewcommand{\homeworkProblemName}{#1}% % Assign \homeworkProblemName the argument
\section{\homeworkProblemName}% % Make a section in the document with the custom problem count
\enterProblemHeader{\homeworkProblemName}% % Header and footer within environment
}{%
\exitProblemHeader{\homeworkProblemName}% % Header and footer after environment
}
\newcommandx{\problemAnswer}[2][1=Answer]{%
%\newcommand{\problemAnswer}[2][#1,Answer]{% % Defines the problem answer command
\begin{tcolorbox}[breakable,enhanced,colback=gray!5!white,title=#1]%
#2
\end{tcolorbox}%
% Alternative - Makes the box around the problem answer and puts the content inside
%\noindent\framebox[\columnwidth][c]{\begin{minipage}{0.98\columnwidth}#1\end{minipage}}
}
\newcommand{\homeworkSectionName}{}
\newenvironment{homeworkSection}[1]{% % For sections w/in problems; Argument = name of section (no default)
\renewcommand{\homeworkSectionName}{#1}% % Assign \homeworkSectionName the argument
\subsection{\homeworkSectionName}% % Make a subsection with the name of the subsection
\enterProblemHeader{\homeworkProblemName\ [\homeworkSectionName]}% % Header and footer within environment
}{%
\enterProblemHeader{\homeworkProblemName}% % Header and footer after environment
}
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
\begin{document}
% Blank out the traditional title page
\title{\vspace{-1in}} % no title name
\author{} % no author name
\date{} % no date listed
\maketitle % makes this a title page
% Use custom title macro instead
\usebox{\myTitleSignature}
\vspace{1in} % spacing below title header
% Assignment title
{\centering \huge \myAssignment \par}
{\centering \noindent\rule{4in}{0.1pt} \par}
\vspace{0.05in}
{\centering \myDueDate \par}
\vspace{1in}
% Table of Contents
\tableofcontents
\vspace{0.5in}
\begin{homeworkProblem}[Where's the code?]
Instead of textualizing the \LaTeX~in this document, as was done originally (and which was difficult to copy and paste), it is recommended that you just inspect the code directly. If you found this template on \hrefcol{https://www.overleaf.com}{Overleaf}{blue}, you can see the code already in the editor. If you happened upon this example as a document, the \hrefcol{https://github.com/delrocco/overpic-example}{code is in this repository}{blue}. Please feel free to steal anything that helps you :).
\vspace{0.1in}
%\problemAnswer[Code]{Just view the \LaTeX~code in the repository.}
\end{homeworkProblem}
\newpage
%----------------------------------------------------------------------------------------
\begin{homeworkProblem}[How do I overlay text onto an image?]
\problemAnswer[Result]{
\frame{
\begin{overpic}[width=0.5\textwidth]{img/salmon.jpg}%
\put(20,600) {Salmon sashimi with sesame seeds and lemon}%
\put(750,350){lemon}%
\put(300,500){seeds}%
\put(200,150){salmon}%
\put(550,50){Looks yummy, right?}%
\end{overpic}
}
}
\end{homeworkProblem}
%----------------------------------------------------------------------------------------
\begin{homeworkProblem}[How do I superimpose a grid for easy alignment?]
\problemAnswer[Result]{
\vspace{0.1in}
\hspace{0.1in}
\begin{overpic}[width=0.5\textwidth,grid]{img/salmon.jpg}%
\put(750,350){lemon}%
\end{overpic}
}
\end{homeworkProblem}
%----------------------------------------------------------------------------------------
\begin{homeworkProblem}[How do I draw cirles, lines and polygons over an image?]
\problemAnswer[Result]{
\frame{
\begin{overpic}[width=0.5\textwidth]{img/salmon.jpg}%
\put(800,380){\color{blue}lemon}%
\put(700,300){\color{blue}\circle{200}}%
\put(100,600){seeds}%
\put(150,585){\linethickness{0.25mm}\color{black}\line(1,-1){285}}%
\put(10,230){salmon}%
\multiput(180,240)(50,0){4}{\linethickness{0.5mm}\line(1,0){30}}%
\put(450,600){kaiware daikon sprouts}%
\put(450,450){\linethickness{0.25mm}\color{black}\polygon(0,0)(290,0)(290,120)(0,120)}%
\put(280,55){\circle*{10}}%
\put(280,55){\circle{20}}%
\put(300,40){Looks yummy, right?}%
\end{overpic}
}
}
\end{homeworkProblem}
%----------------------------------------------------------------------------------------
\begin{homeworkProblem}[How do I superimpose images over an image?]
\problemAnswer[Result]{
\begin{overpic}[width=0.5\textwidth]{img/salmon.jpg}%
\put(500,300){\includegraphics[width=0.3\textwidth]{img/chopsticks.png}}%
\end{overpic}
%\vspace{0.25in}
}
\end{homeworkProblem}
%----------------------------------------------------------------------------------------
\begin{homeworkProblem}[How do I use this to compare multiple images in a figure?]
\problemAnswer[Result]{
\frame{\begin{overpic}[width=0.3\textwidth]{img/salmon.jpg}%
\put(20,590){(A)}%
\end{overpic}}%
~%
\frame{\begin{overpic}[width=0.3\textwidth]{img/salmon.jpg}%
\put(20,590){(B)}%
\end{overpic}}%
}
\problemAnswer[Result]{
\frame{\begin{overpic}[width=0.215\textwidth]{img/salmon.jpg}%
\put(20,550){(a)}%
\end{overpic}}%
~%
\frame{\begin{overpic}[width=0.215\textwidth]{img/salmon.jpg}%
\put(20,550){(b)}%
\end{overpic}}%
~%
\frame{\begin{overpic}[width=0.215\textwidth]{img/salmon.jpg}%
\put(20,550){(c)}%
\end{overpic}}%
~%
\frame{\begin{overpic}[width=0.215\textwidth]{img/salmon.jpg}%
\put(20,550){(d)}%
\end{overpic}}%
}
\problemAnswer[Result]{
\frame{\begin{overpic}[width=0.6\textwidth]{img/salmon.jpg}%
\put(650,10){\frame{\includegraphics[width=0.2\textwidth]{img/salmon.jpg}}}%
\put(10,620){(1)}%
\put(660,190){(2)}%
\end{overpic}}%
}
\end{homeworkProblem}
%----------------------------------------------------------------------------------------
\newpage
\begin{homeworkProblem}[What else can I do with overpic?]
\problemAnswer{
Here is another 1-page primer by Rolf Niepraschk to get you started:\\
\hrefcol{http://www.ctex.org/documents/packages/graphics/opic-rel.pdf}{http://www.ctex.org/documents/packages/graphics/opic-rel.pdf}{blue}\\
\\
Here is the official documentation on CTAN:\\
\hrefcol{http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/overpic/overpic.pdf}{http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/overpic/overpic.pdf}{blue}\\
\\
Here is a relevant thread on the TeX StackExchange:\\
\hrefcol{https://tex.stackexchange.com/questions/20792/how-to-superimpose-latex-on-a-picture}{https://tex.stackexchange.com/questions/20792/how-to-superimpose-latex-on-a-picture}{blue}\\
\\
You can also use TikZ, but it is more complicated:\\
\hrefcol{https://tex.stackexchange.com/questions/9559/drawing-on-an-image-with-tikz}{https://tex.stackexchange.com/questions/9559/drawing-on-an-image-with-tikz}{blue}\\
}
\end{homeworkProblem}
\end{document}