New answers tagged

0 votes

Chemfig and TikZ

Another possibility. It is possible to insert more complex molecules with ChemFig. There is no need to create new commands. \documentclass{article} \usepackage[version=4]{mhchem} \usepackage{chemfig} ...
CrocoDuck's user avatar
  • 3,820
1 vote

Chemfig and TikZ

There are a lot of ways to draw this. You could use the chemfig package like in the following exammple, but you could also directly use TikZ: \documentclass[border=10pt]{standalone} \usepackage{...
Jasper Habicht's user avatar
3 votes

Generate TikZ \pics dynamically

If we are using OpTeX, we don't need to use TikZ, because there is \puttext macro. The powerSupply.png image is saved to the \pwbox and this box is copied (and rotated) in the \fornum loop. \newcount\...
wipet's user avatar
  • 73.2k
2 votes
Accepted

Visual errors in pgfplots graph

As far as I understand you want to see a scatter plot. So, you may use only marks option to remove the lines and leave only markers. the size of points can be controlled via mark size. Just use scaled ...
Andrey L.'s user avatar
  • 1,697
6 votes
Accepted

Draw additional parallel paths in TikZ

I just found the nfold library from 2023 by Jonathan Schulz. It can do exactly that - also for Bézier curves and closed curves. \documentclass[tikz, border=1cm]{standalone} \usetikzlibrary{nfold} \...
hpekristiansen's user avatar
5 votes

tikz-cd "equal" arrow with a colored background

Use the nfold library, so you don't need to guess the background color. \documentclass{article} \usepackage{xcolor} \usepackage{tikz-cd} \usetikzlibrary{nfold} \begin{document} \colorbox{blue!90!red}...
egreg's user avatar
  • 1.1m
4 votes

tikz-cd "equal" arrow with a colored background

It appears that tikzcd uses TikZ's double option. As I found out in this comment, this option has an optional parameter specifying the background color separating the two lines of the "equal"...
sparusaurata's user avatar
2 votes
Accepted

Generate TikZ \pics dynamically

You can make use of the pgfplotstable package (which loads pgfplots and tikz in the background) and read in a CSV file which you can then process and use to place \pics or whatever you want to do. I'd ...
Jasper Habicht's user avatar
1 vote
Accepted

How to print a \pic in TiKz aligned to one of its border?

You can just set an anchor to the node and set the inner sep to 0pt: \documentclass{article} \usepackage[a4paper, margin=10mm]{geometry} \usepackage{tikz} \tikzset{ PowerSupply/.pic={ \...
Jasper Habicht's user avatar
3 votes
Accepted

Inclined plane with friction

I am not fully sure whether this is about what you want, but a solution in reference to my other answer could be: \documentclass[border=10pt]{standalone} \usepackage{tikz} \usetikzlibrary{patterns} \...
Jasper Habicht's user avatar
2 votes
Accepted

How to put the caption of a TikZ Picture below an image when using overlay option?

I'm not sure why you want to use overlay there, but you could place the caption below the node with the image: \documentclass{article} \usepackage[a4paper,margin=10mm]{geometry} \usepackage{tikz} \...
samcarter_is_at_topanswers.xyz's user avatar
1 vote
Accepted

Drawing a basketball using Latex

The correct syntax of this line is : \shade[ball color=orange] (0,0) circle [radius=2cm]; It should work now
Waxler's user avatar
  • 584
3 votes
Accepted

Create an electrical installation plan in TikZ

Instead of answering your questions, I focus on achieving the result in a reasonably way. \documentclass{article} \usepackage[a4paper, hmargin=0.2cm, vmargin=1cm]{geometry} \usepackage[parfill]{...
hpekristiansen's user avatar
0 votes

infinite square well potential

I did some changes to Alice answer for my quantum mechanics notes: \documentclass[tikz, border=5mm]{standalone} \usepackage{color} \usetikzlibrary{calc} \usepackage[english]{babel} \usepackage[utf8]{...
Héctor FH's user avatar
2 votes

TikZ strange default anchor behavior

This is an example to explain why there are some gaps even the margin was already set to 0. By default, there will be paragraph indent (horizontally) and topskip (vertical) space before the first ...
Tom's user avatar
  • 6,763
0 votes

How to draw logic gates in tikz

\begin{circuitikz} \draw (0,0) node[nand port] (nand1) {} (0,2) node[nand port] (nand2) {} (2,1) node[nand port] (nand3) {} (nand1.in 1) node[anchor=east] {A} (nand1.in 2) node[anchor=east] {A} (nand2....
E x s o t i c's user avatar
0 votes
Accepted

pgfplots bar plot: add labeled arrow from one bar to another

Just add a method if you want easily and precisely place the arrow. You could put the \draw inside the axis environment and use axis cs and [normalized] location for the symbolic coordinates where [...
Tom's user avatar
  • 6,763
0 votes

pgfplots bar plot: add labeled arrow from one bar to another

As a quick hack, you could manually add the arrow (adjust the coordinates as needed): \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.9} \begin{document} \...
samcarter_is_at_topanswers.xyz's user avatar
1 vote

How highlight date or week in TikZ Calendar with background color?

With due amendments to the code here - Tikz-Calendar: How to work with an array of dates? The colors can be changed here % standard stuff % if (Saturday) [blue!50] if (Sunday) [red] To ...
js bibra's user avatar
  • 20.9k
1 vote

Replacing a square with a star in TikZ

The shapes.geometric library (see section "71.3 Geometric Shapes" of the user manual) provides a star shape: \documentclass{article} \usepackage{tikz} \usetikzlibrary{shapes.geometric} \...
samcarter_is_at_topanswers.xyz's user avatar
10 votes

TikZ in XeLaTeX vs. LaTeX

You get ! LaTeX Error: Backend request inconsistent with engine: using 'pdftex' (LaTeX) backend. The help message reads You have requested backend 'dvipdfmx', but this is not suitable for use ...
egreg's user avatar
  • 1.1m
1 vote
Accepted

How do I draw a line to connect one entry to another within a tabular environment?

You forget remember picture option. \documentclass{memoir} \usepackage{tikz} \tikzset{mynode/.style={draw=none,fill=none,rectangle,anchor=base}} \begin{document} \begin{center} \begin{tabular}{lcl} ...
Tom's user avatar
  • 6,763
3 votes

How to put arrow between characters (inside text)

You could use a tikzcd inline. \documentclass{article} \usepackage{tikz-cd} \tikzcdset{arrow style=tikz, diagrams={>=Parenthesis}} \tikzset{inline/.style={column sep=2mm, cells={nodes={inner xsep=...
Sandy G's user avatar
  • 41.5k
6 votes
Accepted

Is there a way to choose a "horizontal center" of a TikZ picture?

\documentclass[tikz]{standalone} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \coordinate (o) at (2,2); \draw (0,0) rectangle (4,4); \draw[fill=black] (3,3.5) circle[radius=0.1] -- ++(0,...
hpekristiansen's user avatar
4 votes

Is there a way to choose a "horizontal center" of a TikZ picture?

I understand that you want an automatic way to extend the (horizontal) figure bounding box so that it is symmetrical around the center of your rectangle. One way of solving this is the following: I ...
Rmano's user avatar
  • 40.3k
0 votes

Is there a way to choose a "horizontal center" of a TikZ picture?

You could hide the width of the label with \makebox[0pt]{label extends border} and add a horizontal margin to your image which will be symmetrical: \documentclass[tikz,border={0.7cm 0cm}]{standalone} \...
samcarter_is_at_topanswers.xyz's user avatar
1 vote

Using TikZ (or other package) to draw a gameboard, somewhat similar to chess (Hnefatafl)

You could create your custom commands. Here I used expl syntax to convert some alphanumeric coordinate such as f4 to a node at the relevant coordinate in a TikZ coordinate system. For the actual game ...
Jasper Habicht's user avatar
0 votes

How to label the nodes ( coordinates ) in tikz picture?

\begin{tikzpicture}[scale=1.5] \coordinate[label=above left:$A$] (A) at (0,2); \coordinate[label=below left:$B$] (B) at (0,0); \coordinate[label=below right:$C$] (C) at (3,0); \draw (A) -- (B) -- (C) -...
denisflay9's user avatar
1 vote

How to put arrow between characters (inside text)

This could be achieved by setting the baseline to (current bounding box.base) and node anchor to base. \documentclass{report} \usepackage[doublespacing]{setspace} \usepackage{tikz} \newcommand{\...
Tom's user avatar
  • 6,763
1 vote

How to put arrow between characters (inside text)

This solution could be improve (and should) but at least somehow works. 1st argument is pre-space (default 1pt) optional 2nd argument is after-space (default 1pt) optional 3rd argument (1st mandatory)...
Mane32's user avatar
  • 501
0 votes

Fixing tikz in cventry of moderncv

This is an old question, but since it's the first result that appears when searching for "moderncv tikz error", here's my take. Use \DeclareRobustCommand instead of \newcommand to define the ...
Piolie's user avatar
  • 133
3 votes

Level distance from edges in cyclic tree

An alternative is to use chains, which by default measures distance between node borders. The scopes library makes the code cleaner when you have a lot of branches. \documentclass{article} \...
Sandy G's user avatar
  • 41.5k
2 votes
Accepted

TikZ knots issue: circular "paper-cutout"s at intersections when using double

You need to set clip radius to something sensible. For testing, you can try: clip width=2, background color=yellow \documentclass[tikz, border=1cm]{standalone} \usetikzlibrary{knots} \begin{document} \...
hpekristiansen's user avatar
1 vote
Accepted

Improvement of my pgf plots figure

Here's a way to do it to obtain a stylized spectrum. Ad 2: Was already answered. Ad 3: Add minor x tick num=1, to have 1 minor between two major ticks Ad 1: change ymin=-10, AND \addplot[black,domain=...
MS-SPO's user avatar
  • 10.4k
1 vote

How to redraw a node with new options later in a tikzpicture?

Here's a more common approach: use iterations start with basic code refine and compile again that's dynamic in itself. The following example tries mimicking this process. Think of modifying your (M0)...
MS-SPO's user avatar
  • 10.4k
1 vote

Placing Node Somewhere Along A tikz Plot

Here's a simple solution: shift the node away (135deg, 1.5cm) from its position: ... node[right,shift=(135:1.5)] {$f(x) = \sin x$}; It may be less nice than using a pos-parameter, and it requires ...
MS-SPO's user avatar
  • 10.4k
0 votes
Accepted

Drawing a Non-Jagged Grid Outline

I don't know why using the padding of line width / 2 doesn't work. But, like @polyn mentioned in the comments, using line cap = rect does work, e.g.: \draw[..., line cap = rect] (0, 0) grid (10cm, ...
psygo's user avatar
  • 438
1 vote
Accepted

Book design and numbering of the chapters

Hope this is what you want: \documentclass[a4paper,12pt]{book} \usepackage{amsmath,amsfonts,amssymb,amsthm,mathrsfs} %\usepackage[utf8]{inputenc} \usepackage[french]{babel} \usepackage[T1]{fontenc} \...
Tom's user avatar
  • 6,763
0 votes

How to draw hebrew text around a circle?

Not an expert, but you seem to have set the path in the wrong order. The following works: \documentclass{article} \usepackage{tikz} \usepackage{fontspec} \usepackage{polyglossia} \usetikzlibrary{...
Niranjan's user avatar
  • 3,353
9 votes
Accepted

Vertical alignment issue with tikzpicture

The issue is that positioning commands measure distance from the edges of the nodes, not the centers. To measure from the center of the previous node, use right = 2cm of Spec-Gauss.center. To measure ...
Sandy G's user avatar
  • 41.5k
3 votes
Accepted

LuaLatex and intersection segments: Error only with Lua

If the code is compiled with LuaLaTeX then the intersection point at the origin is not found. This is probably due to rounding errors. If the domain in the line \addplot[domain=0:5, name path=f] {f(x)}...
matexmatics's user avatar
  • 3,579
1 vote

I have to draw a complete 5-sunlet graph and a 5-barbel graph. I have tried to draw them (code given below). But this is not precise

This should be pretty accurate: \documentclass[12pt]{article} \usepackage{tikz} \begin{document} \thispagestyle{empty} %Please, no page numbers or similar \begin{tikzpicture}[xscale=1, yscale=1] ...
Ronald's user avatar
  • 285
0 votes
Accepted

Package PGFPLOTS legend empty entry shift to left

You could use the trick from https://tex.stackexchange.com/a/204519/36296 to add your headline instead of the legend image: \documentclass{standalone} \usepackage{siunitx} \usepackage{pgfplots} \...
samcarter_is_at_topanswers.xyz's user avatar
0 votes

Plotting a closed parametric curve and shading the area inside it

A few years late! A solution with lualatex : tkz packages are not required ... % !TEX TS-program = lualatex \documentclass{article} \usepackage{tkz-base,tkz-elements} \begin{document} \begin{...
Alain Matthes's user avatar
2 votes
Accepted

Controlling Label Text in TikZ Nodes with \NewDocumentCommand: Including or Excluding Descriptions

You could set a optional token like this: \documentclass{article} \usepackage{tikz} \NewDocumentCommand{\myincludegraphics}{s O{0,0} O{1,1} t\displaytitle m}{% \IfBooleanTF{#1}{% \...
Tom's user avatar
  • 6,763
1 vote
Accepted

Controlling Coordinates of Rectangle in Image Inclusion

This can be easily achieved by xparse. Define star version of \myincludegraphics as default includegraphics without rectangle drawing. Then the non-star version will have two optional args to specify ...
Tom's user avatar
  • 6,763
4 votes
Accepted

Create command with decoration in Tikz

You could do this with a path picture in a sloped node. You can adjust minimum height and minimum width, and then also adjust the (relative) coordinates of the four lines. \documentclass{article} \...
Sandy G's user avatar
  • 41.5k
2 votes
Accepted

How to parse a `key[value]` string with the package listofitems

First, I must improve my ability to parse the SGF inputs, relative to my prior answer(s). Here is a short MWE just showing that parsing. I use listofitems to perform a 3-depth (nested) parsing: the ...
Steven B. Segletes's user avatar
6 votes
Accepted

How to automate this drop-cap-like effect

\documentclass[11pt]{article} \usepackage{lipsum,xcolor} \usepackage{lettrine} \begin{document} \rlap{\lettrine[ lines=8, loversize=-0.05, findent=-50pt,]{\color{gray!10}H}{}} \noindent How much \...
Fran's user avatar
  • 80k
0 votes

Evenly spaced grids with vertical measure

I suggest putting all three grids in one picture to ensure good alignment. I made a new node style called mygrid to make grid placement easier. The style draws the node and adds the grid as a path ...
Sandy G's user avatar
  • 41.5k

Top 50 recent answers are included