How to align text above triangle figure












2















I managed to align my hypotenuse text with the hypotenuse side of my triangle, but I feel like it was done inefficiently using a lot of ~~~~~~ in this line node[above] {$sqrt{1+x^2}$~~~~~~~} (B) --.



Is there a better way to get the same alignment that I have now without the excessive use of ~?



enter image description here



documentclass[hidelinks,14pt, letterpaper]{extarticle}
usepackage{amsmath, amssymb, tikz}

newcommand{pythagwidth}{3cm}
newcommand{pythagheight}{2cm}

begin{document}
begin{figure}[h]
centering

begin{tikzpicture}[scale=1.25]
coordinate [label=left:$A$] (A) at (-1.5cm,-1.cm);
coordinate [label=above:$B$] (B) at (1.5cm,1.0cm);
coordinate [label=below right:$C$] (C) at (1.5cm,-1.0cm);
draw
(A) --
node[above] {$sqrt{1+x^2}$~~~~~~~} (B) --
node[right] {?} (C) --
node[below] {?}
(A);
draw
(1.25cm,-1.0cm) rectangle (1.5cm,-0.75cm);

end{tikzpicture}
caption{Caption}
label{fig:my_label}
end{figure}
end{document}









share|improve this question



























    2















    I managed to align my hypotenuse text with the hypotenuse side of my triangle, but I feel like it was done inefficiently using a lot of ~~~~~~ in this line node[above] {$sqrt{1+x^2}$~~~~~~~} (B) --.



    Is there a better way to get the same alignment that I have now without the excessive use of ~?



    enter image description here



    documentclass[hidelinks,14pt, letterpaper]{extarticle}
    usepackage{amsmath, amssymb, tikz}

    newcommand{pythagwidth}{3cm}
    newcommand{pythagheight}{2cm}

    begin{document}
    begin{figure}[h]
    centering

    begin{tikzpicture}[scale=1.25]
    coordinate [label=left:$A$] (A) at (-1.5cm,-1.cm);
    coordinate [label=above:$B$] (B) at (1.5cm,1.0cm);
    coordinate [label=below right:$C$] (C) at (1.5cm,-1.0cm);
    draw
    (A) --
    node[above] {$sqrt{1+x^2}$~~~~~~~} (B) --
    node[right] {?} (C) --
    node[below] {?}
    (A);
    draw
    (1.25cm,-1.0cm) rectangle (1.5cm,-0.75cm);

    end{tikzpicture}
    caption{Caption}
    label{fig:my_label}
    end{figure}
    end{document}









    share|improve this question

























      2












      2








      2


      1






      I managed to align my hypotenuse text with the hypotenuse side of my triangle, but I feel like it was done inefficiently using a lot of ~~~~~~ in this line node[above] {$sqrt{1+x^2}$~~~~~~~} (B) --.



      Is there a better way to get the same alignment that I have now without the excessive use of ~?



      enter image description here



      documentclass[hidelinks,14pt, letterpaper]{extarticle}
      usepackage{amsmath, amssymb, tikz}

      newcommand{pythagwidth}{3cm}
      newcommand{pythagheight}{2cm}

      begin{document}
      begin{figure}[h]
      centering

      begin{tikzpicture}[scale=1.25]
      coordinate [label=left:$A$] (A) at (-1.5cm,-1.cm);
      coordinate [label=above:$B$] (B) at (1.5cm,1.0cm);
      coordinate [label=below right:$C$] (C) at (1.5cm,-1.0cm);
      draw
      (A) --
      node[above] {$sqrt{1+x^2}$~~~~~~~} (B) --
      node[right] {?} (C) --
      node[below] {?}
      (A);
      draw
      (1.25cm,-1.0cm) rectangle (1.5cm,-0.75cm);

      end{tikzpicture}
      caption{Caption}
      label{fig:my_label}
      end{figure}
      end{document}









      share|improve this question














      I managed to align my hypotenuse text with the hypotenuse side of my triangle, but I feel like it was done inefficiently using a lot of ~~~~~~ in this line node[above] {$sqrt{1+x^2}$~~~~~~~} (B) --.



      Is there a better way to get the same alignment that I have now without the excessive use of ~?



      enter image description here



      documentclass[hidelinks,14pt, letterpaper]{extarticle}
      usepackage{amsmath, amssymb, tikz}

      newcommand{pythagwidth}{3cm}
      newcommand{pythagheight}{2cm}

      begin{document}
      begin{figure}[h]
      centering

      begin{tikzpicture}[scale=1.25]
      coordinate [label=left:$A$] (A) at (-1.5cm,-1.cm);
      coordinate [label=above:$B$] (B) at (1.5cm,1.0cm);
      coordinate [label=below right:$C$] (C) at (1.5cm,-1.0cm);
      draw
      (A) --
      node[above] {$sqrt{1+x^2}$~~~~~~~} (B) --
      node[right] {?} (C) --
      node[below] {?}
      (A);
      draw
      (1.25cm,-1.0cm) rectangle (1.5cm,-0.75cm);

      end{tikzpicture}
      caption{Caption}
      label{fig:my_label}
      end{figure}
      end{document}






      tikz-pgf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 4 hours ago









      Evan KimEvan Kim

      1503




      1503






















          2 Answers
          2






          active

          oldest

          votes


















          5














          Something like this? I use node[midway,above left=0pt,inner sep=0.5pt] {$sqrt{1+x^2}$}, where inner sep=0.5pt controls the distance.



          documentclass[hidelinks,14pt, letterpaper]{extarticle}
          usepackage{amsmath, amssymb, tikz}

          newcommand{pythagwidth}{3cm}
          newcommand{pythagheight}{2cm}

          begin{document}
          begin{figure}[h]
          centering

          begin{tikzpicture}[scale=1.25]
          coordinate [label=left:$A$] (A) at (-1.5cm,-1.cm);
          coordinate [label=above:$B$] (B) at (1.5cm,1.0cm);
          coordinate [label=below right:$C$] (C) at (1.5cm,-1.0cm);
          draw
          (A) --
          node[midway,above left=0pt,inner sep=0.5pt] {$sqrt{1+x^2}$} (B) --
          node[right] {?} (C) --
          node[below] {?}
          (A);
          draw
          (1.25cm,-1.0cm) rectangle (1.5cm,-0.75cm);

          end{tikzpicture}
          caption{Caption}
          label{fig:my_label}
          end{figure}
          end{document}


          enter image description here



          ADDENDUM: Just for fun: an even simpler and shorter code with TikZ...



          documentclass[tikz,border=3.14mm]{standalone}
          begin{document}
          begin{tikzpicture}[scale=1.25]
          draw (-1.5,-1) coordinate [label=left:$A$] (A) --
          node[midway,above,sloped] {$sqrt{1+x^2}$}
          (1.5,1) coordinate [label=above:$B$] (B) --
          node[right] {?}
          (1.5,-1)coordinate [label=below right:$C$] (C) --
          node[below] {?} cycle;
          draw ([xshift=-0.25cm]C) |- ([yshift=0.25cm]C);
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer


























          • yes that is it thanks! It seems like simply having node [midway,above left=0pt] {$sqrt{1+x^2}$} (B) -- does the trick too without using inner_sept

            – Evan Kim
            3 hours ago





















          1














          Just for fun: with pstricks, a very short code to have this figure:



           documentclass{article}
          usepackage{pst-eucl}%,
          usepackage{auto-pst-pdf}

          begin{document}

          begin{postscript}
          psset{unit=2, linejoin=1, PointSymbol=none,}
          pstTriangle(-1.5,-1){A}(1.5,1){B}(1.5,-1){C}
          ncline[linestyle=none]{A}{B}naput*[nrot=:U]{$ sqrt{1 + x^2}$}
          psset{PointName=none}
          pstMiddleAB{A}{C}{I}uput[d](I){?}
          pstMiddleAB{B}{C}{J}uput[r](J){?}
          end{postscript}

          end{document}


          enter image description here






          share|improve this answer
























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "85"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f485211%2fhow-to-align-text-above-triangle-figure%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            Something like this? I use node[midway,above left=0pt,inner sep=0.5pt] {$sqrt{1+x^2}$}, where inner sep=0.5pt controls the distance.



            documentclass[hidelinks,14pt, letterpaper]{extarticle}
            usepackage{amsmath, amssymb, tikz}

            newcommand{pythagwidth}{3cm}
            newcommand{pythagheight}{2cm}

            begin{document}
            begin{figure}[h]
            centering

            begin{tikzpicture}[scale=1.25]
            coordinate [label=left:$A$] (A) at (-1.5cm,-1.cm);
            coordinate [label=above:$B$] (B) at (1.5cm,1.0cm);
            coordinate [label=below right:$C$] (C) at (1.5cm,-1.0cm);
            draw
            (A) --
            node[midway,above left=0pt,inner sep=0.5pt] {$sqrt{1+x^2}$} (B) --
            node[right] {?} (C) --
            node[below] {?}
            (A);
            draw
            (1.25cm,-1.0cm) rectangle (1.5cm,-0.75cm);

            end{tikzpicture}
            caption{Caption}
            label{fig:my_label}
            end{figure}
            end{document}


            enter image description here



            ADDENDUM: Just for fun: an even simpler and shorter code with TikZ...



            documentclass[tikz,border=3.14mm]{standalone}
            begin{document}
            begin{tikzpicture}[scale=1.25]
            draw (-1.5,-1) coordinate [label=left:$A$] (A) --
            node[midway,above,sloped] {$sqrt{1+x^2}$}
            (1.5,1) coordinate [label=above:$B$] (B) --
            node[right] {?}
            (1.5,-1)coordinate [label=below right:$C$] (C) --
            node[below] {?} cycle;
            draw ([xshift=-0.25cm]C) |- ([yshift=0.25cm]C);
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer


























            • yes that is it thanks! It seems like simply having node [midway,above left=0pt] {$sqrt{1+x^2}$} (B) -- does the trick too without using inner_sept

              – Evan Kim
              3 hours ago


















            5














            Something like this? I use node[midway,above left=0pt,inner sep=0.5pt] {$sqrt{1+x^2}$}, where inner sep=0.5pt controls the distance.



            documentclass[hidelinks,14pt, letterpaper]{extarticle}
            usepackage{amsmath, amssymb, tikz}

            newcommand{pythagwidth}{3cm}
            newcommand{pythagheight}{2cm}

            begin{document}
            begin{figure}[h]
            centering

            begin{tikzpicture}[scale=1.25]
            coordinate [label=left:$A$] (A) at (-1.5cm,-1.cm);
            coordinate [label=above:$B$] (B) at (1.5cm,1.0cm);
            coordinate [label=below right:$C$] (C) at (1.5cm,-1.0cm);
            draw
            (A) --
            node[midway,above left=0pt,inner sep=0.5pt] {$sqrt{1+x^2}$} (B) --
            node[right] {?} (C) --
            node[below] {?}
            (A);
            draw
            (1.25cm,-1.0cm) rectangle (1.5cm,-0.75cm);

            end{tikzpicture}
            caption{Caption}
            label{fig:my_label}
            end{figure}
            end{document}


            enter image description here



            ADDENDUM: Just for fun: an even simpler and shorter code with TikZ...



            documentclass[tikz,border=3.14mm]{standalone}
            begin{document}
            begin{tikzpicture}[scale=1.25]
            draw (-1.5,-1) coordinate [label=left:$A$] (A) --
            node[midway,above,sloped] {$sqrt{1+x^2}$}
            (1.5,1) coordinate [label=above:$B$] (B) --
            node[right] {?}
            (1.5,-1)coordinate [label=below right:$C$] (C) --
            node[below] {?} cycle;
            draw ([xshift=-0.25cm]C) |- ([yshift=0.25cm]C);
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer


























            • yes that is it thanks! It seems like simply having node [midway,above left=0pt] {$sqrt{1+x^2}$} (B) -- does the trick too without using inner_sept

              – Evan Kim
              3 hours ago
















            5












            5








            5







            Something like this? I use node[midway,above left=0pt,inner sep=0.5pt] {$sqrt{1+x^2}$}, where inner sep=0.5pt controls the distance.



            documentclass[hidelinks,14pt, letterpaper]{extarticle}
            usepackage{amsmath, amssymb, tikz}

            newcommand{pythagwidth}{3cm}
            newcommand{pythagheight}{2cm}

            begin{document}
            begin{figure}[h]
            centering

            begin{tikzpicture}[scale=1.25]
            coordinate [label=left:$A$] (A) at (-1.5cm,-1.cm);
            coordinate [label=above:$B$] (B) at (1.5cm,1.0cm);
            coordinate [label=below right:$C$] (C) at (1.5cm,-1.0cm);
            draw
            (A) --
            node[midway,above left=0pt,inner sep=0.5pt] {$sqrt{1+x^2}$} (B) --
            node[right] {?} (C) --
            node[below] {?}
            (A);
            draw
            (1.25cm,-1.0cm) rectangle (1.5cm,-0.75cm);

            end{tikzpicture}
            caption{Caption}
            label{fig:my_label}
            end{figure}
            end{document}


            enter image description here



            ADDENDUM: Just for fun: an even simpler and shorter code with TikZ...



            documentclass[tikz,border=3.14mm]{standalone}
            begin{document}
            begin{tikzpicture}[scale=1.25]
            draw (-1.5,-1) coordinate [label=left:$A$] (A) --
            node[midway,above,sloped] {$sqrt{1+x^2}$}
            (1.5,1) coordinate [label=above:$B$] (B) --
            node[right] {?}
            (1.5,-1)coordinate [label=below right:$C$] (C) --
            node[below] {?} cycle;
            draw ([xshift=-0.25cm]C) |- ([yshift=0.25cm]C);
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer















            Something like this? I use node[midway,above left=0pt,inner sep=0.5pt] {$sqrt{1+x^2}$}, where inner sep=0.5pt controls the distance.



            documentclass[hidelinks,14pt, letterpaper]{extarticle}
            usepackage{amsmath, amssymb, tikz}

            newcommand{pythagwidth}{3cm}
            newcommand{pythagheight}{2cm}

            begin{document}
            begin{figure}[h]
            centering

            begin{tikzpicture}[scale=1.25]
            coordinate [label=left:$A$] (A) at (-1.5cm,-1.cm);
            coordinate [label=above:$B$] (B) at (1.5cm,1.0cm);
            coordinate [label=below right:$C$] (C) at (1.5cm,-1.0cm);
            draw
            (A) --
            node[midway,above left=0pt,inner sep=0.5pt] {$sqrt{1+x^2}$} (B) --
            node[right] {?} (C) --
            node[below] {?}
            (A);
            draw
            (1.25cm,-1.0cm) rectangle (1.5cm,-0.75cm);

            end{tikzpicture}
            caption{Caption}
            label{fig:my_label}
            end{figure}
            end{document}


            enter image description here



            ADDENDUM: Just for fun: an even simpler and shorter code with TikZ...



            documentclass[tikz,border=3.14mm]{standalone}
            begin{document}
            begin{tikzpicture}[scale=1.25]
            draw (-1.5,-1) coordinate [label=left:$A$] (A) --
            node[midway,above,sloped] {$sqrt{1+x^2}$}
            (1.5,1) coordinate [label=above:$B$] (B) --
            node[right] {?}
            (1.5,-1)coordinate [label=below right:$C$] (C) --
            node[below] {?} cycle;
            draw ([xshift=-0.25cm]C) |- ([yshift=0.25cm]C);
            end{tikzpicture}
            end{document}


            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 3 hours ago

























            answered 4 hours ago









            marmotmarmot

            118k6153288




            118k6153288













            • yes that is it thanks! It seems like simply having node [midway,above left=0pt] {$sqrt{1+x^2}$} (B) -- does the trick too without using inner_sept

              – Evan Kim
              3 hours ago





















            • yes that is it thanks! It seems like simply having node [midway,above left=0pt] {$sqrt{1+x^2}$} (B) -- does the trick too without using inner_sept

              – Evan Kim
              3 hours ago



















            yes that is it thanks! It seems like simply having node [midway,above left=0pt] {$sqrt{1+x^2}$} (B) -- does the trick too without using inner_sept

            – Evan Kim
            3 hours ago







            yes that is it thanks! It seems like simply having node [midway,above left=0pt] {$sqrt{1+x^2}$} (B) -- does the trick too without using inner_sept

            – Evan Kim
            3 hours ago













            1














            Just for fun: with pstricks, a very short code to have this figure:



             documentclass{article}
            usepackage{pst-eucl}%,
            usepackage{auto-pst-pdf}

            begin{document}

            begin{postscript}
            psset{unit=2, linejoin=1, PointSymbol=none,}
            pstTriangle(-1.5,-1){A}(1.5,1){B}(1.5,-1){C}
            ncline[linestyle=none]{A}{B}naput*[nrot=:U]{$ sqrt{1 + x^2}$}
            psset{PointName=none}
            pstMiddleAB{A}{C}{I}uput[d](I){?}
            pstMiddleAB{B}{C}{J}uput[r](J){?}
            end{postscript}

            end{document}


            enter image description here






            share|improve this answer




























              1














              Just for fun: with pstricks, a very short code to have this figure:



               documentclass{article}
              usepackage{pst-eucl}%,
              usepackage{auto-pst-pdf}

              begin{document}

              begin{postscript}
              psset{unit=2, linejoin=1, PointSymbol=none,}
              pstTriangle(-1.5,-1){A}(1.5,1){B}(1.5,-1){C}
              ncline[linestyle=none]{A}{B}naput*[nrot=:U]{$ sqrt{1 + x^2}$}
              psset{PointName=none}
              pstMiddleAB{A}{C}{I}uput[d](I){?}
              pstMiddleAB{B}{C}{J}uput[r](J){?}
              end{postscript}

              end{document}


              enter image description here






              share|improve this answer


























                1












                1








                1







                Just for fun: with pstricks, a very short code to have this figure:



                 documentclass{article}
                usepackage{pst-eucl}%,
                usepackage{auto-pst-pdf}

                begin{document}

                begin{postscript}
                psset{unit=2, linejoin=1, PointSymbol=none,}
                pstTriangle(-1.5,-1){A}(1.5,1){B}(1.5,-1){C}
                ncline[linestyle=none]{A}{B}naput*[nrot=:U]{$ sqrt{1 + x^2}$}
                psset{PointName=none}
                pstMiddleAB{A}{C}{I}uput[d](I){?}
                pstMiddleAB{B}{C}{J}uput[r](J){?}
                end{postscript}

                end{document}


                enter image description here






                share|improve this answer













                Just for fun: with pstricks, a very short code to have this figure:



                 documentclass{article}
                usepackage{pst-eucl}%,
                usepackage{auto-pst-pdf}

                begin{document}

                begin{postscript}
                psset{unit=2, linejoin=1, PointSymbol=none,}
                pstTriangle(-1.5,-1){A}(1.5,1){B}(1.5,-1){C}
                ncline[linestyle=none]{A}{B}naput*[nrot=:U]{$ sqrt{1 + x^2}$}
                psset{PointName=none}
                pstMiddleAB{A}{C}{I}uput[d](I){?}
                pstMiddleAB{B}{C}{J}uput[r](J){?}
                end{postscript}

                end{document}


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 3 hours ago









                BernardBernard

                176k778210




                176k778210






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f485211%2fhow-to-align-text-above-triangle-figure%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    GameSpot

                    connect to host localhost port 22: Connection refused

                    Getting a Wifi WPA2 wifi connection