6

I know it is possible to use curly brackets (braces) in both vertical and horizontal orientation in Latex. Can I somehow use this to mark my change in y and my change in x on a Coordinate plane?

Here's an image of what I am trying to accomplish.

change in y over change in x

This graphic is produced in Geogebra 4.2 and as you can see it's a very simple idea. But I had to use the pen tool to draw the curly bracket and I used Latex to typeset the delta y and delta x. Why not use Latex for both of these?

Here's another image where I actually used Latex commands \rbrace and \underbrace to produce the brackets.

second image

It worked out pretty good in this case. But had the slope of this line been bigger and I wanted to mark a larger distance the bracket would not be long (or high) enough. What I have done with these two is I have increased it's "size" to make it bigger. But this results in a much thicker lines. Can I control the width and length of the bracket by some argument?

What is the syntax and what are the possible arguments for the \underbrace command? Is there any official resource page where I can look this up? Like a command catalog?

Samir
  • 195
  • Do you mean drawing a graphics like this (just the first item out of thesearch)? http://tex.stackexchange.com/questions/69281/broken-text-on-bottom-of-pgfplots The question is really difficult to understand. – percusse Mar 24 '13 at 12:29
  • 1
    Welcome to TeX.SE! It would be very helpful if you posted some code to show what you've tried so far. Ideally, you'd post an MWE (minimum working example), which might load various LaTeX packages, that generates the issue you're trying to resolve. – Mico Mar 24 '13 at 12:32
  • Yeah, something like that. Just as you would normally do it on paper. I will update the question with an image in a minute. – Samir Mar 24 '13 at 13:04
  • I'm not sure this should be tagged "brackets". This is more of a graphics question. – kahen Mar 24 '13 at 14:37
  • I have added the graphics tag. – Samir Mar 24 '13 at 15:29
  • +1 for responding quickly and constructively to suggestions that improve the question. – Ethan Bolker Mar 24 '13 at 15:31
  • Is it possible to output Latex on this very page?... I tried the single dollar inline and double dollar display math mode Latex formula and it didn't work. A website dedicated to Tex that doesn't support Tex output? I didn't find any reference to how to do this in the formatting help. – Samir Mar 24 '13 at 17:34
  • I have actually never done any Latex editing before in my life. Latex on web forums doesn't count because writing simple equations and formulas with Latex doesn't compare to this. This is a complete typesetting technique for technical writing. It is like writing through programming. I would say I am picking it up very fast, but not fast enough though. The learning curve (or line) is just too steep for me. It's like hitting a wall. Or like doing completely vertical climbing. This is the stuff people use to write scientific papers for the National Geographic! – Samir Mar 24 '13 at 18:13
  • It's just too overwhelming. I will probably need to learn programming first, and then Latex, and then write my 'curly brackies'! Not that I wouldn't want to but, but it takes time. I thought I could just use some argument or a different syntax to input the same thing on a single line in Geogebra. Like change the width or height of the brackets arbitrarily just to extend it. But there seems to be no such argument for these commands. Instead, I will need to learn Latex first. :) I appreciate your help though. I learned some things today through this experimentation. – Samir Mar 24 '13 at 18:18
  • 1
    It is also possible to create braces like that directly in Geogebra using a custom tool, see http://www.geogebratube.org/material/show/id/33499 – Jan Hlavacek Mar 25 '13 at 00:28
  • @JanHlavacek So I didn't have to use Latex in the first place. The Geogebra tool you linked to works great. It's easy to use and does exactly what I wanted, in the native software that I am using. Thanks a lot! – Samir Mar 29 '13 at 11:55
  • Geogebra is very flexible, there is actually very little you cannot do with it. For publication quality drawings I atill prefere LaTeX with tikz, or perhaps something like Asymptote or metapost. – Jan Hlavacek Mar 29 '13 at 12:35

2 Answers2

4

You can use decoration={brace, amplitude=5pt} from decorations.pathreplacing library of tikz.

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\draw[dashed, thin,gray!50] (0,0) grid (12,12);
\draw[very thick, -latex](-1,0) -- (12,0);
\draw[very thick, -latex](0,-1) -- (0,12);
\draw[thick, ](0,0) -- (11,9);
\draw[very thick, ](8.5,6.95) -- (8.5,3);
\draw[very thick,rotate=0,decorate, decoration={brace, amplitude=5pt}] (8.7,6.95)--(8.7,3);  %%%  <----Puts the vertical brace
\draw[very thick, ](8.5,3) -- (3.7,3);
\draw[very thick,rotate=0,decorate, decoration={brace, amplitude=5pt}] (8.5,2.8) -- (3.7,2.8);  %%% Puts the horizontal brace.
\node at (9.4,5) {\Large $\Delta y$};
\node at (6.1,2.36) {\Large $\Delta x$};

\node at (3.5,3.2) {\Large A};
\node at (8.4,7.25) {\Large B};
\node at (8.7,2.7) {\Large C};

\foreach \x in {1,2,...,11} { \draw[thick] (\x,0) -- (\x,-0.2); }
\foreach \y in {1,2,...,11} { \draw[thick] (0,\y) -- (-0.2,\y); }

