3

I used GMS package to write a maths book, and used Tikz code genrated by Geogebra to draw the image.

The problem is there are too much white space above and below Tikz figure, as in the following picture:

enter image description here

Here is the minimal working example:

\documentclass{gsm-l}
\usepackage[papersize={160mm,240mm},inner=20mm, outer=15mm, vmargin=15mm]{geometry}
\geometry{includeheadfoot}
\usepackage{enumitem}
\setlist[itemize]{leftmargin=*}
\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg, .tif}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usepackage[utf8]{vietnam}
\begin{document}
This is the document.


\begin{definition}
 Đây là môi trường định nghĩa, và hình vẽ đi ngay sau nó.
 This is the definition environment, and the Tikz figure follows it. 
\end{definition}

 \definecolor{cqcqcq}{rgb}{0.75,0.75,0.75}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm,scale=0.7]
\clip(-4.3,-10.66) rectangle (17.58,6.3);
\draw (-2.3,4.08)-- (-3.74,0.04);
\draw (-3.74,0.04)-- (0.9,0.02);
\draw (0.9,0.02)-- (-2.3,4.08);
\draw (4.88,4.04)-- (3.44,0);
\draw (3.44,0)-- (8.08,-0.02);
\draw (8.08,-0.02)-- (4.88,4.04);
\begin{scriptsize}
\fill [color=black] (-2.3,4.08) circle (0.5pt);
\draw[color=black] (-2.28,4.4) node {$A$};
\fill [color=black] (-3.74,0.04) circle (0.5pt);
\draw[color=black] (-3.78,-0.18) node {$B$};
\fill [color=black] (0.9,0.02) circle (0.5pt);
\draw[color=black] (1,-0.18) node {$C$};
\draw[color=black] (-1.44,1.52) node {h.1a};
\fill [color=black] (4.88,4.04) circle (0.5pt);
\draw[color=black] (4.9,4.36) node {$A$};
\fill [color=black] (3.44,0) circle (0.5pt);
\draw[color=black] (3.4,-0.22) node {$B$};
\fill [color=black] (8.08,-0.02) circle (0.5pt);
\draw[color=black] (8.14,-0.26) node {$C=D$};
\draw[color=black] (5.74,1.48) node {h.1b};
\end{scriptsize}
\end{tikzpicture}

The above picture is left align also. 
The other question is : How can I center it? 
Please help me. 
\end{document}

So, how can I remove that white space? Please help me.

Thanks.

6

The offending line in the TikZ code is the first line, which clips the output to the specified rectangle. Normally this is used to trim the bounding box and show only part of a figure, however, in your case, whatever program/code generated the TikZ code has used the \clip functionality to expand the bounding box (likely to match the view shown in the creating program at the time of code generation).

The solution is simply to comment out the offending \clip command. For your other question, you can place the TikZ code inside a proper figure environment with \centering inside, as I have shown below.

The Code

    \documentclass{gsm-l}
\usepackage[papersize={160mm,240mm},inner=20mm, outer=15mm, vmargin=15mm]{geometry}
\geometry{includeheadfoot}
\usepackage{enumitem}
\setlist[itemize]{leftmargin=*}
\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg, .tif}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usepackage[utf8]{vietnam}
\begin{document}
This is the document.

 Đây là môi trường định nghĩa, và hình vẽ đi ngay sau nó.
 This is the definition environment, and the Tikz figure follows it. 

 \definecolor{cqcqcq}{rgb}{0.75,0.75,0.75}
\begin{figure}[h] % place the figure [h]ere, you may want to give LaTeX some more options
\centering
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm,scale=0.7]
%\clip(-4.3,-10.66) rectangle (17.58,6.3);
\draw (-2.3,4.08)-- (-3.74,0.04);
\draw (-3.74,0.04)-- (0.9,0.02);
\draw (0.9,0.02)-- (-2.3,4.08);
\draw (4.88,4.04)-- (3.44,0);
\draw (3.44,0)-- (8.08,-0.02);
\draw (8.08,-0.02)-- (4.88,4.04);
\begin{scriptsize}
\fill [color=black] (-2.3,4.08) circle (0.5pt);
\draw[color=black] (-2.28,4.4) node {$A$};
\fill [color=black] (-3.74,0.04) circle (0.5pt);
\draw[color=black] (-3.78,-0.18) node {$B$};
\fill [color=black] (0.9,0.02) circle (0.5pt);
\draw[color=black] (1,-0.18) node {$C$};
\draw[color=black] (-1.44,1.52) node {h.1a};
\fill [color=black] (4.88,4.04) circle (0.5pt);
\draw[color=black] (4.9,4.36) node {$A$};
\fill [color=black] (3.44,0) circle (0.5pt);
\draw[color=black] (3.4,-0.22) node {$B$};
\fill [color=black] (8.08,-0.02) circle (0.5pt);
\draw[color=black] (8.14,-0.26) node {$C=D$};
\draw[color=black] (5.74,1.48) node {h.1b};
\end{scriptsize}
\end{tikzpicture}
\caption{This is the figure caption.}
\end{figure}

