Layout business cards in LaTeX
Good day!
On habré already many articles about how and where to apply typesetting in LaTeX. From standard scientific articles and presentations to calendars and summaries.
The main advantage of LaTeX initially was freeing the writer from having to think about the layout of the text on the page: the author writes the content, and the engine puts everything in the right places.
Hence the irresistible urgestart to drill with a saw and to saw with a gimlet to solve using LaTeX a task that requires full control of the layout of the text on the page. The classic example is the layout of the cards, which we are going to do.
Outset that the design we do will not — someone has already chosen for us, all margins, fonts, interlinear, etc., etc., We just bring it to TK in the LaTeX template.
Assume that TK is as follows:
the
So there you go. First you need to choose the compiler: latex and pdflatex (actually, in a sense, are one and the same, but for this article it doesn't matter) we don't need, because it is very, very bad digest non-native fonts. If someone wants to make friends with pdflatex, and, say, the Myriad font, the number of gestures will pass all reasonable limits. XeLaTeX is able to work with any Unicode fonts, and understands, and most of us do not have.
the
The document type we are, in principle, unimportant, anyway, we're going to place elements on the page to bypass standard mechanisms. The fontspec package we need for correct work with otf fonts and it also allows you to easily adjust the font size and leading (more on this below).
The following item: how to solve the issue with the size of the page. Here comes the geometry package, which is perfectly copes with it.
the
Finally, a key subproblem: how to control the position of text blocks on the page, in particular, the indents from the field. For this we will use the package textpos:
the
Package connected with option absolute, that is, the positioning of the blocks will be in absolute units.
Else would we use the package adjustbox is one of the ways to control the position of symbols (and in General the so-called boxed content):
the
We use the option export to standard commands of the package extended to \includegraphics.
Finally, the package xcolor because we want to enter their own color.
Now let's configure all the packages:
the
Here, as you might guess, we set the paper size, the size of the space where we will place the text, and fields.
We define the primary color of the text, and define macros for phone numbers and addresses
the
And the command
If we want to insert logos and/or pictures on our card, the best option would be to use a vector format. Let these files are called, respectively, LogoUni.eps and LogoLab.eps. We arrange them next to our main file. In General, xelatex is able to work out of the box with many image formats (unfortunately, svg to this list does not apply).
You can start to implement requirements in life:
the
Have the logo of our University so that the upper left corner of the image had the coordinates (4.2 mm, 4.2 mm) and the height of the logo is 20.6 mm. we will use For this environment:
the
Decoding is quite simple: a text block the width should be positioned so that the point on the sheet with absolute coordinates (xcoord,ycoord) were dot block with relative coordinates [a,b], which vary from zero to unity. If a=0, b=0, then we have the upper left corner, if a=1,b=0, then the upper right, if a=1,b=1, then bottom right, and if a=0.5, b=0.5 — the center of our text block.
To adjust the height of the image, just use the standard method of \includegraphics:
the
The command \noindent is needed that the engine did not put the red line and did not spoil the indentation. Also note that the % signs at the end of each line — comments in TeX — here essentially as an ordinary hyphens are treated as spaces, and can damage the layout.
Analogichnym way do lab's logo: available upper right corner of the logo at the specified coordinates.
the
The right option in the \includegraphics aligns the image right-aligned text.
Then position the text block with your name and post right under the picture logo, left indent — 24.8 mm (height of the picture plus the indent of the image):
the
The command \setmainfont sets the font family for the main text (more details can be found in the documentation for the fontspec package) and \fontsize{x}{y} defines the font size of the x and y spacing. The command \selectfont applies the changes introduced fontsize. The last command \\* makes the soft hyphen and not start a new paragraph.
Finally, the last block of text with the phone number and address of the laboratory position with the same indentation 18.5 mm so that the bottom margin was 4.2 mm
the
If we want to make the reverse side of business cards or make a few business cards in one file, then the regular commands start a new page (\pagebreak, \newpage, \clearpage, \cleardoublepage, etc.) just don't work. Plain text on the page after all, so the engine believes that to start a new page is not necessary. It costs all of the following:
the
Already rolled add a picture with the logo, have the center of the text block centered on the paper:
the
Logos I for this article he sketched in Inkscape, colors and fonts picked "just was", so that the aesthetic component will not vouch.
The final front and the reverse side:
Documentation links to used packages:
adjustbox
geometry
textpos
xcolor
Article based on information from habrahabr.ru
On habré already many articles about how and where to apply typesetting in LaTeX. From standard scientific articles and presentations to calendars and summaries.
The main advantage of LaTeX initially was freeing the writer from having to think about the layout of the text on the page: the author writes the content, and the engine puts everything in the right places.
Hence the irresistible urge
Outset that the design we do will not — someone has already chosen for us, all margins, fonts, interlinear, etc., etc., We just bring it to TK in the LaTeX template.
Assume that TK is as follows:
the
- Logo lab: image height of 20.6 mm, the upper-right corner is separated from the right
the upper corner of the card by 4.2 mm on both coordinates
the - text Color in RGB: (00,62,92) the
- background Color — the text color is diluted with white at 50% (or RGB (00,31,46)) the
- Text with first and last name typed in Arial: size 12, line spacing of 14.4. Located immediately below the logos, indent 18.5 mm, right field — 4.2 mm.
Underneath on a new line the text with the position, Arial, size 7, the spacing is 7.5
the - Text with the name of the laboratory, phone number and address: Consolas, size 5.5, the spacing of 7.5. The left margin of 18.5 mm, bottom margin is 4.2 mm, right field — 4.2 mm
the Logo of the University: the image height of 20.6 mm, the upper left corner is from the upper left corner of the card by 4.2 mm on both coordinates
the
on the flip side of business cards: the logo of the University on full-width, centered vertically and horizontally
So there you go. First you need to choose the compiler: latex and pdflatex (actually, in a sense, are one and the same, but for this article it doesn't matter) we don't need, because it is very, very bad digest non-native fonts. If someone wants to make friends with pdflatex, and, say, the Myriad font, the number of gestures will pass all reasonable limits. XeLaTeX is able to work with any Unicode fonts, and understands, and most of us do not have.
the
\documentclass{article}
\usepackage{fontspec}
The document type we are, in principle, unimportant, anyway, we're going to place elements on the page to bypass standard mechanisms. The fontspec package we need for correct work with otf fonts and it also allows you to easily adjust the font size and leading (more on this below).
The following item: how to solve the issue with the size of the page. Here comes the geometry package, which is perfectly copes with it.
the
\usepackage{geometry}
Finally, a key subproblem: how to control the position of text blocks on the page, in particular, the indents from the field. For this we will use the package textpos:
the
\usepackage[absolute]{textpos}
Package connected with option absolute, that is, the positioning of the blocks will be in absolute units.
Else would we use the package adjustbox is one of the ways to control the position of symbols (and in General the so-called boxed content):
the
\usepackage[export]{adjustpage}
We use the option export to standard commands of the package extended to \includegraphics.
Finally, the package xcolor because we want to enter their own color.
\usepackage{xcolor}
Now let's configure all the packages:
the
\geometry{paperwidth=85mm, paperheight=55mm, layoutwidth=85mm, layoutheight=55mm, left=0mm, top=0mm, right=0mm, bottom=0mm}
Here, as you might guess, we set the paper size, the size of the space where we will place the text, and fields.
We define the primary color of the text, and define macros for phone numbers and addresses
the
\definecolor{bl}{RGB}{0,62,92}
\newcommand{\phonei}{T. +7~XXX~XXX~XX~XX - M. +7~XXX~XXX~XX~XX}
\newcommand{\emaili}{you@domain.somewhere}
\newcommand{\firstlineaddress}{Name of your Lab}
\newcommand{\secondlineaddress}{1, Nameless street\\* 123456, In The Middle of Nowhere, Earth}
And the command
\pagecolor{bl!50!white}
sets the background color of diluting the already known color "bl", white 50%.If we want to insert logos and/or pictures on our card, the best option would be to use a vector format. Let these files are called, respectively, LogoUni.eps and LogoLab.eps. We arrange them next to our main file. In General, xelatex is able to work out of the box with many image formats (unfortunately, svg to this list does not apply).
You can start to implement requirements in life:
the
\begin{document}%
Have the logo of our University so that the upper left corner of the image had the coordinates (4.2 mm, 4.2 mm) and the height of the logo is 20.6 mm. we will use For this environment:
the
\begin{textblock*}{width}[a,b](xcoord,ycoord)
\end{textblock*}
Decoding is quite simple: a text block the width should be positioned so that the point on the sheet with absolute coordinates (xcoord,ycoord) were dot block with relative coordinates [a,b], which vary from zero to unity. If a=0, b=0, then we have the upper left corner, if a=1,b=0, then the upper right, if a=1,b=1, then bottom right, and if a=0.5, b=0.5 — the center of our text block.
To adjust the height of the image, just use the standard method of \includegraphics:
the
\begin{textblock*}{50mm}[0,0](4.2 mm,4.2 mm)%
\noindent%
\includegraphics[height=20.6 mm]{LogoUni.eps}%
\end{textblock*}
The command \noindent is needed that the engine did not put the red line and did not spoil the indentation. Also note that the % signs at the end of each line — comments in TeX — here essentially as an ordinary hyphens are treated as spaces, and can damage the layout.
Analogichnym way do lab's logo: available upper right corner of the logo at the specified coordinates.
the
\begin{textblock*}{20mm}[1,0](80.8 mm,4.2 mm)%
\noindent%
\includegraphics[height=20mm, right]{LogoLab.png}%
\end{textblock*}
The right option in the \includegraphics aligns the image right-aligned text.
Then position the text block with your name and post right under the picture logo, left indent — 24.8 mm (height of the picture plus the indent of the image):
the
\setmainfont{Arial}%
\fontsize{12}{14.4}\selectfont%
\begin{textblock*}{62.3 mm}[0,0](18.5 mm,24.8 mm)%
{\color{bl}%
\noindent\namei\\*%
\fontsize{7}{7.5}\selectfont%
\posi%
}\end{textblock*}%
The command \setmainfont sets the font family for the main text (more details can be found in the documentation for the fontspec package) and \fontsize{x}{y} defines the font size of the x and y spacing. The command \selectfont applies the changes introduced fontsize. The last command \\* makes the soft hyphen and not start a new paragraph.
Finally, the last block of text with the phone number and address of the laboratory position with the same indentation 18.5 mm so that the bottom margin was 4.2 mm
the
\setmainfont{Consolas}%
\fontsize{5.5}{7.5}\selectfont%
\begin{textblock*}{62.3 mm}[0,1](18.5 mm,50.8 mm)
{\color{bl}%
\noindent\firstlineaddress\\*%
\secondlineaddress\\*%
\phonei\\%
E. \emaili}\end{textblock*}%
If we want to make the reverse side of business cards or make a few business cards in one file, then the regular commands start a new page (\pagebreak, \newpage, \clearpage, \cleardoublepage, etc.) just don't work. Plain text on the page after all, so the engine believes that to start a new page is not necessary. It costs all of the following:
the
\null\newpage%
Already rolled add a picture with the logo, have the center of the text block centered on the paper:
the
\begin{textblock*}{85mm}[0.5,0.5](42.5 mm,27.5 mm)%
\noindent%
\includegraphics[width=85mm]%
{LogoUni.eps}%
\end{textblock*}%
\end{document}
Outcome:
\documentclass{article}
\usepackage{fontspec}
\usepackage{geometry}
\usepackage{xcolor}
\usepackage[export]{adjustbox}
\usepackage[absolute]{textpos}
\usepackage{tikz}
\geometry{paperwidth=85mm, paperheight=55mm, layoutwidth=85mm, layoutheight=55mm, left=0mm, top=0mm, right=0mm, bottom=0mm}
\definecolor{bl}{RGB}{0,62,92}
\newcommand{\phonei}{T. +7~XXX~XXX~XX~XX - M. +7~XXX~XXX~XX~XX}%
\newcommand{\namei}{Name Surname}
\newcommand{\posi}{Position}
\newcommand{\emaili}{E. you@yourdomain.somewhere}
\newcommand{\urli}{yourdomain.somewhere}
\newcommand{\secondlineaddress}{1, Nameless street\\* 123456, In The Middle of Nowhere, Earth}
\pagecolor{bl!50!white}
\begin{document}%
\begin{textblock*}{50mm}[0,0](4.2 mm,4.2 mm)%
\noindent%
\includegraphics[height=20.6 mm]{LogoUni.eps}%
\end{textblock*}%
\begin{textblock*}{50mm}[1,0](80.8 mm,4.2 mm)%
\noindent%
\includegraphics[height=20.6 mm,right]{LogoLab.eps}%
\end{textblock*}%
%
\setmainfont{Arial}%
\fontsize{12}{14.4}\selectfont%
\begin{textblock*}{62.3 mm}[0,0](18.5 mm,24.8 mm){\color{bl}\noindent\namei\\*%
\setmainfont{Arial}%
\fontsize{7}{7.5}\selectfont%
\posi%
}\end{textblock*}%
\setmainfont{Consolas}%
\fontsize{5.5}{7.5}\selectfont%
\begin{textblock*}{62.3 mm}[0,1](18.5 mm,50.8 mm){\color{bl}\noindent\firstlineaddress\\*%
\secondlineaddress\\*%
\phonei\\%
\emaili}\end{textblock*}%
\null\newpage%
\begin{textblock*}{85mm}[0.5,0.5](42.5 mm,27.5 mm)%
\noindent%
\includegraphics[width=85mm]
{LogoUni.eps}%
\end{textblock*}%
\end{document}
Logos I for this article he sketched in Inkscape, colors and fonts picked "just was", so that the aesthetic component will not vouch.
The final front and the reverse side:
Documentation links to used packages:
adjustbox
geometry
textpos
xcolor