소스 검색

Added more papers and PoCs

master
Ludovic 'Archivist' Lagouardette 4 년 전
부모
커밋
75bdbceb5c
27개의 변경된 파일2400개의 추가작업 그리고 3개의 파일을 삭제
  1. +21
    -0
      .gitignore
  2. +3
    -0
      Makefile
  3. +7
    -0
      include/database.hpp
  4. +35
    -3
      include/network.hpp
  5. +56
    -0
      src/izaro-coordinate.cpp
  6. +50
    -0
      src/test_spam_version.cpp
  7. +113
    -0
      tests/time-client.cpp
  8. +45
    -0
      tests/time-server.cpp
  9. BIN
      whitepaper/Pictures/Mockups.epgz
  10. BIN
      whitepaper/Pictures/background.pdf
  11. BIN
      whitepaper/Pictures/background.png
  12. BIN
      whitepaper/Pictures/background.xcf
  13. BIN
      whitepaper/Pictures/chapter_head_1.exr
  14. BIN
      whitepaper/Pictures/chapter_head_1.jpg
  15. BIN
      whitepaper/Pictures/chapter_head_1.png
  16. BIN
      whitepaper/Pictures/confirmregister.png
  17. BIN
      whitepaper/Pictures/desktopmain.png
  18. BIN
      whitepaper/Pictures/loginpage.png
  19. BIN
      whitepaper/Pictures/nekoit_title.png
  20. BIN
      whitepaper/Pictures/newdevice.png
  21. BIN
      whitepaper/Pictures/newfs.png
  22. BIN
      whitepaper/Pictures/placeholder.jpg
  23. +4
    -0
      whitepaper/StyleInd.ist
  24. +159
    -0
      whitepaper/bibliography.bib
  25. +23
    -0
      whitepaper/data/Cloud data storage.csv
  26. +1365
    -0
      whitepaper/main.tex
  27. +519
    -0
      whitepaper/structure.tex

+ 21
- 0
.gitignore 파일 보기

