I have difficulty in the use of tikz package. I want to be like the output below. Please heip me! Thank you very much!
Asked
Active
Viewed 725 times
2
2 Answers
7
First of all, read tutorial 1 in pgfmanual. After that you will understand how to draw this simple graphic.
Second, take a look at tcolorbox documentation and you'll see how to format this kind of boxes.
After that, try to understand following code and you'll be able to adapt it to your needs:
\documentclass[twocolumn]{article}
\usepackage[most]{tcolorbox}
\usetikzlibrary{arrows.meta}
\usepackage{lipsum}
\newtcolorbox{boxone}{%
enhanced,
colback=brown!10,
boxrule=0pt,
sharp corners,
frame hidden,
fontupper=\bfseries,
notitle,
overlay={%
\draw[Circle-Circle, brown!70!black, line width=2pt](frame.north west)--(frame.south west);
\draw[Circle-Circle, brown!70!black, line width=2pt](frame.north east)--(frame.south east);}
}
\newtcolorbox{boxtwo}{%
enhanced,
%frame style={draw=none},
colback=orange!20,
boxrule=0pt,
sharp corners,
frame hidden,
notitle,
overlay={%
\draw[{Triangle[right]}-{Triangle[left]}, , line width=2pt](frame.north west)--(frame.north east);
\draw[{Triangle[left]}-{Triangle[right]}, , line width=2pt](frame.south west)--(frame.south east);}
}
\newtcolorbox{boxthree}[2][]{%
enhanced,
%frame style={draw=none},
colback=orange!10,
colbacktitle=orange!10,
boxrule=0pt,
fonttitle=\Large\bfseries,
coltitle=brown!30!black,
sharp corners,
frame hidden,
title=#2,
overlay={%
\draw[thick, brown!70!black, double=orange, double distance=2pt] (frame.north west)--(frame.north east);
\draw[thick, brown!70!black, double=orange, double distance=2pt] (frame.south west)--(frame.south east);
\fill[red!50!brown] ([shift={(3mm,.5mm)}]title.south west)--([shift={(-3mm,0mm)}]title.south east)--([shift={(3mm,-.5mm)}]title.south west)--cycle;}
}
\begin{document}
\begin{boxone}
\lipsum[1]
\end{boxone}
\begin{boxtwo}
\lipsum[3]
\end{boxtwo}
\begin{boxthree}{Nice maths}
\[\sin^2 x + \cos^2 = 1\]
\end{boxthree}
{\par\centering
\begin{tikzpicture}
\draw[help lines, dotted] (0,0) grid (7,4);
\draw[cyan] (1,1) node[below left, black] {$B$}--node[above left]{$c$} (2,3) node[above, black]{$A$}--node[above right]{$b$} (6,1) node[below right, black]{$C$}--node[below]{$c'$}(2,1) node[below,black]{$H$}--node[below]{$b'$}(1,1)--cycle;
\draw[violet] (2,1)--node[right]{$h$}(2,3);
\draw[violet] (2,1.2)-|(2.2,1);
\draw[thin] (1,.9)--++(-90:.8) (6,.9)--++(-90:.8);
\draw[LaTeX-LaTeX] (1,.3)-- node[fill=white]{$a$}(6,.3);
\end{tikzpicture}
\par}
\end{document}
Ignasi
- 136,588
-
The above code generates the error:
''pgfkeys Erros:I do not know the key '/tcb/shap corners',...''
– tranhoang10 Oct 28 '16 at 07:33 -
-
@tranhoang150488 You probably have an old tcolorbox version. Update it. – Ignasi Oct 28 '16 at 07:41
-
Thank you very much! Now, how to get “LaTeX” symbol in document{book}?? – tranhoang10 Oct 28 '16 at 08:25
-
@tranhoang150488 This is another question, but ...
\LaTeXor http://tex.stackexchange.com/questions/11095/how-to-write-latex-with-parentheses-or-any-other-tex-related-logo – Ignasi Oct 28 '16 at 08:41 -
How to change the length and width of text box above?Please help me! Thank you very much! – tranhoang10 Oct 30 '16 at 04:50
-
@tranhoang150488 -- Look at the option
twocolumnin the\documentclass. Is that the culprit? Or do you mean: I intend to make my boxes have different widths, but I don't know how to do that. – jon Oct 30 '16 at 06:10
3
You do not show what have tried. But have a look at the following code. It will give you a possible starting point.
\documentclass[a4paper,12pt,twocolumn]{article}
\usepackage{amsmath,tcolorbox,tikz}
\begin{document}
\foreach \y in {1,...,34} {
\begin{tcolorbox}
This is a \textbf{tcolorbox}.
\end{tcolorbox}
\begin{tcolorbox}
This is another \textbf{tcolorbox}.
\end{tcolorbox}
\begin{tcolorbox}[title= My nice title]
\foreach \z in {1,...,10} {This is a long \textbf{tcolorbox}.}
\end{tcolorbox}
}
\end{document}
Denis
- 5,267



minipage. Maybe you should look around for a calss. – Enlico Oct 27 '16 at 14:39