I understand that this post may cause some down votes because it seems a bit off-topic, but having seen the discussions on Christmas Tree with LaTeX I am still willing to try.
How do you draw a red cute love heart using LaTeX?
animationsdiagramsfuntikz-pgf
I understand that this post may cause some down votes because it seems a bit off-topic, but having seen the discussions on Christmas Tree with LaTeX I am still willing to try.
How do you draw a red cute love heart using LaTeX?
Here is a small bag of tips and tricks that I use to improve the handling and presentation of images in publications, which I want to share with you.
Use non-floating images
Most people think that the only way to insert an image in a publication is by using the LaTeX environment \begin{figure}...\end{figure}
. This has many advantages but also many disadvantages. Inserting images directly into the text i.e., by using the macro \includegraphics[]{}
gives you full control, but also full responsibility for the layout.
Enclose them in minipages
It is better to use an approach similar to HTML/CSS and use divs to enclose these, except these boxes are now minipages. You can the resize them to suit the layout as well as move them in any direction using vskip and hskip or the LaTeX equivalent of hspace and vspace. All the page layouts shown here were achieved using such an approach.
Use \newgeometry
and \restoregeometry
.
Sometimes it is much easier to adjust a layout by simply using the geometry package's new commands, \newgeometry and \restoregeometry.
Create a TeX Database
Another useful technique is to store all the images in a TeX database. This is not as complicated as it sounds. Remember that any macro actually can be used to store information. What I do is something resembling the following:
Create variations of commands using \csname..endcsname
holding the data for each image.
\mypics@img1@caption
\mypics@img1@longdescription
\mypics@img1@date
These are created automatically via a command \addtoDB{}{}{}
or similar. This also adds the original name into a list, which acts as the index.
\mypictures{img1,img2,img3,img4}
This enable easy use of multiple images, in a @for
loop. This is how the images above were inserted. The techniques can be used for almost everything, for example see some of the code at Cunning (La)TeX tricks and Adding a list of bios to the book class.
Keep the main file code to a minimal by leverage the filecontents package.
While developing pages, if you write everything in one file the code becomes bloated and confusing. What I do is to develop the page, first in the main file and then to use filecontents
to write it to the file. I then delete the relevant section and use \input
to load it onto the main file. I find it easier than opening and closing too many windows. I also use this to develop small packages, have the code first in the preamble, test as you go and when I am happy delete the filecontents
. An example of how to use this can be found at
internationalization. In What is a good strategy to internationalize a document class?, I used this technique to create a package-on-the-fly for whoever was to use the MWE.
Captions
Use a bit of innovation for these layouts see for example the images below which have a three column caption. (I use the caption
package for numbering).
I am currently incorporating all these into a class. Unfortunately the code is too lengthy to post here and also the class is not in a shape that I would feel comfortable to upload it to ctan
yet. With LaTeX's 3 coffins, I think I can also leverage the layouts a bit more and publish it sometimes over the next few months.
In the meantime if you need any help to incorporate these suggestions with what you are busy with, post a question and I can extract some of the code to help you out.
Not only for Modern books
The last example is from mathematics, from Newton's Principia. The left figure below shows my attempt using LaTeX and a bit of modern approach. The image on the right below is a scan of the original page. This was achieved using wrapfig
and a minimum of manual adjustment, just a negative vskip
a few points up to position the image better.
All the tools are here, go and make great books. thanks for reading this far.
Here is my start:
\documentclass[x11names]{beamer}
\usepackage{lmodern}
\usepackage{tikzorbital}
\usetikzlibrary{backgrounds,
lindenmayersystems,
decorations.pathmorphing,
decorations.markings,
shapes.geometric,
calc,
shapes.symbols,
}
\pgfdeclarelayer{endroom}
\pgfdeclarelayer{window}
\pgfdeclarelayer{back window}
\pgfsetlayers{endroom,back window,window,background,main}
\setbeamertemplate{navigation symbols}{}
\setlength{\textwidth}{\paperwidth}
\setlength{\textheight}{\paperheight}
% original code by percusse:
% http://tex.stackexchange.com/questions/39296/simulating-hand-drawn-lines#49961
\makeatletter
\pgfdeclaredecoration{penciline}{initial}{
\state{initial}[width=+\pgfdecoratedinputsegmentremainingdistance,auto corner on length=3mm,]{
\pgfpathcurveto%
{% From
\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}
{\pgfdecorationsegmentamplitude}
}
{% Control 1
\pgfmathrand
\pgfpointadd{\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}{0pt}}
{\pgfqpoint{-\pgfdecorationsegmentaspect\pgfdecoratedinputsegmentremainingdistance}%
{\pgfmathresult\pgfdecorationsegmentamplitude}
}
}
{%TO
\pgfpointadd{\pgfpointdecoratedinputsegmentlast}{\pgfpoint{1pt}{1pt}}
}
}
\state{final}{}
}
\tikzset{pencil decoration/.style={decorate, decoration=penciline}}
\tikzset{fine random decoration/.style=decorate,decoration={random steps,segment length=0.8pt,amplitude=0.125pt}}
\pgfdeclareradialshading[tikz@ball]{bauble}{\pgfpoint{-0.275cm}{0.4cm}}{%
rgb(0cm)=(1,1,1);
color(0.4cm)=(tikz@ball!70!white);
color(0.6cm)=(tikz@ball);
color(0.8cm)=(tikz@ball!60!black);
rgb(1cm)=(1,1,1)
}
\tikzoption{bauble color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{bauble}\tikz@addmode{\tikz@mode@shadetrue}}
\pgfdeclareradialshading[tikz@ball]{bauble off}{\pgfpoint{-0.275cm}{0.4cm}}{%
rgb(0cm)=(1,1,1);
color(0.185cm)=(tikz@ball!35!black);
color(0.8cm)=(tikz@ball!80!black);
rgb(1cm)=(1,1,1)
}
\tikzoption{bauble off color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{bauble off}\tikz@addmode{\tikz@mode@shadetrue}}
\makeatother
% original code by Daniel:
% http://tex.stackexchange.com/questions/55806/tikzpicture-in-beamer#55849
\tikzset{
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
},
}
% original code in
% http://tex.stackexchange.com/questions/84513/highlighting-in-beamer-using-tikz-nodes#84608
\tikzset{
background shade/.style={#1},
shade on/.style={alt=#1{}{background shade}},
}
\tikzset{snow/.style={
starburst, random starburst=#1,
inner sep=2.5pt,scale=0.15,
background shade={inner color=Snow3, outer color= Snow2},
}
}
% original code by Andrew Stacey:
% http://tex.stackexchange.com/questions/39149/how-can-we-draw-a-christmas-tree-with-decorations-using-tikz#39209
\tikzset{
tinsel/.style={
#1,
rounded corners=10mm,
ultra thin,
decorate,
decoration={
snake,
amplitude=.1mm,
segment length=10,
}
},
baubles/.style={
decorate,
decoration={
markings,
mark=between positions .3 and 1 step 2cm
with
{
\pgfmathsetmacro{\brad}{1.5 + .5 * rand}
\tikzset{background shade/.default={shading=bauble off,bauble off color=#1}}
\path[background shade={shading=bauble,bauble color=#1},shade on=<{2,4}>](0,0) circle[radius=\brad mm];
}
}
},
lights/.style={
decorate,
decoration={
markings,
mark=between positions 0 and 1 step 1cm
with
{
\pgfmathsetseed{12345}
\pgfmathparse{rand > 0 ? "dart" : "kite"}
\let\lshape\pgfmathresult
\pgfmathsetmacro{\tint}{100*rnd}
\tikzset{background shade/.default={shading=bauble off,bauble off color=red!\tint!orange}}
\node[rotate=90,\lshape,inner sep=1pt,
background shade={shading=bauble,bauble color=red!\tint!yellow},
shade on=<{1,3,5}>] {};
}
}
}
}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\useasboundingbox(0.25,0.25) rectangle (12,9.25);
\begin{pgfonlayer}{endroom}
\draw[very thin] (-0.5,0)--(2,1.25)--(9,1.25)--(11.75,0);
\draw[very thin] (-0.5,9.25)--(2,8.25)--(9,8.25)--(11.75,9.25);
\draw[very thin] (2,1.25)--(2,8.25);
\draw[very thin] (9,1.25)--(9,8.25);
\end{pgfonlayer}
% tree base coordinate
\coordinate (star) at (12,8.75);
% window
\begin{scope}
\pgfmathsetseed{123456}
\begin{pgfonlayer}{back window}
% outer
\draw[pencil decoration,fill=LightSalmon3!80] (2.75,5)node[inner sep=0pt](outer below left){}
--(2.75,7)node[inner sep=0pt](outer above left){}
--(5,7)node[inner sep=0pt](outer above right){}
-- (5,5)node[inner sep=0pt](outer below right){}
--cycle;
% inner
\draw[pencil decoration,top color=Blue3, bottom color=Blue3!30, shading angle=35] (2.95,5.2)node[inner sep=0pt](inner below left){}
--(2.95,6.8)node[inner sep=0pt](inner above left){}
--(4.8,6.8)node[inner sep=0pt](inner above right){}
--(4.8,5.2)node[inner sep=0pt](inner below right){}
--cycle;
\end{pgfonlayer}
\begin{pgfonlayer}{window}
\draw[pencil decoration,fill=LightSalmon3!80]
($(inner above left)!0.45!(inner above right)+(0,0.05)$)node[inner sep=0pt](internal above left){}
--($(inner below left)!0.45!(inner below right)-(0,0.02)$)node[inner sep=0pt](internal below left){}
--($(inner below left)!0.55!(inner below right)-(0,0.05)$)node[inner sep=0pt](internal below right){}
--($(inner above left)!0.55!(inner above right)+(0,0.03)$)node[inner sep=0pt](internal above right){}
--cycle;
\node[inner sep=0pt](opening) at ($(internal below left)!0.5!(internal above left)+(0.1,0)$){};
\orbital[pcolor=Goldenrod2, ncolor=Goldenrod2,scale=0.25,pos = {(opening)}]{pz}
\draw[radius=0.75bp, fill=Goldenrod2] (opening) circle ;
\end{pgfonlayer}
% SNOW
\coordinate (inner middle left) at ($(inner above left)!0.5!(inner below left)$);
\coordinate (inner middle right) at ($(inner above right)!0.5!(inner below right)$);
\coordinate (inner semi-middle right) at ($(inner above right)!0.3!(inner below right)$);
\coordinate (inner semi-middle left) at ($(inner above left)!0.3!(inner below left)$);
\coordinate (middle above left) at ($(inner above left)!0.5!(internal above left)$);
\coordinate (middle above right) at ($(inner above right)!0.5!(internal above right)$);
\coordinate (middle center left) at ($(inner middle left)!0.5!(opening)$);
\coordinate (middle center right) at ($(inner middle right)!0.5!(opening)$);
\coordinate (middle below left) at ($(inner below left)!0.5!(internal below left)$);
\coordinate (middle below right) at ($(inner below right)!0.5!(internal below right)$);
\foreach \xstep/\ystep/\sequence in {0.1/0.12/{1,2,4},0.2/0.2/{2,4,5},0.35/0.475/{1,3,5},0.575/0.7/{2,3,4}}{,
\tikzset{
background shade/.default={inner color=Snow1, outer color= Snow1!50}
}
\pgfmathrandom{200}
\pgfmathtruncatemacro\rndstartburst\pgfmathresult
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(inner above right)!\xstep!(internal above right)!\ystep!(opening)+(-0.075*rnd,-0.1*rnd)$) {};
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(inner above right)!\xstep!(internal above right)!\ystep!(opening)+(0.3*rnd,-0.3*rnd)$) {};
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(internal above left)!\xstep!(inner above left)!\ystep!(inner middle left)+(-0.05*rnd,-0.2*rnd)$) {};
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(internal above left)!\xstep!(inner above left)!\ystep!(inner middle left)+(0.4*rnd,-0.375*rnd)$) {};
}
\foreach \xstep/\ystep/\sequence in {0.05/0.075/{2,3,5},0.2/0.215/{1,2,3,4},0.275/0.325/{1,4},0.45/0.55/{2,3,5}}{
\tikzset{
background shade/.default={inner color=Snow1, outer color= Snow1!50}
}
\pgfmathrandom{200}
\pgfmathtruncatemacro\rndstartburst\pgfmathresult
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(middle above right)!\xstep!(internal above right)!\ystep!(opening)+(-0.1*rnd,-0.025*rnd)$) {};
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(middle above left)!\xstep!(inner above left)!\ystep!(inner middle left)+(-0.1*rnd,0.05*rnd)$) {};
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(opening)!\xstep!(middle center left)!\ystep!(inner below left)+(-0.35*rnd,-0.05*rnd)$) {};
}
\foreach \xstep/\ystep/\sequence in {0.1/0.12/{1,2,5},0.2/0.2/{2,3,5},0.35/0.475/{1,3,4},0.575/0.7/{2,4}}{,
\tikzset{
background shade/.default={inner color=Snow1, outer color= Snow1!50}
}
\pgfmathrandom{200}
\pgfmathtruncatemacro\rndstartburst\pgfmathresult
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(inner semi-middle right)!\xstep!(opening)!\ystep!(middle below right)+(-0.075*rnd,0.1*rnd)$) {};
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(inner semi-middle right)!\xstep!(opening)!\ystep!(middle below right)+(0.2*rnd,-0.2*rnd)$) {};
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(middle center right)!\xstep!(opening)!\ystep!(internal below right)+(0.1*rnd,-0.1*rnd)$) {};
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(opening)!\xstep!(middle center left)!\ystep!(inner below left)+(0.125*rnd,-0.25*rnd)$) {};
}
\foreach \xstep/\ystep/\sequence in {0.2/0.15/{1,3,5},0.225/0.35/{2,4},0.35/0.475/{1,2,3,5},0.6/0.7/{1,2,4}}{,
\tikzset{
background shade/.default={inner color=Snow1, outer color= Snow1!50}
}
\pgfmathrandom{200}
\pgfmathtruncatemacro\rndstartburst\pgfmathresult
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(opening)!\xstep!(middle center left)!\ystep!(inner below left)+(0.1*rnd,-0.2*rnd)$) {};
\node[snow=\rndstartburst,shade on=<{\sequence}>]
at ($(middle center left)!\xstep!(inner middle left)!\ystep!(inner below left)+(0.1*rnd,0.35*rnd)$) {};
}
\node[snow=10,shade on=<{2,3,4}>]
at ($(inner middle left)!0.8!(opening)!0.25!(internal above left)$) {};
\node[snow=10,shade on=<{1,4}>]
at ($(inner middle left)!0.4!(opening)!0.8!(internal below left)$) {};
\end{scope}
\end{tikzpicture}
%% Christmas tree
\scalebox{0.65}{
\begin{tikzpicture}[overlay,remember picture]
\path (star) +(-50:7) coordinate (rhs) +(-130:7) coordinate (lhs);
\draw[brown!50!black,line width=5mm,line cap=round] (star) ++(-90:6.8) -- ++(0,-1) coordinate (base);
\node[scale=-1,trapezium,fill=black,minimum size=1cm] at (base) {};
\foreach \height/\colour in {%
.2/blue,
.4/yellow,
.6/red,
.8/orange,
1/pink%
} {
\draw[tinsel=\colour] ($(star)!\height!(lhs)$) to[bend right] ($(star)!\height!(rhs)$);
}
\path (star);
\pgfgetlastxy{\starx}{\stary}
\begin{scope}[xshift=\starx,yshift=\stary,yshift=-7cm]
\draw[color=green!50!black, l-system={rule set={S -> [+++G][---G]TS, G -> +H[-G]L, H -> -G[+H]L, T -> TL, L -> [-FFF][+FFF]F}, step=4pt, angle=18, axiom=+++++SLFFF, order=11}] lindenmayer system -- cycle;
\end{scope}
\foreach \height/\colour in {%
.1/pink,
.3/red,
.5/yellow,
.7/blue,
.9/orange%
} {
\draw[tinsel=\colour] ($(star)!\height!(lhs)$) to[bend right] ($(star)!\height!(rhs)$);
}
\foreach \height in {.15,.35,...,1} {
\draw[lights] ($(star)!\height!(lhs)$) to[bend right] ($(star)!\height!(rhs)$);
}
\foreach \angle/\colour in {
-50/red,
-70/yellow,
-90/blue,
-110/Green2,
-130/MediumOrchid1%
} {
\draw[baubles=\colour] (star) -- ++(\angle:7);
}
\node[star,star point ratio=2.5,fill=yellow,minimum size=1cm] at (star) {};
\end{tikzpicture}
}
\end{frame}
\end{document}
A Christmas wreath:
\documentclass[x11names]{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{lindenmayersystems,positioning,decorations.text}
\setbeamertemplate{navigation symbols}{}
\makeatletter
\pgfdeclareradialshading[tikz@ball]{bauble}{\pgfpoint{-0.275cm}{0.4cm}}{%
rgb(0cm)=(1,1,1);
color(0.4cm)=(tikz@ball!70!white);
color(0.6cm)=(tikz@ball);
color(0.8cm)=(tikz@ball!60!black);
rgb(1cm)=(1,1,1)
}
\tikzoption{bauble color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{bauble}\tikz@addmode{\tikz@mode@shadetrue}}
\pgfdeclareradialshading[tikz@ball]{bauble off}{\pgfpoint{-0.275cm}{0.4cm}}{%
rgb(0cm)=(1,1,1);
color(0.185cm)=(tikz@ball!35!black);
color(0.8cm)=(tikz@ball!80!black);
rgb(1cm)=(1,1,1)
}
\tikzoption{bauble off color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{bauble off}\tikz@addmode{\tikz@mode@shadetrue}}
\makeatother
% original code by Daniel:
% http://tex.stackexchange.com/questions/55806/tikzpicture-in-beamer#55849
\tikzset{
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
},
}
% original code in
% http://tex.stackexchange.com/questions/84513/highlighting-in-beamer-using-tikz-nodes#84608
\tikzset{
background shade/.style={#1},
shade on/.style={alt=#1{}{background shade}},
}
\tikzset{
background text/.style={text=#1},
background text/.default={red},
text on/.style={alt=#1{}{background text}},
}
\tikzset{background shade/.default={
shading=bauble off,
bauble off color=red
},
bauble size/.style={
circle,
inner sep=3pt,
}
}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\draw [green!60!black,rotate=90] l-system
[l-system={rule set={F -> F[+FF]F[-FF] ->F[+FF]F[-FF]}, axiom=F, order=4, angle=15,step=4pt}];
\node[background text={green!50!black},text on=<{2,4,5,7,9,10}>,scale=1.1](m) at ([xshift=1cm,yshift=2cm]0,0){Merry};
\node[text=Yellow2,scale=1.17] at ([xshift=1cm,yshift=2cm]0,0){Merry};
\node[background text={green!50!black},text on=<{2,4,5,7,9,10}>,scale=1.1] at ([xshift=1cm,yshift=2cm]0,-0.2){Christmas};
\node[text=Yellow2,scale=1.17]at([xshift=1cm,yshift=2cm]0,-0.2){Christmas};
\foreach \pos/\initlight in {{(-0.35,1)}/{1,2,3},{(1,-1.5)}/{2,3},{(2.35,1)}/{1,3}}{
\node[bauble size,background shade={shading=bauble,bauble color=red},shade on=<{\initlight,4,5,7,10}>](node1)
at \pos {};
\node[below=-0.05cm,bauble size,background shade={shading=bauble,bauble color=red},shade on=<{\initlight,6,7,9}>](node2)
at (node1.south west) {};
\node[below=-0.05cm,bauble size,background shade={shading=bauble,bauble color=red},shade on=<{\initlight,4,6,8,10}>](node3)
at (node1.south east) {};
}
\foreach \pos/\initlight in {{(-0.6,-0.5)}/{1,2},{(2.6,-0.5)}/{1,2}}{
\node[bauble size,background shade={shading=bauble,bauble color=red},shade on=<{\initlight,4,6,7,9}>](node1)
at \pos {};
\node[below=-0.05cm,bauble size,background shade={shading=bauble,bauble color=red},shade on=<{\initlight,5,8,10}>](node2)
at (node1.south west) {};
\node[below=-0.05cm,bauble size,background shade={shading=bauble,bauble color=red},shade on=<{\initlight,4,5,7,8,9}>](node3)
at (node1.south east) {};
}
\end{tikzpicture}
\end{frame}
\end{document}
Best Answer
Use
shapepar
to write your note:The longer your note, and the shorter or more “hyphenatable” your words toward the end of the note, the more likely it is that
shapepar
will produce a pleasing shape, without rivers or the underfull lines seen in my image; I recommendmicrotype
for the same reason.