LaTeX forum ⇒ Math & ScienceThe vertices overlap in tikz

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Autumn_
Posts: 2
Joined: Sun May 07, 2023 12:28 am

The vertices overlap in tikz

Postby Autumn_ » Sun May 07, 2023 1:11 am

the vertics overleap in my code. Why? please tell me a good code...

\documentclass[dvipdfmx]{ltjsarticle}
\usepackage{tikz}
\usetikzlibrary{intersections,calc,arrows.meta}

\begin{document}
  \begin{tikzpicture}
    \coordinate[label=left:A](A)at(0,0)
    \coordinate[label=right:B](B)at(3,0);
    \coordinate[label=above:C](C)at(2,2);
    \draw(A)--(B)--(C)--cycle;
  \end{tikzpicture}
\end{document}
Attachments
スクリーンショット (91).png
スクリーンショット (91).png (11.44 KiB) Viewed 1140 times

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net
LaTeX Beginner's Guide LaTeX Cookbook
Bartman
Posts: 331
Joined: Fri Jan 03, 2020 2:39 pm

The vertices overlap in tikz

Postby Bartman » Sun May 07, 2023 2:09 am

Please mark multiline code using the suitable tags.

A semicolon is missing at the end of the first \coordinate command.

Autumn_
Posts: 2
Joined: Sun May 07, 2023 12:28 am

The vertices overlap in tikz

Postby Autumn_ » Sun May 07, 2023 2:48 am

Bartman wrote:Please mark multiline code using the suitable tags.

A semicolon is missing at the end of the first \coordinate command.


1st message>> Sorry,what does it means? Sorry I do not good at English... Could you show me a good program code?
2nd message>> oh! thank you! But the result does not change...

User avatar
Stefan Kottwitz
Site Admin
Posts: 9987
Joined: Mon Mar 10, 2008 9:44 pm

The vertices overlap in tikz

Postby Stefan Kottwitz » Sun May 07, 2023 9:49 am

Hi Autumn,

welcome to the forum!

Look at the line for coordinate A here, I put the semicolon at the end. It is missing in your original code. Every TikZ path has to end with a semicolon.

%!TEX lualatex
\documentclass{ltjsarticle}
\usepackage{tikz}
\usetikzlibrary{intersections,calc,arrows.meta}

\begin{document}
  \begin{tikzpicture}
    \coordinate[label=left:A](A)at(0,0);
    \coordinate[label=right:B](B)at(3,0);
    \coordinate[label=above:C](C)at(2,2);
    \draw(A)--(B)--(C)--cycle;
  \end{tikzpicture}
\end{document}


You can click on "Run LaTeX here" to see that it works.

By the way, I removed the dvipdfmx option, which is not compatible with LuaLaTeX, required by ltjsarticle.

To 2. you accidentally used the "LaTeX" button, which is for inline code marking of LaTeX commands. For multiple lines of code, there's the "Code" button at the left top of the editor field when writing. Not perfect, I guess. I edited it above.

Stefan
LaTeX.org admin


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 1 guest