The above picture is left align also. 
The other question is : How can I center it? 
Please help me. 
\end{document}

The Output

enter image description here

6

Some more explanations on how to detect the problem. The command \clip clips the picture part that that lies within the rectangle bounded by (-4.3,-10.66) and (17.58,6.3). To get a visual of this rectangle you can add some sort of grid like

\draw (-5,-10) grid (18,6.5);
%\clip(-4.3,-10.66) rectangle (17.58,6.3);

in your tikzpicture and you will get

enter image description here

Now you will see that the \clip operation is doing a bad thing by un-necessarily showing the bottom, top and right parts. Hence as told by Paul Gessler the culprit is the dimensions given to the \clip command. You can either comment out the \clip line or choose a proper dimension to have a more tighter border.

For the latter, we can assign the tick labels to see the correct labels. Add

\draw[help lines,xstep=1,ystep=1] (-5,-10) grid (18,6.5);
\foreach \x in {-5,-4,...,18} { \node [anchor=north] at (\x,0) {\x}; }
\foreach \y in {-10,-9,...,6} { \node [anchor=east] at (0,\y) {\y}; }

to get

enter image description here

Now you can see the correct coordinates that musrt be provided to the \clip operation. I will choose (-4,-0.5) rectangle (9,4.5); in

\clip(-4,-0.5) rectangle (9,4.5);
\draw[help lines,xstep=1,ystep=1] (-5,-10) grid (18,6.5);
\foreach \x in {-5,-4,...,18} { \node [anchor=north] at (\x,0) {\x}; }
\foreach \y in {-10,-9,...,6} { \node [anchor=east] at (0,\y) {\y}; }

to get

enter image description here

Finally comment out the grids and friends like

\clip(-4,-0.5) rectangle (9,4.5);
%\draw[help lines,xstep=1,ystep=1] (-5,-10) grid (18,6.5);
%\foreach \x in {-5,-4,...,18} { \node [anchor=north] at (\x,0) {\x}; }
%\foreach \y in {-10,-9,...,6} { \node [anchor=east] at (0,\y) {\y}; }

Full code:

\documentclass{article}
\usepackage[papersize={160mm,240mm},inner=20mm, outer=15mm, vmargin=15mm]{geometry}
\geometry{includeheadfoot}
\usepackage{enumitem}
\setlist[itemize]{leftmargin=*}
\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg, .tif}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usepackage[utf8]{vietnam}
\begin{document}
This is the document.

 Đây là môi trường định nghĩa, và hình vẽ đi ngay sau nó.
 This is the definition environment, and the Tikz figure follows it.

 \definecolor{cqcqcq}{rgb}{0.75,0.75,0.75}
\begin{figure}[h] % place the figure [h]ere, you may want to give LaTeX some more options
\centering
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm,scale=0.7]
\clip(-4,-0.5) rectangle (9,4.5);
%\draw[help lines,xstep=1,ystep=1] (-5,-10) grid (18,6.5);
%\foreach \x in {-5,-4,...,18} { \node [anchor=north] at (\x,0) {\x}; }
%\foreach \y in {-10,-9,...,6} { \node [anchor=east] at (0,\y) {\y}; }
\draw (-2.3,4.08)-- (-3.74,0.04);
\draw (-3.74,0.04)-- (0.9,0.02);
\draw (0.9,0.02)-- (-2.3,4.08);
\draw (4.88,4.04)-- (3.44,0);
\draw (3.44,0)-- (8.08,-0.02);
\draw (8.08,-0.02)-- (4.88,4.04);
\begin{scriptsize}
\fill [color=black] (-2.3,4.08) circle (0.5pt);
\draw[color=black] (-2.28,4.4) node {$A$};
\fill [color=black] (-3.74,0.04) circle (0.5pt);
\draw[color=black] (-3.78,-0.18) node {$B$};
\fill [color=black] (0.9,0.02) circle (0.5pt);
\draw[color=black] (1,-0.18) node {$C$};
\draw[color=black] (-1.44,1.52) node {h.1a};
\fill [color=black] (4.88,4.04) circle (0.5pt);
\draw[color=black] (4.9,4.36) node {$A$};
\fill [color=black] (3.44,0) circle (0.5pt);
\draw[color=black] (3.4,-0.22) node {$B$};
\fill [color=black] (8.08,-0.02) circle (0.5pt);
\draw[color=black] (8.14,-0.26) node {$C=D$};
\draw[color=black] (5.74,1.48) node {h.1b};
\end{scriptsize}
\end{tikzpicture}
\caption{This is the figure caption.}
\end{figure}

The above picture is left align also.
The other question is : How can I center it?
Please help me.
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.