@ -1,3 +1,24 @@
*.orig
build/*
vgcore.*
whitepaper/main.aux
whitepaper/main.glo
whitepaper/main.idx
whitepaper/main.ist
whitepaper/main.ilg
whitepaper/main.ind
whitepaper/main.lof
whitepaper/main.bbl
whitepaper/main.bcf
whitepaper/main.blj
whitepaper/main.lot
whitepaper/main.log
whitepaper/main.blg
whitepaper/main.ptc
whitepaper/structure.idx
whitepaper/structure.log
whitepaper/texput.log
whitepaper/main.run.xml
whitepaper/main.toc
whitepaper/main.synctex.gz
whitepaper/main.pdf

+ 3
- 0
Makefile 파일 보기

@ -60,7 +60,10 @@ $(TARGET): $(OBJECTS) $(TJS_OBJECTS) build
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -pthread $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/$(TARGETNAME) src/$(TARGET) $(OBJECTS) $(TJS_OBJECTS)
$(CXX) $(CXXFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/test_client src/test_client.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/test_spam_version src/test_spam_version.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/db_stats src/db_stats.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/test-time-client tests/time-client.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/test-time-server tests/time-server.cpp
.PHONY: all build clean

+ 7
- 0
include/database.hpp 파일 보기

@ -3,6 +3,13 @@
#include <chrono>
#include <random>
enum class data_mode {
A,
B,
AB
};
struct metadata_t{
bitops::regulated<uint64_t> record_cnt;
bitops::regulated<uint64_t> page_cnt;

+ 35
- 3
include/network.hpp 파일 보기

@ -2,6 +2,9 @@
#include "endian.hpp"
#include "database.hpp"
/*************************************/
/* STORAGE SERVER */
/*************************************/
enum class db_op : uint32_t {
version = 0,
@ -10,11 +13,11 @@ enum class db_op : uint32_t {
remove = 3,
stats = 4,
sread = 5,
swrite = 6,
swrite = p">(2 << 16) + write,
sallocate = 7,
sremove = mi">3,
sremove = p">(2 << 16) + remove,
confirm = 8,
bulk_write = mi">9
bulk_write = p">(2 << 15) + write
};
struct [[gnu::packed]] received_data {
@ -27,6 +30,7 @@ struct [[gnu::packed]] received_data {
struct [[gnu::packed]] received_bulk_data {
bitops::regulated<db_op> op = db_op::version;
bitops::regulated<uint64_t> rep_id = 0;
bitops::regulated<uint32_t> nb_count = 0;
std::array<record_identifier, 4096/sizeof(record_identifier)> identifiers;
std::array<db_page, 4096/sizeof(record_identifier)> page;
};
@ -49,4 +53,32 @@ struct [[gnu::packed]] stats_data {
bitops::regulated<uint64_t> sync_duration_µs;
bitops::regulated<uint64_t> max_sync_duration_µs;
bitops::regulated<uint64_t> avg_sync_duration_µs;
};
/*************************************/
/* COORDINATE SERVER */
/*************************************/
enum class coord_op : uint32_t {
version = 0,
read = 1,
write = 2,
remove = 3,
stats = 4
};
struct [[gnu::packed]] received_data_coord {
bitops::regulated<db_op> op = db_op::version;
bitops::regulated<uint64_t> rep_id = 0;
record_identifier identifier = record_identifier{};
db_page pageA = {0};
db_page pageB = {0};
};
struct req_rep {
uint64_t id = 0;
uint64_t client_ts = 0;
bitops::regulated<uint64_t> server_ts = 0;
};

+ 56
- 0
src/izaro-coordinate.cpp 파일 보기

@ -0,0 +1,56 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <variant>
#include <chrono>
#include <algorithm>
#include "database.hpp"
#include "network.hpp"
#include <memory>
#include <cstdlib>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <stdio.h>
#include "commander.hpp"
class [[gnu::packed]] server {
std::array<uint8_t, 4> address;
uint16_t port;
};
class system_link{
server A;
server B;
server AB;
template<data_mode mode>
server operator() ()
{
if constexpr (mode == data_mode::A)
{
return A;
} else if constexpr (mode == data_mode::B)
{
return B;
} else if constexpr (mode == data_mode::AB)
{
return AB;
}
}
};
std::vector<server> spares;
int main()
{
uint16_t db_port = 25666;
auto soc = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(db_port);
memset((void*)&addr.sin_addr, 0, sizeof(addr.sin_addr));
bind(soc,(struct sockaddr*)&addr,sizeof(addr));
}

+ 50
- 0
src/test_spam_version.cpp 파일 보기

@ -0,0 +1,50 @@
#include "network.hpp"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int main(int, char** argv) {
{
auto soc = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in server;
server.sin_family = AF_INET;
server.sin_addr.s_addr = *(in_addr_t*)std::array<unsigned char, 4>{127,0,0,1}.data();
server.sin_port = htons(20450);
uint32_t tot = 2048;
if(argv[1])
{
tot = std::stoi(argv[1]);
}
connect(soc, (struct sockaddr*)&server, sizeof(server));
sending_data reply;
received_data request;
db_page& v = request.page;
v.fill(1);
auto begin = std::chrono::high_resolution_clock::now();
for(size_t idx=0;idx<tot;idx++)
{
request.op = db_op::version;
sendto(
soc,
(void*)&request,
sizeof(request.op),
0,
(struct sockaddr*)&server,
(socklen_t)sizeof(server)
);
recv(soc, &reply, sizeof(reply), 0);
}
auto durr = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - begin)/tot;
std::cerr << "-v:durr/elem = " << durr.count() << "ns/op" << std::endl;
std::cerr << "-v:elem/s = " << 1000000000.0f/durr.count() << std::endl;
}
}

+ 113
- 0
tests/time-client.cpp 파일 보기

@ -0,0 +1,113 @@
#include <chrono>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <sstream>
#include <string>
#include <endian.hpp>
#include <network.hpp>
#include <array>
#include <thread>
#include <algorithm>
using namespace std::chrono_literals;
int main(int, char** argv){
int64_t offset=0;
std::array<int64_t, 4096> offsets;
std::array<int64_t, 4096> offsets_smooth;
std::array<int64_t, 4096> offset_variations;
size_t pos = 0;
int64_t max_offset_variation;
int64_t max_oscillation = 0;
int64_t min_ever = std::numeric_limits<int64_t>::max();
int64_t max_ever = 0;
std::stringstream ip_stream{argv[1]};
std::array<uint8_t, 4> ip;
std::string token;
std::getline(ip_stream, token, '.');
ip[0] = std::stoi(token);
std::getline(ip_stream, token, '.');
ip[1] = std::stoi(token);
std::getline(ip_stream, token, '.');
ip[2] = std::stoi(token);
std::getline(ip_stream, token, '.');
ip[3] = std::stoi(token);
uint16_t port = std::stoi(argv[2]);
auto soc = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in server;
server.sin_family = AF_INET;
server.sin_addr.s_addr = *(in_addr_t*)ip.data();
server.sin_port = htons(port);
struct timeval tv;
tv.tv_sec = 5;
tv.tv_usec = 0;
setsockopt(soc, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv);
std::cerr << "Connecting..." <<std::endl;
connect(soc, (struct sockaddr*)&server, sizeof(server));
req_rep buffer;
uint64_t cnt = 0;
uint64_t old_time = 0;
while(true)
{
uint64_t tmp;
buffer.id = 16;
buffer.client_ts = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
send(soc, (void*)&buffer, (socklen_t)sizeof(req_rep), 0);
recv(soc, (void*)&buffer, (socklen_t)sizeof(req_rep), 0);
if(buffer.server_ts != old_time)
{
tmp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count() - buffer.client_ts;
int64_t n_offset = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count() - buffer.server_ts;
n_offset /= 2;
offset_variations[pos] = ((long long)(offset-n_offset));
if(cnt != 0)
{
offsets[pos] = n_offset;
} else {
offsets.fill(n_offset);
offsets_smooth.fill(n_offset);
}
max_offset_variation = std::max(*std::max_element(offset_variations.begin(), offset_variations.end()), std::abs((int64_t)*std::min_element(offset_variations.begin(), offset_variations.end())));
offset = (
7 * (std::accumulate(offsets_smooth.begin(), offsets_smooth.end(), 0)/offsets_smooth.size())
+ std::accumulate(offsets.begin(), offsets.end(), 0)/offsets.size()
) / 8;
offsets_smooth[pos] = offset;
pos=(pos+1)%offset_variations.size();
if(cnt > offsets.size()*2)
{
for(auto i : offsets_smooth)
for(auto j : offsets_smooth)
{
max_oscillation = std::max(
std::abs(i-j),
max_oscillation
);
}
min_ever = std::min(min_ever, offset);
max_ever = std::max(max_ever, offset);
}
else if (cnt < offsets.size()) {
offsets_smooth[pos] = n_offset;
}
old_time = buffer.server_ts;
std::cout << cnt << "\t"<< min_ever << "\t" << offset << "\t" << max_ever << "\t" << max_oscillation << "\t" << offset-n_offset << "\t" << max_offset_variation <<std::endl;
}
cnt++;
//std::this_thread::sleep_for(6ms);
}
}

+ 45
- 0
tests/time-server.cpp 파일 보기

@ -0,0 +1,45 @@
#include <chrono>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <endian.hpp>
#include <network.hpp>
using namespace std::chrono_literals;
int main(){
uint16_t db_port = 32555;
auto soc = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(db_port);
memset((void*)&addr.sin_addr, 0, sizeof(addr.sin_addr));
bind(soc,(struct sockaddr*)&addr,sizeof(addr));
req_rep buffer;
sockaddr_in client;
socklen_t packet_sz;
while(true)
{
recvfrom(
soc,
(void*)&buffer,
sizeof(req_rep),
MSG_WAITFORONE,
(struct sockaddr*)&client,
&packet_sz
);
buffer.server_ts = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
sendto(
soc,
(void*)&buffer,
sizeof(req_rep),
0,
(struct sockaddr*)&client,
(socklen_t)sizeof(client)
);
}
}

BIN
whitepaper/Pictures/Mockups.epgz 파일 보기


BIN
whitepaper/Pictures/background.pdf 파일 보기


BIN
whitepaper/Pictures/background.png 파일 보기

Before After
Width: 4841  |  Height: 6921  |  Size: 147 KiB

BIN
whitepaper/Pictures/background.xcf 파일 보기


BIN
whitepaper/Pictures/chapter_head_1.exr 파일 보기


BIN
whitepaper/Pictures/chapter_head_1.jpg 파일 보기

Before After
Width: 1920  |  Height: 960  |  Size: 314 KiB

BIN
whitepaper/Pictures/chapter_head_1.png 파일 보기

Before After
Width: 1920  |  Height: 960  |  Size: 1.8 MiB

BIN
whitepaper/Pictures/confirmregister.png 파일 보기

Before After
Width: 457  |  Height: 698  |  Size: 33 KiB

BIN
whitepaper/Pictures/desktopmain.png 파일 보기

Before After
Width: 917  |  Height: 590  |  Size: 54 KiB

BIN
whitepaper/Pictures/loginpage.png 파일 보기

Before After
Width: 915  |  Height: 698  |  Size: 27 KiB

BIN
whitepaper/Pictures/nekoit_title.png 파일 보기

Before After
Width: 4800  |  Height: 1200  |  Size: 157 KiB

BIN
whitepaper/Pictures/newdevice.png 파일 보기

Before After
Width: 457  |  Height: 598  |  Size: 25 KiB

BIN
whitepaper/Pictures/newfs.png 파일 보기

Before After
Width: 457  |  Height: 598  |  Size: 24 KiB

BIN
whitepaper/Pictures/placeholder.jpg 파일 보기

Before After
Width: 350  |  Height: 193  |  Size: 20 KiB

+ 4
- 0
whitepaper/StyleInd.ist 파일 보기

@ -0,0 +1,4 @@
delim_0 "\\dotfill\ "
delim_1 "\\dotfill\ "
headings_flag 1
heading_prefix "\\nopagebreak\n\\tikz\\node at (0pt,0pt) [draw=none,fill=ocre!50,line width=1pt,inner sep=5pt]{\\parbox{\\linewidth-2\\fboxsep-2\\fboxrule-2pt}{\\centering\\large\\sffamily\\bfseries\\textcolor{white}{" heading_suffix "}}};\\vspace*{0.2cm}\\nopagebreak\n"

+ 159
- 0
whitepaper/bibliography.bib 파일 보기

@ -0,0 +1,159 @@
@book{book_key,
address = {City},
publisher = {Publisher},
author = {Smith, John},
title = {Book title},
year = {2012},
volume = {3},
series = {2},
edition = {1},
pages = {123--200},
month = {January}
}
@article{article_key,
address = {City},
publisher = {Publisher},
author = {Smith, James},
title = {Article title},
year = {2013},
volume = {14},
number = {6},
pages = {1--8},
month = {March},
}
@article{Gilbert:2002:BCF:564585.564601,
author = {Gilbert, Seth and Lynch, Nancy},
title = {Brewer's Conjecture and the Feasibility of Consistent, Available, Partition-tolerant Web Services},
journal = {SIGACT News},
issue_date = {June 2002},
volume = {33},
number = {2},
month = 6,
year = {2002},
issn = {0163-5700},
pages = {51--59},
numpages = {9},
url = {http://doi.acm.org/10.1145/564585.564601},
doi = {10.1145/564585.564601},
acmid = {564601},
publisher = {ACM},
address = {New York, NY, USA}
}
@article{6133253,
author={E. Brewer},
journal={Computer},
title={CAP twelve years later: How the "rules" have changed},
year={2012},
volume={45},
number={2},
pages={23-29},
keywords={theorem proving;CAP theorem;consistency-availability-partition tolerance theorem;networked shared-data system;partition handling;Web extra;Software Engineering Radio;Distributed databases;Relational databases;Data processing;Cloud computing;CAP theorem;ACID;BASE;cloud computing},
doi={10.1109/MC.2012.37},
ISSN={0018-9162},
month={2}
}
@article{rootlisp,
author={Paul Graham},
title={The Roots of Lisp},
year={2001},
keywords={lisp;programming;language},
month={5},
url={http://www.paulgraham.com/rootsoflisp.html}
}
@article{Undeflow_2014,
title={Subtract and detect underflow, most efficient way? (x86/64 with GCC)},
url={https://stackoverflow.com/questions/24958469/subtract-and-detect-underflow-most-efficient-way-x86-64-with-gcc},
journal={StackOverflow},
publisher={Stack Exchange},
author={(StackExchange user), kktsuri and (StackExchange user), Jester},
year={2014},
month={7}
}
@phdthesis{Gentry:2009:FHE:1834954,
author = {Gentry, Craig},
advisor = {Boneh, Dan},
title = {A Fully Homomorphic Encryption Scheme},
year = {2009},
isbn = {978-1-109-44450-6},
note = {AAI3382729},
publisher = {Stanford University},
address = {Stanford, CA, USA},
}
@article{bbc_icloud,
title={Apple toughens iCloud security after celebrity breach},
url={https://www.bbc.com/news/technology-29237469},
journal={BBC},
publisher={BBC},
author={Leo Kelion},
year={2014},
month={7}
}
@misc{wiki:Data_Encryption_Standard,
author = "Wikipedia",
title = "{Data Encryption Standard} --- {W}ikipedia{,} The Free Encyclopedia",
year = "2019",
url = {http://en.wikipedia.org/w/index.php?title=Data\%20Encryption\%20Standard&oldid=905592598},
note = "[Online; accessed 30-July-2019]"
}
@misc{apple_sweatshop,
title={Samsung one-ups Apple with sweatshop labor: contractor raided by ICE.},
url={https://www.youtube.com/watch?v=XjW2tMeO3Mk},
journal={Louis Rossmann Group},
howpublished={Youtube},
author={Louis Rossmann},
year={2019},
month={4}
}
@misc{ltt_backup,
title={I Hope Google Doesn’t Ban Us... - Abusing Unlimited Google Drive},
url={https://www.youtube.com/watch?v=y2F0wjoKEhg},
journal={Linus Tech Tips},
howpublished={Youtube},
author={Linus Media Group},
year={2018},
month={8}
}
@misc{cambridge_analytica,
title={Facebook, l'envers du réseau},
url={https://www.youtube.com/watch?v=9kpKDaF3IFw},
journal={Envoyé spécial},
howpublished={TV},
author={France 2},
year={2018},
month={4}
}
@article{cockroach_atomic,
title={Living without atomic clocks},
url={https://www.cockroachlabs.com/blog/living-without-atomic-clocks/},
journal={Cockroach Labs Blog},
publisher={Cockroach Labs},
author={Spencer Kimball},
year={2016},
month={2}
}
@article{cockroach_postgres,
title={Why CockroachDB and PostgreSQL Are Compatible},
url={https://www.cockroachlabs.com/blog/why-postgres/},
journal={Cockroach Labs Blog},
publisher={Cockroach Labs},
author={Raphael 'kena' Poss},
year={2018},
month={August}
}

+ 23
- 0
whitepaper/data/Cloud data storage.csv 파일 보기

@ -0,0 +1,23 @@
How concerned about data privacy are you ?,Do you use any of those features/applications ?,Which do you trust more ?,Do you currently use any sort of online storage ?
Very concerned,Telegram,Open-Source community approved cryptography,No
Very concerned,Encrypted harddrive (open source solution);VPN;Telegram,Open-Source community approved cryptography,No
Very concerned,Encrypted harddrive (open source solution);VPN;Telegram,Open-Source community approved cryptography,"Yes, an encrypted one"
Concerned,,Open-Source community approved cryptography,"Yes, an encrypted one"
Very concerned,Encrypted harddrive (open source solution);VPN,Open-Source community approved cryptography,No
Concerned,Encrypted harddrive (open source solution);VPN;Telegram,Open-Source community approved cryptography,"Yes, but without encryption"
Not so concerned,Encrypted harddrive (open source solution),Government approved cryptography,No
Not so concerned,Telegram,Open-Source community approved cryptography,No
Not so concerned,Telegram,Open-Source community approved cryptography,No
Very concerned,VPN;Telegram,Government approved cryptography,No
Concerned,Encrypted harddrive (manufacturer solution);Encrypted harddrive (open source solution);VPN;Telegram,Open-Source community approved cryptography,"Yes, but without encryption"
Very concerned,Encrypted harddrive (manufacturer solution);Telegram,Open-Source community approved cryptography,"Yes, but without encryption"
Very concerned,Encrypted harddrive (open source solution);Telegram,Open-Source community approved cryptography,"Yes, an encrypted one"
Very concerned,Encrypted harddrive (open source solution);VPN;Telegram,Open-Source community approved cryptography,No
Very concerned,Encrypted harddrive (manufacturer solution);Encrypted harddrive (open source solution);VPN;Telegram,Open-Source community approved cryptography,"Yes, an encrypted one"
Very concerned,Encrypted harddrive (open source solution);Telegram,Open-Source community approved cryptography,No
Very concerned,VPN;Telegram,Open-Source community approved cryptography,No
Very concerned,VPN,Open-Source community approved cryptography,"Yes, but without encryption"
Very concerned,,Open-Source community approved cryptography,No
Not so concerned,,I don'k know,No
Very concerned,VPN;Telegram,Open-Source community approved cryptography,"Yes, an encrypted one"
Very concerned,VPN,Open-Source community approved cryptography,"Yes, an encrypted one"

+ 1365
- 0
whitepaper/main.tex
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 519
- 0
whitepaper/structure.tex 파일 보기

@ -0,0 +1,519 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The Legrand Orange Book
% Structural Definitions File
% Version 2.1 (26/09/2018)
%
% Original author:
% Mathias Legrand (legrand.mathias@gmail.com) with modifications by:
% Vel (vel@latextemplates.com)
%
% This file was downloaded from:
% http://www.LaTeXTemplates.com
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------------------------------------------------------------------------------------
% VARIOUS REQUIRED PACKAGES AND CONFIGURATIONS
%----------------------------------------------------------------------------------------
\usepackage{graphicx} % Required for including pictures
\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored
\usepackage{lipsum} % Inserts dummy text
\usepackage{tikz} % Required for drawing custom shapes
\usepackage[english]{babel} % English language/hyphenation
\usepackage{makeidx}
\usepackage{enumitem} % Customize lists
\setlist{nolistsep} % Reduce spacing between bullet points and numbered lists
\usepackage{booktabs} % Required for nicer horizontal rules in tables
\usepackage{xcolor} % Required for specifying colors by name
\definecolor{ocre}{RGB}{0,102,233} % Define the orange color used for highlighting throughout the book
\makeindex
%----------------------------------------------------------------------------------------
% MARGINS
%----------------------------------------------------------------------------------------
\usepackage{geometry} % Required for adjusting page dimensions and margins
\geometry{
paper=a4paper, % Paper size, change to letterpaper for US letter size
top=3cm, % Top margin
bottom=3cm, % Bottom margin
left=3cm, % Left margin
right=3cm, % Right margin
headheight=14pt, % Header height
footskip=1.4cm, % Space from the bottom margin to the baseline of the footer
headsep=10pt, % Space from the top margin to the baseline of the header
%showframe, % Uncomment to show how the type block is set on the page
}
%----------------------------------------------------------------------------------------
% FONTS
%----------------------------------------------------------------------------------------
\usepackage{avant} % Use the Avantgarde font for headings
%\usepackage{times} % Use the Times font for headings
\usepackage{mathptmx} % Use the Adobe Times Roman as the default text font together with math symbols from the Sym­bol, Chancery and Com­puter Modern fonts
\usepackage{microtype} % Slightly tweak font spacing for aesthetics
\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------
\usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]{biblatex}
\addbibresource{bibliography.bib} % BibTeX bibliography file
\defbibheading{bibempty}{}
\usepackage{calc} % For simpler calculation - used for spacing the index letter headings correctly
\usepackage{makeidx} % Required to make an index
\makeindex % Tells LaTeX to create the files required for indexing
%----------------------------------------------------------------------------------------
% MAIN TABLE OF CONTENTS
%----------------------------------------------------------------------------------------
\usepackage{titletoc} % Required for manipulating the table of contents
\contentsmargin{0cm} % Removes the default margin
% Part text styling (this is mostly taken care of in the PART HEADINGS section of this file)
\titlecontents{part}
[0cm] % Left indentation
{\addvspace{20pt}\bfseries} % Spacing and font options for parts
{}
{}
{}
% Chapter text styling
\titlecontents{chapter}
[1.25cm] % Left indentation
{\addvspace{12pt}\large\sffamily\bfseries} % Spacing and font options for chapters
{\color{ocre!60}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{ocre}} % Formatting of numbered sections of this type
{\color{ocre}} % Formatting of numberless sections of this type
{\color{ocre!60}\normalsize\;\titlerule*[.5pc]{.}\;\thecontentspage} % Formatting of the filler to the right of the heading and the page number
% Section text styling
\titlecontents{section}
[1.25cm] % Left indentation
{\addvspace{3pt}\sffamily\bfseries} % Spacing and font options for sections
{\contentslabel[\thecontentslabel]{1.25cm}} % Formatting of numbered sections of this type
{} % Formatting of numberless sections of this type
{\hfill\color{black}\thecontentspage} % Formatting of the filler to the right of the heading and the page number
% Subsection text styling
\titlecontents{subsection}
[1.25cm] % Left indentation
{\addvspace{1pt}\sffamily\small} % Spacing and font options for subsections
{\contentslabel[\thecontentslabel]{1.25cm}} % Formatting of numbered sections of this type
{} % Formatting of numberless sections of this type
{\ \titlerule*[.5pc]{.}\;\thecontentspage} % Formatting of the filler to the right of the heading and the page number
% Figure text styling
\titlecontents{figure}
[1.25cm] % Left indentation
{\addvspace{1pt}\sffamily\small} % Spacing and font options for figures
{\thecontentslabel\hspace*{1em}} % Formatting of numbered sections of this type
{} % Formatting of numberless sections of this type
{\ \titlerule*[.5pc]{.}\;\thecontentspage} % Formatting of the filler to the right of the heading and the page number
% Table text styling
\titlecontents{table}
[1.25cm] % Left indentation
{\addvspace{1pt}\sffamily\small} % Spacing and font options for tables
{\thecontentslabel\hspace*{1em}} % Formatting of numbered sections of this type
{} % Formatting of numberless sections of this type
{\ \titlerule*[.5pc]{.}\;\thecontentspage} % Formatting of the filler to the right of the heading and the page number
%----------------------------------------------------------------------------------------
% MINI TABLE OF CONTENTS IN PART HEADS
%----------------------------------------------------------------------------------------
% Chapter text styling
\titlecontents{lchapter}
[0em] % Left indentation
{\addvspace{15pt}\large\sffamily\bfseries} % Spacing and font options for chapters
{\color{ocre}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{ocre}} % Chapter number
{}
{\color{ocre}\normalsize\sffamily\bfseries\;\titlerule*[.5pc]{.}\;\thecontentspage} % Page number
% Section text styling
\titlecontents{lsection}
[0em] % Left indentation
{\sffamily\small} % Spacing and font options for sections
{\contentslabel[\thecontentslabel]{1.25cm}} % Section number
{}
{}
% Subsection text styling (note these aren't shown by default, display them by searchings this file for tocdepth and reading the commented text)
\titlecontents{lsubsection}
[.5em] % Left indentation
{\sffamily\footnotesize} % Spacing and font options for subsections
{\contentslabel[\thecontentslabel]{1.25cm}}
{}
{}
%----------------------------------------------------------------------------------------
% HEADERS AND FOOTERS
%----------------------------------------------------------------------------------------
\usepackage{fancyhdr} % Required for header and footer configuration
\pagestyle{fancy} % Enable the custom headers and footers
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries\chaptername\ \thechapter.\ #1}{}} % Styling for the current chapter in the header
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}} % Styling for the current section in the header
\fancyhf{} % Clear default headers and footers
\fancyhead[LE,RO]{\sffamily\normalsize\thepage} % Styling for the page number in the header
\fancyhead[LO]{\rightmark} % Print the nearest section name on the left side of odd pages
\fancyhead[RE]{\leftmark} % Print the current chapter name on the right side of even pages
%\fancyfoot[C]{\thepage} % Uncomment to include a footer
\renewcommand{\headrulewidth}{0.5pt} % Thickness of the rule under the header
\fancypagestyle{plain}{% Style for when a plain pagestyle is specified
\fancyhead{}\renewcommand{\headrulewidth}{0pt}%
}
% Removes the header from odd empty pages at the end of chapters
\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}
%----------------------------------------------------------------------------------------
% THEOREM STYLES
%----------------------------------------------------------------------------------------
\usepackage{amsmath,amsfonts,amssymb,amsthm} % For math equations, theorems, symbols, etc
\newcommand{\intoo}[2]{\mathopen{]}#1\,;#2\mathclose{[}}
\newcommand{\ud}{\mathop{\mathrm{{}d}}\mathopen{}}
\newcommand{\intff}[2]{\mathopen{[}#1\,;#2\mathclose{]}}
\renewcommand{\qedsymbol}{$\blacksquare$}
\newtheorem{notation}{Notation}[chapter]
% Boxed/framed environments
\newtheoremstyle{ocrenumbox}% Theorem style name
{0pt}% Space above
{0pt}% Space below
{\normalfont}% Body font
{}% Indent amount
{\small\bf\sffamily\color{ocre}}% Theorem head font
{\;}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\small\sffamily\color{ocre}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}} % Optional theorem note
\newtheoremstyle{blacknumex}% Theorem style name
{5pt}% Space above
{5pt}% Space below
{\normalfont}% Body font
{} % Indent amount
{\small\bf\sffamily}% Theorem head font
{\;}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\small\sffamily{\tiny\ensuremath{\blacksquare}}\nobreakspace\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}% Optional theorem note
\newtheoremstyle{blacknumbox} % Theorem style name
{0pt}% Space above
{0pt}% Space below
{\normalfont}% Body font
{}% Indent amount
{\small\bf\sffamily}% Theorem head font
{\;}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\small\sffamily\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}% Optional theorem note
% Non-boxed/non-framed environments
\newtheoremstyle{ocrenum}% Theorem style name
{5pt}% Space above
{5pt}% Space below
{\normalfont}% Body font
{}% Indent amount
{\small\bf\sffamily\color{ocre}}% Theorem head font
{\;}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\small\sffamily\color{ocre}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}} % Optional theorem note
\makeatother
% Defines the theorem text style for each type of theorem to one of the three styles above
\newcounter{dummy}
\numberwithin{dummy}{section}
\theoremstyle{ocrenumbox}
\newtheorem{theoremeT}[dummy]{Theorem}
\newtheorem{problem}{Problem}[chapter]
\newtheorem{exerciseT}{Exercise}[chapter]
\theoremstyle{blacknumex}
\newtheorem{exampleT}{Example}[chapter]
\theoremstyle{blacknumbox}
\newtheorem{vocabulary}{Vocabulary}[chapter]
\newtheorem{definitionT}{Definition}[section]
\newtheorem{corollaryT}[dummy]{Corollary}
\theoremstyle{ocrenum}
\newtheorem{proposition}[dummy]{Proposition}
%----------------------------------------------------------------------------------------
% DEFINITION OF COLORED BOXES
%----------------------------------------------------------------------------------------
\RequirePackage[framemethod=default]{mdframed} % Required for creating the theorem, definition, exercise and corollary boxes
% Theorem box
\newmdenv[skipabove=7pt,
skipbelow=7pt,
backgroundcolor=black!5,
linecolor=ocre,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=5pt,
leftmargin=0cm,
rightmargin=0cm,
innerbottommargin=5pt]{tBox}
% Exercise box
\newmdenv[skipabove=7pt,
skipbelow=7pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
backgroundcolor=ocre!10,
linecolor=ocre,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=5pt,
innerbottommargin=5pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt]{eBox}
% Definition box
\newmdenv[skipabove=7pt,
skipbelow=7pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
linecolor=ocre,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=0pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt,
innerbottommargin=0pt]{dBox}
% Corollary box
\newmdenv[skipabove=7pt,
skipbelow=7pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
linecolor=gray,
backgroundcolor=black!5,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=5pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt,
innerbottommargin=5pt]{cBox}
% Creates an environment for each type of theorem and assigns it a theorem text style from the "Theorem Styles" section above and a colored box from above
\newenvironment{theorem}{\begin{tBox}\begin{theoremeT}}{\end{theoremeT}\end{tBox}}
\newenvironment{exercise}{\begin{eBox}\begin{exerciseT}}{\hfill{\color{ocre}\tiny\ensuremath{\blacksquare}}\end{exerciseT}\end{eBox}}
\newenvironment{definition}{\begin{dBox}\begin{definitionT}}{\end{definitionT}\end{dBox}}
\newenvironment{example}{\begin{exampleT}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{exampleT}}
\newenvironment{corollary}{\begin{cBox}\begin{corollaryT}}{\end{corollaryT}\end{cBox}}
%----------------------------------------------------------------------------------------
% REMARK ENVIRONMENT
%----------------------------------------------------------------------------------------
\newenvironment{remark}{\par\vspace{10pt}\small % Vertical white space above the remark and smaller font size
\begin{list}{}{
\leftmargin=35pt % Indentation on the left
\rightmargin=25pt}\item\ignorespaces % Indentation on the right
\makebox[-2.5pt]{\begin{tikzpicture}[overlay]
\node[draw=ocre!60,line width=1pt,circle,fill=ocre!25,font=\sffamily\bfseries,inner sep=2pt,outer sep=0pt] at (-15pt,0pt){\textcolor{ocre}{R}};\end{tikzpicture}} % Orange R in a circle
\advance\baselineskip -1pt}{\end{list}\vskip5pt} % Tighter line spacing and white space after remark
%----------------------------------------------------------------------------------------
% SECTION NUMBERING IN THE MARGIN
%----------------------------------------------------------------------------------------
\makeatletter
\renewcommand{\@seccntformat}[1]{\llap{\textcolor{ocre}{\csname the#1\endcsname}\hspace{1em}}}
\renewcommand{\section}{\@startsection{section}{1}{\z@}
{-4ex \@plus -1ex \@minus -.4ex}
{1ex \@plus.2ex }
{\normalfont\large\sffamily\bfseries}}
\renewcommand{\subsection}{\@startsection {subsection}{2}{\z@}
{-3ex \@plus -0.1ex \@minus -.4ex}
{0.5ex \@plus.2ex }
{\normalfont\sffamily\bfseries}}
\renewcommand{\subsubsection}{\@startsection {subsubsection}{3}{\z@}
{-2ex \@plus -0.1ex \@minus -.2ex}
{.2ex \@plus.2ex }
{\normalfont\small\sffamily\bfseries}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}
{-2ex \@plus-.2ex \@minus .2ex}
{.1ex}
{\normalfont\small\sffamily\bfseries}}
%----------------------------------------------------------------------------------------
% PART HEADINGS
%----------------------------------------------------------------------------------------
% Numbered part in the table of contents
\newcommand{\@mypartnumtocformat}[2]{%
\setlength\fboxsep{0pt}%
\noindent\colorbox{ocre!20}{\strut\parbox[c][.7cm]{\ecart}{\color{ocre!70}\Large\sffamily\bfseries\centering#1}}\hskip\esp\colorbox{ocre!40}{\strut\parbox[c][.7cm]{\linewidth-\ecart-\esp}{\Large\sffamily\centering#2}}%
}
% Unnumbered part in the table of contents
\newcommand{\@myparttocformat}[1]{%
\setlength\fboxsep{0pt}%
\noindent\colorbox{ocre!40}{\strut\parbox[c][.7cm]{\linewidth}{\Large\sffamily\centering#1}}%
}
\newlength\esp
\setlength\esp{4pt}
\newlength\ecart
\setlength\ecart{1.2cm-\esp}
\newcommand{\thepartimage}{}%
\newcommand{\partimage}[1]{\renewcommand{\thepartimage}{#1}}%
\def\@part[#1]#2{%
\ifnum \c@secnumdepth >-2\relax%
\refstepcounter{part}%
\addcontentsline{toc}{part}{\texorpdfstring{\protect\@mypartnumtocformat{\thepart}{#1}}{\partname~\thepart\ ---\ #1}}
\else%
\addcontentsline{toc}{part}{\texorpdfstring{\protect\@myparttocformat{#1}}{#1}}%
\fi%
\startcontents%
\markboth{}{}%
{\thispagestyle{empty}%
\begin{tikzpicture}[remember picture,overlay]%
\node at (current page.north west){\begin{tikzpicture}[remember picture,overlay]%
\fill[ocre!20](0cm,0cm) rectangle (\paperwidth,-\paperheight);
\node[anchor=north] at (4cm,-3.25cm){\color{ocre!40}\fontsize{220}{100}\sffamily\bfseries\thepart};
\node[anchor=south east] at (\paperwidth-1cm,-\paperheight+1cm){\parbox[t][][t]{8.5cm}{
\printcontents{l}{0}{\setcounter{tocdepth}{1}}% The depth to which the Part mini table of contents displays headings; 0 for chapters only, 1 for chapters and sections and 2 for chapters, sections and subsections
}};
\node[anchor=north east] at (\paperwidth-1.5cm,-3.25cm){\parbox[t][][t]{15cm}{\strut\raggedleft\color{white}\fontsize{30}{30}\sffamily\bfseries#2}};
\end{tikzpicture}};
\end{tikzpicture}}%
\@endpart}
\def\@spart#1{%
\startcontents%
\phantomsection
{\thispagestyle{empty}%
\begin{tikzpicture}[remember picture,overlay]%
\node at (current page.north west){\begin{tikzpicture}[remember picture,overlay]%
\fill[ocre!20](0cm,0cm) rectangle (\paperwidth,-\paperheight);
\node[anchor=north east] at (\paperwidth-1.5cm,-3.25cm){\parbox[t][][t]{15cm}{\strut\raggedleft\color{white}\fontsize{30}{30}\sffamily\bfseries#1}};
\end{tikzpicture}};
\end{tikzpicture}}
\addcontentsline{toc}{part}{\texorpdfstring{%
\setlength\fboxsep{0pt}%
\noindent\protect\colorbox{ocre!40}{\strut\protect\parbox[c][.7cm]{\linewidth}{\Large\sffamily\protect\centering #1\quad\mbox{}}}}{#1}}%
\@endpart}
\def\@endpart{\vfil\newpage
\if@twoside
\if@openright
\null
\thispagestyle{empty}%
\newpage
\fi
\fi
\if@tempswa
\twocolumn
\fi}
%----------------------------------------------------------------------------------------
% CHAPTER HEADINGS
%----------------------------------------------------------------------------------------
% A switch to conditionally include a picture, implemented by Christian Hupfer
\newif\ifusechapterimage
\usechapterimagetrue
\newcommand{\thechapterimage}{}%
\newcommand{\chapterimage}[1]{\ifusechapterimage\renewcommand{\thechapterimage}{#1}\fi}%
\newcommand{\autodot}{.}
\def\@makechapterhead#1{%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}\thechapter\autodot~#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\else
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\fi\fi\par\vspace*{270\p@}}}
%-------------------------------------------
\def\@makeschapterhead#1{%
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] at (0,0) {\ifusechapterimage\includegraphics[width=\paperwidth]{\thechapterimage}\fi};
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white,fill opacity=0.5,inner sep=15pt]{\strut\makebox[22cm]{}};
\draw[anchor=west] (\Gm@lmargin+.3cm,-9cm) node {\huge\sffamily\bfseries\color{black}#1\strut};
\end{tikzpicture}};
\end{tikzpicture}
\par\vspace*{270\p@}}
\makeatother
%----------------------------------------------------------------------------------------
% LINKS
%----------------------------------------------------------------------------------------
\usepackage{hyperref}
%\hypersetup{hidelinks,backref=true,pagebackref=true,colorlinks=false,breaklinks=true,urlcolor=ocre,bookmarks=true,bookmarksopen=false}
\usepackage{bookmark}
\bookmarksetup{
open,
numbered,
addtohook={%
\ifnum\bookmarkget{level}=0 % chapter
\bookmarksetup{bold}%
\fi
\ifnum\bookmarkget{level}=-1 % part
\bookmarksetup{color=ocre,bold}%
\fi
}
}

불러오는 중...
취소
저장