From a9baf1b501d6459ad7c7e7da95f25bb8dd3a98aa Mon Sep 17 00:00:00 2001 From: Nam Tran Date: Sat, 1 Feb 2020 19:04:02 -0600 Subject: [PATCH] tricks to compile 2 pdf from 1 source file --- wedding-invitation/Makefile | 16 ++++-- wedding-invitation/qrEvent_en.txt | 11 ++++ wedding-invitation/qrGen.py | 23 ++++---- wedding-invitation/thiep1.tex | 92 ++++++++++++++++++++----------- 4 files changed, 93 insertions(+), 49 deletions(-) create mode 100644 wedding-invitation/qrEvent_en.txt diff --git a/wedding-invitation/Makefile b/wedding-invitation/Makefile index 19e2557..e018cb9 100644 --- a/wedding-invitation/Makefile +++ b/wedding-invitation/Makefile @@ -1,15 +1,21 @@ DOC=thiep1 INPUT=$(DOC).tex -TARGET=$(DOC).pdf +TARGET_EN=thiep_en +TARGET_VI=thiep_vi +TARGET=$(TARGET_EN).pdf $(TARGET_VI).pdf TEX=xelatex -QR=qr.png +QR=qrEvent_vi.png qrEvent_en.png default: $(TARGET) -$(TARGET): $(INPUT) Makefile $(QR) - $(TEX) $< && $(TEX) $< +$(TARGET_EN).pdf: $(INPUT) Makefile $(QR) + $(TEX) --jobname=$(TARGET_EN) $< && $(TEX) --jobname=$(TARGET_EN) $< -$(QR): qrEvent_vi.txt +$(TARGET_VI).pdf: $(INPUT) Makefile $(QR) + $(TEX) --jobname=$(TARGET_VI) "\def\ViFlag{}\input{$<}" && \ + $(TEX) --jobname=$(TARGET_VI) "\def\ViFlag{}\input{$<}" + +$(QR): qrEvent_vi.txt qrEvent_en.txt ./qrGen.py clean: diff --git a/wedding-invitation/qrEvent_en.txt b/wedding-invitation/qrEvent_en.txt new file mode 100644 index 0000000..c140246 --- /dev/null +++ b/wedding-invitation/qrEvent_en.txt @@ -0,0 +1,11 @@ +BEGIN:VCALENDAR +VERSION:2.0 +BEGIN:VEVENT +SUMMARY:Nam's wedding +DTSTART;TZID=Asia/Saigon:20200301T160000 +DTEND;TZID=Asia/Saigon:20200301T200000 +LOCATION:Auco Convention Center, 1A Nguyen Huu Cau Str., Ngoc Chau Ward, Hai Duong City, Hai Duong, Vietnam +GEO:20.9351879;106.3433482,18 +URL:https://goo.gl/maps/eyfMhXgjFTQzAWB79 +END:VEVENT +END:VCALENDAR diff --git a/wedding-invitation/qrGen.py b/wedding-invitation/qrGen.py index 93af205..5878785 100755 --- a/wedding-invitation/qrGen.py +++ b/wedding-invitation/qrGen.py @@ -1,14 +1,15 @@ #!/usr/bin/env python3 import qrcode -qr = qrcode.QRCode( - version=2, - error_correction=qrcode.constants.ERROR_CORRECT_Q, - box_size=5, - border=1) - -with open("qrEvent_vi.txt") as fp: - qr.add_data(fp.read()) - qr.make(fit=True) - img = qr.make_image(fill_color="orangered", back_color="white") - img.save("qr.png") +for fname in ["qrEvent_en", "qrEvent_vi"]: + qr = qrcode.QRCode( + version=2, + error_correction=qrcode.constants.ERROR_CORRECT_Q, + box_size=5, + border=1) + + with open(f"{fname}.txt") as fp: + qr.add_data(fp.read()) + qr.make(fit=True) + img = qr.make_image(fill_color="orangered", back_color="white") + img.save(f"{fname}.png") diff --git a/wedding-invitation/thiep1.tex b/wedding-invitation/thiep1.tex index 1ac253f..76e1a64 100644 --- a/wedding-invitation/thiep1.tex +++ b/wedding-invitation/thiep1.tex @@ -5,19 +5,19 @@ \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{ebgaramond} +\usepackage{etoolbox} + +\newtoggle{Vietnamese} + +\ifdefined\ViFlag + \toggletrue{Vietnamese} +\else + \togglefalse{Vietnamese} +\fi \usetikzlibrary{fadings} % \tikzfading[name=fade right, left color=transparent!0, right color=transparent!100] % \tikzfading[name=fade in, inner color=transparent!200, outer color=transparent!0] - -% \pgfdeclareradialshading{ellipse}{\pgfpoint{50bp}{50bp}}{ -\pgfdeclareradialshading{ellipse}{\pgfpoint{100bp}{100bp}}{ - color(0bp)=(pgftransparent!100); - color(25bp)=(pgftransparent!100); - color(50bp)=(pgftransparent!80); - color(75bp)=(pgftransparent!00); - color(100bp)=(pgftransparent!0)} - \pgfdeclarehorizontalshading{FOne}{100bp} { color(0bp)=(pgftransparent!0); color(25bp)=(pgftransparent!0); @@ -31,45 +31,71 @@ \begin{document} \begin{tikzpicture}[overlay,remember picture] \node[anchor=east,inner sep=0pt] (pic) at (current page.east) - % {\includegraphics[height=\pdfpageheight]{GAO_9361_01}}; {\includegraphics[height=\pdfpageheight]{027-028}}; - % \fill[white,path fading=fade right] (pic.north west) rectangle (pic.south east); \fill[white,path fading=myfading] (pic.north west) rectangle (pic.south east); - % \coordinate (pin) at (12,-2.5); - % \filldraw[ultra thick,draw=red,fill=red!50] (pin) -- ++(70:.5) arc (-20:200:.18) -- cycle; - % \path (pin) -- ++(0,.5) node[draw,fill,red,circle,inner sep=1pt] {}; - \node[anchor=south east, inner sep=0pt] (qr) at (pic.south east) - {\includegraphics[height=2.8cm]{qr}}; + \iftoggle{Vietnamese}{ + \node[anchor=south east, inner sep=0pt] (qrEvent_vi) at (pic.south east) + {\includegraphics[height=2.5cm]{qrEvent_vi}}; + }{ + \node[anchor=south east, inner sep=0pt] (qrEvent_en) at (pic.south east) + {\includegraphics[height=2.5cm]{qrEvent_en}}; + } \end{tikzpicture}% \obeylines% -{\addfontfeatures{Scale=2.8,LetterSpace=9} INVITATION} +{\addfontfeatures{Scale=2.8,LetterSpace=9,Color=red} + \iftoggle{Vietnamese}{ THIỆP MỜI }{ INVITATION }} \bigbreak \textit{% - Dear friend, + \iftoggle{Vietnamese}{ + Trân trọng kính mời bạn - We'd love to invite you to our wedding reception. + dự tiệc cưới của chúng tôi, - Sincerly, + Nam và Hương. + }{ + Dear friend, - Nam and Huong + We'd love to invite you to our wedding reception. + + Sincerly, + + Nam and Huong. + } } \vfill -{\addfontfeatures{Scale=1.4,LetterSpace=5}\scshape when?} -\textit{% - March 1\/\rlap{,}\textsuperscript{st} 2020 - 4\kern.5pt:\kern.5pt00 pm -} -\medbreak -{\addfontfeatures{Scale=1.4,LetterSpace=5}\scshape where?} -\textit{% - Auco Convention Center, + \iftoggle{Vietnamese}{ + {\addfontfeatures{Scale=1.4,LetterSpace=5,Color=red}\scshape Bao giờ?} + \textit{% + Chủ Nhật, ngày 1, tháng 3, năm 2020 + 4\kern.5pt:\kern.5pt00 chiều + } + \medbreak + {\addfontfeatures{Scale=1.4,LetterSpace=5,Color=red}\scshape Ở đâu?} + \textit{% + Trung tâm nhà hàng tiệc cưới Âu Cơ, - 1A Nguyen Huu Cau Str, Ngoc Chau Ward + 1A Nguyễn Hữu Cầu, Phường Ngọc Châu, - Hai Duong City, Hai Duong -} + Thành phố Hải Dương, Hải Dương + } + }{ + {\addfontfeatures{Scale=1.4,LetterSpace=5,Color=red}\scshape when?} + \textit{% + March 1\/\rlap{,}\textsuperscript{st} 2020 + 4\kern.5pt:\kern.5pt00 pm + } + \medbreak + {\addfontfeatures{Scale=1.4,LetterSpace=5,Color=red}\scshape where?} + \textit{% + Auco Convention Center, + + 1A Nguyen Huu Cau Str, Ngoc Chau Ward + + Hai Duong City, Hai Duong + } + } \end{document}