\foreach \x in {1,2,...,11} { \node [anchor=north] at (\x,-0.3) {\x}; }
\foreach \y in {1,2,...,11} { \node [anchor=east] at (-0.3,\y) {\y}; }
\node at (-0.5,-0.5) {0};

\end{tikzpicture}

\end{document}

enter image description here

For more details type: texdoc pgfmanual from command prompt, or goto www.texdoc.net and search for pgfmanual. You can draw your graph entirely with tikz and/orpgfplots. If you find it difficult, draw the graph in geogebra, export it as tikz code and use the lines that produce the braces with appropriate co-ordinates (The lines are pointed to by comments in code).

  • Yeah, something like that would be nice. The only problem is that I am a complete newbie when it comes to Latex. I only know some basic commands that I use on web forums. But I understand I need a text editor, right? I have just installed Texmaker. And I understand I will need some Latex distribution? I am installing MikTex right now. Will that include Tikz? Or do I need to get that separately? How do i install it? What software packages did you use to produce this graphic? – Samir Mar 24 '13 at 15:40
  • @Sammy Install complete MiKTeX (Not basic installation) hoping that you use windows. That will include tikz. And Texmaker as the editor. These two suffice to do any thing like the above. I used miktex as tex distribution and winedt 7 as the editor to produce above. –  Mar 24 '13 at 16:33
  • I have managed to reproduce the same graphic using your code. Unfortunately I installed the basic MikTex version. But running the code it prompted me to install additional packages. It installed the files standalone.ds, tikz.sty, everyshi.sty, xcolor.sty and supp-pdf.mkii. I installed Texmaker separately, I installed that one first. When it couldn't run any commands I figured out I needed a Latex distribution installed. Yes, I'm on Windows. – Samir Mar 24 '13 at 16:53
  • The problem for me now will be to make this my own. Can I use this setup now as a replacement for Geogebra when graphing functions? Or can I somehow integrate all this into Geogebra? There is an option in Geogebra to export the graphics as PGF/Tikz. So maybe I can export from Geogebra and then make these modifications in Texmaker using Latex? – Samir Mar 24 '13 at 17:08
  • Can you please point me to some web resource where I can learn about the commands you used here? Whcih line actually describes the braces here? – Samir Mar 24 '13 at 17:11
  • @Sammy I have marked those lines with comments inside code. Also modified the answer with details. –  Mar 24 '13 at 22:19
1

You could use TikZ for this thing. Position your image inside a tikzpicture environment like so:

\documentclass{standalone}
\usepackage{tikz}
\usepackage[demo]{graphicx} % Do not use demo in your code!!!

\begin{document}
\begin{tikzpicture}
    \node (pic) at (0,0) {\includegraphics{test.pdf}};
    \coordinate (A) at (3,4); % Play arround to get the coordinates by hand
    \coordinate (B) at (8,4);
    \coordinate (C) at (8,8);
    % Use the code from the Question mentioned bellow and use the defined coordinates
\end{tikzpicture}
\end{document}

Then use the tip described in Draw Curly Braces in TikZ.


You could also use pgfplots and then position the nodes at some specific (x,y) coordinates and this would help you avoid manual fidling when searching for proper A, B and C coordinates.

There are some answers related to node positioning in PGF plots here:

The pgfplots manual can be found here.

aignas
  • 1,306
  • What is TiKZ and pgfplots? Are these just some packages or extensions of some sort, or are they complete programs with user interface? And do I need both of them? If they are extensions, what are they extensions of? What software application (with a graphical user interface) can utilize these? Can I use them in Geogebra? – Samir Mar 24 '13 at 13:41
  • Well TiKZ and pgfplots are packages for LaTeX. The first can handle quite a lot of vector graphics drawing needs. You can find lots of examples on http://www.texample.net. The latter is for plotting functions using TiKZ and gnuplot straight from LaTeX.

    I guess, that you need both only if you want to use pgfplots. Otherwise you can get away only with using TiKZ.

    – aignas Mar 24 '13 at 13:44
  • So can I use this in Geogebra? – Samir Mar 24 '13 at 13:48
  • I guess that no. It is a solution using different tools. In this case you need to use TiKZ with PGFplots inside your LaTeX document, or you need to use Geogebra and then inside your LaTeX document you use TiKZ. – aignas Mar 24 '13 at 15:11
  • What do I input for "demo"? What is "test.pdf"? – Samir Mar 24 '13 at 17:17
  • "! LaTeX Error: Option clash for package graphicx." "! Package pdftex.def Error: File test.pdf' not found." "LaTeX Warning: Filetest.pdf` not found on input line 7." – Samir Mar 24 '13 at 17:21
  • So I have replaced the "test.pdf" file with my png image file and I also had to remove the \usepackage[demo]{graphicx} line because there seems to be no use for it. I now got my image displayed on the right side in my Latex editor. But the graphic quality is horrible. Now how do I get the curly bracket from that other post on top of my image? I tried merging the line 11 where it says \draw [decorate,decoration={brace,amplitude=10pt},xshift=-4pt,yshift=0pt] within the tikzpicture environment but I get Tikz error that I need to load a decoration library???... – Samir Mar 24 '13 at 18:00
  • Can you please adapt this line to my specific case? – Samir Mar 24 '13 at 18:04