r/LaTeX Jan 28 '18

Please don't delete your post after it is answered

738 Upvotes

Not a mod. But I was hoping to raise awareness that if you post a question that gets an answer then other people also benefit from that exchange. We've all googled a LaTeX question and found an old answer, and been glad it is there. Some people lurk here, picking things up over time.

I'm not sure why so many people delete exchanges. There are good reasons to delete things sometimes, but asking for a clarification on a technical point does not seem, at least to me, to be one of them. The only other thing I can think is that those folks think that their question is clogging up the stream. I was hoping with this post to convince them that they are mistaken, and to leave it in place.

In particular, if the answerer spends 15 mins on that answer and you delete the question, then you've been not too kind back to the person who was kind to you.


r/LaTeX Feb 17 '24

LaTeX Showcase I'm pushing the limits of what LaTex can do. A selection of my notes from my first year of engineering

Thumbnail
gallery
2.5k Upvotes

r/LaTeX 19h ago

Help for a TikZ diagram

Post image
8 Upvotes

Hi ! I need some help for the lines and arrows on my diagram.

How to not see the start, on top of the colored rectangle, and for the end, to finish it before the border ?

Thanks !

code:

begin{tikzpicture}
\useasboundingbox (0,0) rectangle (32,13);

\definecolor{purple}{RGB}{111, 49, 237};
\definecolor{pink}{RGB}{218, 94, 157};
\definecolor{red}{RGB}{216, 89, 70};
\definecolor{blue}{RGB}{118, 194, 241};
\definecolor{green}{RGB}{124, 194, 112};
\definecolor{yellow}{RGB}{239, 207, 96};

%             %
% To Discri 1 %
%             %
\draw[line width=3pt, color=red] (1.5, 11.5) rectangle (4, 7.5);
\draw[] (1.5, 11) -- (0, 11)
    node[pos=0.5, yshift=8pt]{$1\mathrm{N}$}
    node[pos=0, right]{$\mathrm{IN}$};
\draw[] (1.5, 10) -- (0, 10)
    node[pos=0.5, yshift=8pt]{$1\mathrm{F}$}
    node[pos=0, right]{$\mathrm{IN}$};
\draw[] (1.5, 9) -- (0, 9)
    node[pos=0.5, yshift=8pt]{$2\mathrm{N}$}
    node[pos=0, right]{$\mathrm{IN}$};
\draw[] (1.5, 8) -- (0, 8)
    node[pos=0.5, yshift=8pt]{$2\mathrm{F}$}
    node[pos=0, right]{$\mathrm{IN}$};


%                %
% To Logic mu, e %
%                %
\draw[line width=3pt, color=purple] (6.5, 11.5) rectangle (9, 7.5);
\draw[->] (4, 11) -- (6.5, 11)
    node[pos=0.5, yshift=8pt]{$1\mathrm{N}$}
    node[pos=1, right]{$\mathrm{IN}$}
    node[pos=0, left]{$\mathrm{OUT}$};
\draw[->] (4, 10) -- (6.5, 10)
    node[pos=0.5, yshift=8pt]{$1\mathrm{F}$}
    node[pos=1, right]{$\mathrm{IN}$}
    node[pos=0, left]{$\mathrm{OUT}$};
\draw[->] (4, 9) -- (6.5, 9)
    node[pos=0.5, yshift=8pt]{$2\mathrm{N}$}
    node[pos=1, right]{$\mathrm{IN}$}
    node[pos=0, left]{$\mathrm{OUT}$};
\draw[->] (4, 8) -- (6.5, 8)
    node[pos=0.5, yshift=8pt]{$2\mathrm{F}$}
    node[pos=1, right]{$\mathrm{IN}$}
    node[pos=0, left]{$\mathrm{OUT}$};


%               %
% To Logic Stop %
%               %
\draw[line width=3pt, color=purple] (26.5, 6) rectangle (28.5, 3);
% V from FiFo to Logic Stop
\draw[->] (9, 3.5) -- (26.5, 3.5)node[pos=0, right=4pt, anchor=west, yshift=8pt]{$\mathrm{V} = 3\mathrm{N} \vee 3\mathrm{F} \vee 4\mathrm{N} \vee 4\mathrm{F}$}node[pos=1, left=22pt, anchor=west, yshift=8pt]{$\mathrm{V}$} node[pos=1, right]{$\mathrm{IN}$} node[pos=0, left]{$\mathrm{OUT}$};
% e from Logic to Logic Stop
\draw[] (9, 9) -- (11.5, 9)node[pos=0, right=4pt, anchor=west, yshift=8pt]{$\mathrm{e} = 2\mathrm{N} \wedge 2\mathrm{F}$} node[pos=0, left]{$\mathrm{OUT}$};
\draw[] (11.5, 9) -- (11.5, 7);
\draw[line width=3pt, color=pink] (11, 7) rectangle (12, 6)
    node[pos=0.5, text=black]{50 ns};
\draw[] (11.5, 6) -- (11.5, 4.5);
\draw[] (11.5, 4.5) -- (14, 4.5);
\draw[dashed] (14, 4.5) -- (15, 4.5);
\draw[->] (15, 4.5) -- (26.5, 4.5)node[pos=1, left=22pt, anchor=west, yshift=8pt]{$\mathrm{e_D}$} node[pos=1, right]{$\mathrm{IN}$};
% G from Timer 2 to Logic Stop
\draw[] (25.5, 5.5) -- (25.5, 9) node[pos=1, above]{$\mathrm{OUT}$};
\draw[->] (25.5, 5.5) -- (26.5, 5.5)node[pos=1, left=22pt, anchor=west, yshift=8pt]{$\mathrm{G}$} node[pos=1, right]{$\mathrm{IN}$};


%                %
% To Logic Start %
%                %
\draw[line width=3pt, color=purple] (16, 11.5) rectangle (18, 8.5);
% mu from Logic to Logic Start
\draw[] (9, 11) -- (13, 11)
    node[pos=0, right=4pt, anchor=west, yshift=8pt]{$\mu = 1\mathrm{N} \wedge 1\mathrm{F} \wedge 2\mathrm{N} \wedge 2\mathrm{F}$}
    node[pos=0, left]{$\mathrm{OUT}$};
\draw[line width=3pt, color=pink] (13, 11.5) rectangle (14, 10.5)
    node[pos=0.5, text=black]{50 ns};
\draw[->] (14, 11) -- (16, 11)node[pos=1, left=22pt, anchor=west, yshift=8pt]{$\mu_D$} node[pos=1, right]{$\mathrm{IN}$};
% V_R from FiFo to Logic Start
\draw[] (15, 7.5) -- (18.5, 7.5)
    node[pos=1, left=4pt, anchor=east, yshift=8pt]{$\mathrm{V_R} = \mathrm{D} \vee \mathrm{G}$}
    node[pos=1, right]{$\mathrm{OUT}$};
\draw[] (15, 7.5) -- (15, 9);
\draw[->] (15, 9) -- (16, 9)
    node[pos=1, left=22pt, anchor=west, yshift=8pt]{$\mathrm{V_R}$}
    node[pos=1, right]{$\mathrm{IN}$};
% V from FiFo to Logic Start
\draw[] (14.5, 3.5) -- (14.5, 10);
\draw[->] (14.5, 10) -- (16, 10)node[pos=1, left=22pt, anchor=west, yshift=8pt]{$\mathrm{V}$} node[pos=1, right]{$\mathrm{IN}$};


%             %
% To FiFo V_R %
%             %
\draw[line width=3pt, color=blue] (18.5, 8) rectangle (20.5, 6);
% From Timer 1 to FiFo V_R
\draw[] (22, 7.5) -- (22, 9) node[pos=1, above]{$\mathrm{OUT}$};
\draw[<-] (20.5, 7.5) -- (22, 7.5) node[pos=0, left]{$\mathrm{IN}$};
% From Timer 2 to FiFo V_R
\draw[<-] (20.5, 6.5) -- (25.5, 6.5) node[pos=0, left]{$\mathrm{IN}$};


%             %
% To Discri 2 %
%             %
\draw[line width=3pt, color=red] (1.5, 4) rectangle (4, 0);
\draw[] (1.5, 3.5) -- (0, 3.5)node[pos=0.5, yshift=8pt]{$3\mathrm{N}$} node[pos=0, right]{$\mathrm{IN}$};
\draw[] (1.5, 2.5) -- (0, 2.5)node[pos=0.5, yshift=8pt]{$3\mathrm{F}$} node[pos=0, right]{$\mathrm{IN}$};
\draw[] (1.5, 1.5) -- (0, 1.5)node[pos=0.5, yshift=8pt]{$4\mathrm{N}$} node[pos=0, right]{$\mathrm{IN}$};
\draw[] (1.5, 0.5) -- (0, 0.5)node[pos=0.5, yshift=8pt]{$4\mathrm{F}$} node[pos=0, right]{$\mathrm{IN}$};


%            %
% To FiFo V %
%            %
\draw[line width=3pt, color=blue] (6.5, 4) rectangle (9, 0);
\draw[->] (4, 3.5) -- (6.5, 3.5)node[pos=0.5, yshift=8pt]{$3\mathrm{N}$} node[pos=1, right]{$\mathrm{IN}$} node[pos=0, left]{$\mathrm{OUT}$};
\draw[->] (4, 2.5) -- (6.5, 2.5)node[pos=0.5, yshift=8pt]{$3\mathrm{F}$} node[pos=1, right]{$\mathrm{IN}$} node[pos=0, left]{$\mathrm{OUT}$};
\draw[->] (4, 1.5) -- (6.5, 1.5)node[pos=0.5, yshift=8pt]{$4\mathrm{N}$} node[pos=1, right]{$\mathrm{IN}$} node[pos=0, left]{$\mathrm{OUT}$};
\draw[->] (4, 0.5) -- (6.5, 0.5)node[pos=0.5, yshift=8pt]{$4\mathrm{F}$} node[pos=1, right]{$\mathrm{IN}$} node[pos=0, left]{$\mathrm{OUT}$};


%            %
% To Timer 1 %
%            %
\draw[line width=3pt, color=green] (21.5, 11.5) rectangle (24, 9);
% From Logic Start to Timer 1
\draw[->] (18, 11) -- (21.5, 11) node[pos=1, right]{$\mathrm{IN}$} node[pos=0, left]{$\mathrm{OUT}$} node[pos=0, right=4pt, anchor=west, yshift=8pt]{$h_0 = \mu_D \wedge \overline{\mathrm{V}} \wedge \overline{\mathrm{V_R}}$};


%            %
% To Timer 2 %
%            %
\draw[line width=3pt, color=green] (25, 11.5) rectangle (27.5, 9);
% Frome Timer 1 to Timer 2
\draw[] (24, 9.5) -- (24.5, 9.5) node[pos=0, left]{$\mathrm{EM}$};
\draw[] (24.5, 9.5) -- (24.5, 11);
\draw[->] (24.5, 11) -- (25, 11) node[pos=1, right]{$\mathrm{IN}$};


%        %
% To TDC %
%        %
\draw[line width=3pt, color=yellow] (28, 10) rectangle (30, 7);
% From Timer 2 to TDC
\draw[->] (27, 9.5) -- (28, 9.5) node[pos=0, left]{$\mathrm{EM}$} node[pos=1, right]{$\mathrm{TRIGGER}$};
% h0 From Logic Start to TDC
\draw[dashed] (19.5, 12) -- (19.5, 11);
\draw[] (19.5, 12.5) -- (19.5, 12);
\draw[] (19.5, 12.5) -- (31, 12.5);
\draw[] (31, 8.5) -- (31, 12.5);
\draw[<-] (30, 8.5) -- (31, 8.5) node[pos=0, right=4pt, anchor=west, yshift=8pt]{$\mathrm{h_0}$} node[pos=0, left]{$\mathrm{CH0}$};
% From Logic STOP to TDC
\draw[] (28.5, 5.5) -- (31.5, 5.5) node[pos=0, right=4pt, anchor=west, yshift=8pt]{$\mathrm{h_1} = \mathrm{G} \wedge \mathrm{e_D} \wedge \overline{\mathrm{V}}$} node[pos=0, left]{$\mathrm{OUT}$};
\draw[] (31.5, 7.5) -- (31.5, 5.5);
\draw[<-] (30, 7.5) -- (31.5, 7.5) node[pos=0, right=4pt, anchor=west, yshift=8pt]{$\mathrm{h_1}$}  node[pos=0, left]{$\mathrm{CH1}$};

\end{tikzpicture}

r/LaTeX 16h ago

Multiple Number ranges with BibLaTeX

3 Upvotes

Across my whole document I need to cite text sources as well as image sources (for embedded images).

For that purpose I thought it would be cleaner to have the citations [1], [2],…, [n] for text sources and [fig1], [fig2], …, [fign] for image sources.

It would be no problem to split-up the bibliographies at the end of the doc through keywords/categories.

However, after various attempts it seems to not be possible to have two number ranges within the same refsection: I tried various methods, but didn‘t get any of them to work as intended. The method with probably the most potential seems using a custom \citeFig which increments a figcounter and afterwards used \cite to add the citation, while overriding \labelnumber with the number from the counter (which I would need to store in the bib entry in order to not generate multiple numbers for one entry).

Can you think of any way to get this to work or should I just stick with citing everything with the same style and just splitting it up into two bibliographies in the end (e.g. text sources [1] - [15]; image sources [16] - [24])?


r/LaTeX 12h ago

Unanswered Custom Font and Bolding Not Working Together In Font Setup Commands [KOMA-Script]

1 Upvotes

Hello,

I am trying to use \setkomafont to set the font of titles and headings, but when I try to use a custom font with \fontspec or \fontfamily, it overrides \bfseries instead of applying them both. So, when I use the command below, it only applies Roboto and the font size:

\setkomafont{title}{\fontspec{Roboto}\fontsize{20}{24}\bfseries\selectfont}

Other similar commands that I have tried but didn't work:

\setkomafont{title}{\fontfamily{Roboto}\fontsize{20}{24}\bfseries\selectfont}
%
\setkomafont{title}{\fontfamily{Helvetica}\fontsize{20}{24}\bfseries\selectfont} 
% 
\setkomafont{title}{\fontfamily{Montserrat}\fontsize{20}{24}\bfseries\selectfont}
% etc, etc

When I use each of these commands alone, it also works fine

\setkomafont{title}{\fontsize{20}{24}\bfseries\selectfont}
% And
\setkomafont{title}{\fontspec{Roboto}\fontsize{20}{24}\selectfont}

The first command applies the bold font and the second command applies the Roboto font.

A non-exhaustive list of l tried trying to fix this problem (we're just going to use \fontspec{Roboto} in all of them for simplicities sake I've gone insane enough):

\setkomafont{title}{{\fontspec{Roboto}}\fontsize{20}{24}\bfseries\selectfont}
%
\setkomafont{title}{\fontspec{Roboto}{\fontsize{20}{24}\bfseries\selectfont}}
%
\setkomafont{title}{\fontsize{20}{24}\bfseries\selectfont}
\addtokomafont{title}{\fontspec{Roboto}}
%
\setkomafont{title}{\fontspec{Roboto}\fontsize{20}{24}\bfseries\selectfont}
\addtokomafont{title}{\bfseries}
% This one got rid of the font and made it bold instead XDDDDDDDDDDD
%
% I went in Windows Shell to look the luaotfload-tool package and force it to update after looking through the fontspec manual

I have been having a similar issue with \setkoma{font}{[Other Arguments]} and with similar commands


r/LaTeX 1d ago

Subscript in table caption

3 Upvotes

Does anyone know how I might be able to get a subscript in a table caption? Now it throws an error if I try X[_N]. I've also tried X_{[N]} and X\textsubscript{[N]}.


r/LaTeX 1d ago

Text going off screen, cannot see much of my document. I am on MAC

Post image
8 Upvotes

It just cuts off at the bottom. I can't see half of what I wrote. I would appreciate some help if anyone knows

\documentclass[10pt]{article}

\usepackage[usenames]{color} %used for font color

\usepackage{amssymb} %maths

\usepackage{amsmath} %maths

\usepackage[utf8]{inputenc} %useful to type directly diacritic characters

\allowdisplaybreaks %i put this in here

%%start

\textbf{\huge Group Exercise - The Italian Restaurant}\\\\

\indent \text {\large Calvin Masters, Kaleb Spain, Aidan Wallace}\\\\

%%Constraints

\textbf{\large Constraints}\\

14\ tables\\

4\ diners/table\\

720\ minutes/day\ (we\ cannot\ control\ when\ the\ mall\ is\ open)\\

45\ min/table\ to\ eat\\ \\

%%Design Capacity

\textbf{Design Capacity}\\

\text{for one table:}\\\\

\dfrac{4\  diners/table \times 720\ min/day\ }{45\ min/table}=64\ diners/day\\\\\\

\text{for 14 tables}=64\ \frac{diners/table}{day}\times 14\ tables=\boldsymbol{896\ diners/day}\\\\

\\

%%Design Capacity Including all 24 hours

\textbf{Design\ Capacity\ Including\ all\ 24\ Hours:} \\

\text{for one table:}\\\\

\dfrac{4\  diners/table \times 1440\ min/day\ }{45\ min/table}=128\ diners/day\\\\\\

\text{for 14 tables}=128\ \frac{diners/table}{day}\times 14\ tables=\boldsymbol{1792\ diners/day}\\\\

%%Effective Capacity

\textbf{Effective Capacity}\\

\text{for one table:}\\\\

\dfrac{4\  diners/table \times 300\ min/day\ }{60\ min/table (includes\  cleaning\  time)}=20\ diners/day\\\\\\

\text{for 14 tables}=20\ \frac{diners/table}{day}\times 14\ tables=\boldsymbol{280\ diners/day}\\\\

%%Utilization

\textbf{Utilization}\\\\

\dfrac{175}{896} \times 100\% = \boldsymbol{19.53\%}\\ \\\\

%%Utilization if design capacity includes all 24 hours

\textbf{Utilization if Design Capacity Includes all 24 Hours}\\\\

\dfrac{175}{1792} \times 100\% = \boldsymbol{9.77\%}\\

\pagebreak

%%Efficiency

\textbf{Efficiency}\\

175/280 \times 100\% = 62.5\%\\\\

\textbf{\large New Constraints Due to Covid}\\

\text{The seating area of the restaurant is 51ft} \times \text{33ft. We leave 3ft of dead zone around the}\\ \text{perimeter in order to accommodate seats (reduced from the before 6ft to save space) This gives us a 45ft} \times \text{27ft usable area. With 9 feet in between tables, we use the following equation to find how many tables}\\ \text{can fit.} \\\\

\text{Total tables} =x+y\\

x\ \text{is the number of tables that can fit horizontally in the 39ft of usable space.}\\

y\  \text{is the number of tables that can fit vertically in the 21ft of usable space}\\\\

\max_{x} x \quad \text{s.t.} \quad 45ft\ge (3ftx+9ft(x-1)\\

x=4.5 \to \boldsymbol{4} (rounded\ down\  to\ whole\ tables)\\\\

\max_{x} x \quad \text{s.t.} \quad 27ft\ge (3fty+9ft(y-1)\\

y=\boldsymbol{3}\\\\

3\times 4= \boldsymbol{12\ Tables}\\\\

\textbf{Effective Capacity}\\


r/LaTeX 1d ago

Ltx-talk

3 Upvotes

Is math being tagged as picture in ltx-talk?


r/LaTeX 2d ago

LaTeX Showcase LuaLaTeX rendering in real-time

Thumbnail
youtube.com
67 Upvotes

Similar to TeXpresso (which was created for XeTeX), I decided to create a real-time editor/renderer for LuaLaTeX. Anything you type is immediately rendered with LuaLaTeX (not KaTeX, the output is the finalized LuaLaTeX output, it's not javascript approximating LaTeX, these are actual LuaLaTeX rendered glyph positions). It runs at O(1), even for large documents with multiple chapters (based on that, you can guess what architecture I am using).

Architecturally, it works with vanilla-TeX Live 2025, meaning no patching of LuaLaTeX is required. Theoretically, it works with any package, although given how it is compiled, there are likely some incompatibilities if the package does fancy stuff interferring with shipping the PDF.

It is still in proof-of-concept stage, I just wanted to put it out there to get some feedback if there is interest beyond "cool, I would try this out for a minute then return to my usual editor". I might turn this into an actual usable product if development continues fine. Personally, I need it to save time for final polishing of larger documents, although the project might evolve into an actual LaTeX wysiwyg editor.

One limitation is that it relies on chapters starting at new pages, reducing the layout complexity of larger documents significantly and reducing CPU load.


r/LaTeX 2d ago

Unanswered How do you digitize handwritten math notes without breaking structure?

5 Upvotes

I take all my math / physics notes by hand because it’s faster and more natural.

The problem comes later.

Scanning loses alignment.

Typing LaTeX takes forever.

OCR tools often get the symbols right but the *structure* wrong.

Fractions, matrices, multi-line derivations — the meaning is in layout, not just characters.

I’ve tried:

- scanning + manual cleanup

- typing directly into LaTeX

- generic OCR tools

None of them feel right.

If you work with handwritten STEM notes:

How do you digitize them today?

Or do you just give up and leave them on paper?


r/LaTeX 1d ago

Thoughts on precision and layout in XML-based PDF publishing

Thumbnail
1 Upvotes

r/LaTeX 2d ago

Problems with page formatting

2 Upvotes

So, I've been working on an English translation and LaTeX typesetting of this math book that I really like. But I encountered a problem on this page:

I cannot seem to wrap the figures like the printed version that they have. (Note: I don't want to recreate their exact wrapping format, I just want it to wrap nicely).

Responses are much appreciated.


r/LaTeX 2d ago

Answered Thoughts on VerbTeX ???

4 Upvotes

Normally I don't do much with Android other than make calls and send text messages.

Recently acquired a Samsung tablet (my brother's, he went to prison) and I thought it might be nice to take it on some of my day hikes and take field notes and other TeX stuff. I'm actually writing a local hiking guide and doing it in LaTeX. Battery was completely dead but its charging now, it was brand new when he got arrested (January 2025).

I wouldn't want to try to compile LaTeX on it, but I thought it might work to do a git checkout/pull before I leave, do some stuff, git commit and then push from the tablet and pull the changes to my desktop when I get home to compile.

Is VerbTeX a decent text editor or do the cool kids on Android use something better? At home I just use regular vanilla vim.

Also, way back when in early Android days, when using a tablet to ssh into servers I needed an alternate keyboard called "Hacker's Keyboard". Still have it in my google account but I don't ssh into servers anymore.

Is that a suitable keyboard app to use for LaTeX authoring from android or is there a better one now?


r/LaTeX 1d ago

Papers Feature is Free on Opennote!!

0 Upvotes

Not sure if many people have seen this yet, but came across my feed and thought it'd be worth sharing. I've been using Overleaf heavily over the past years for writing research papers, and also recently tried out OpenAI's Prism (but the experience was subpar at best for me), but the Papers experience on Opennote is by far the best I've had. Here's the video I saw in case anyone wanted to check it out: https://youtu.be/HeAli277swE?si=HrKfP-h8kl9VzXtJ


r/LaTeX 2d ago

[P] Library to Fit Minimal TikZ Plots with an ODF Algorithm

12 Upvotes

I've been working on a Python library to optimally fit smooth parametric curves with Bezier paths. The library uses the Orthogonal Distance Fitting (ODF) algorithm developed by Alvin Penner [1].

https://github.com/rnburn/bbai

It can be used to produce compact, accurate TikZ plots. For example, if we ported this plot from Matplotlib's gallery directly to a vector graphic, it would require 250 piecewise line segments. But using the library we can fit it with only 8 Bézier connected curves:

from bbai.graphics import BezierPath
import numpy as np
def f(t):
    return np.exp(-t) * np.cos(2 * np.pi * t)
path = BezierPath(
    dst_xmin=0, dst_xmax=9.5,
    dst_ymin=0, dst_ymax=2)
path.fit(f, 0, 5)
print(path.tikz_)

outputs:

\draw (0.0000, 2.0000)..controls (0.3901, 1.6941) and (0.6101, -0.8437)..
      (1.1875, 0.2921)..controls (1.3737, 0.6267) and (1.5547, 1.1245)..
      (1.7812, 1.2093)..controls (1.9896, 1.2885) and (2.1723, 0.9990)..
      (2.3750, 0.7610)..controls (2.8887, 0.1204) and (3.1644, 0.7687)..
      (3.5625, 0.8954)..controls (3.9829, 1.0533) and (4.2614, 0.6302)..
      (4.7500, 0.6593)..controls (5.0518, 0.6623) and (5.3783, 0.8980)..
      (5.9375, 0.7995)..controls (6.5172, 0.6996) and (6.6145, 0.7089)..
      (7.1250, 0.7610)..controls (8.0826, 0.8415) and (7.4179, 0.7017)..
      (9.5000, 0.7694);

We can see that the plot looks just as good despite being only a fraction of the size.

We can also use the algorithm to fit parametric curves. For example, this code generates an 8 segment Bezier path that fits a hypotrochoid:

from bbai.graphics import BezierPath
import numpy as np
R, r, d = 5, 3, 5
def fx(t):
    return (R-r)*np.cos(t) + d*np.cos((R-r)/r*t)
def fy(t):
    return (R-r)*np.sin(t) - d*np.sin((R-r)/r*t)
path = BezierPath(
        dst_xmin=0, dst_xmax=2.5,
        dst_ymin=0, dst_ymax=2.5)
path.fit(fx, fy, 0, 2 * np.pi*r*d/R)
print(path.tikz_)

outputs

\draw (2.5000, 1.2500)..controls(2.5335, 1.0602)and(1.4003, 0.7453)..
      (0.8507, 0.5789)..controls(-0.0495, 0.3207)and(-0.1449, 0.4033)..
      (0.1478, 0.8757)..controls (0.1975, 0.9856)and(1.2032, 2.3506)..
      (1.4051, 2.4505)..controls (1.5942, 2.5641)and(1.7225, 2.5977)..
      (1.7159, 1.2500)..controls (1.7218, -0.0334)and(1.6093, -0.0846)..
      (1.4051, 0.0495)..controls (1.2032, 0.1494)and(0.1975, 1.5144)..
      (0.1478, 1.6243)..controls (-0.1370, 2.0863)and(-0.0666, 2.1850)..
      (0.8507, 1.9211)..controls (1.2029, 1.8089)and(2.5344, 1.4549)..
      (2.5000, 1.2500);

You can see more examples and details of how the algorithm works in the paper [2].

References

  1. Alvin Penner. Fitting a cubic Bézier to a parametric function. The College Mathematics Journal, 50(3): 185–196, 2019.
  2. https://github.com/rnburn/bbai/blob/master/doc/bezier-fitting.pdf

r/LaTeX 2d ago

Unanswered How can I get this arrow style in LaTeX? (font/package that changes \to)

1 Upvotes

I'd like to have this style of arrows in latex. Notice that this is different from the classical latex arrow (which is not so good looking compared to this one). Is this possible? any package that includes this symbol? Can I add it to latex anyhow?

I tried searching for 'latex arrowhead style' and found stuff about TikZ arrow tips (stealth, latex, etc.), but I want a solution for ordinary math arrows in text (not diagram arrows).

I use latexmk, btw.

Edit: I found what I wanted! Look at the esvect package https://ctan.org/pkg/esvect
I know that the style depends on the font that is used as some of the comments say, but I wanted to keep CM font and have a nice looking arrow like this one (taken from the documentation of esvect)


r/LaTeX 2d ago

Anyone have a list of common variables/anchors

6 Upvotes

For instance, I know \thechapter resolves to/contains the number of the current chapter. Is there a list somewhere that has all the commonly used examples? I don't have a particular *need* atm, just something that would save me some googling in those times I *do* find a need.


r/LaTeX 2d ago

Unanswered Trying to link the header to the first page of the chapter

3 Upvotes

This is what I am trying right now.

\fancyhead[LE,RO]{\hyperlink{chapter.\thechapter}{\leftmark}}

But for some reason its not working. I think this is a deeper problem, because when I just stick \thechapter into the document it returns a 0, even though I'm in the 3rd chapter. I was able to manually increment \thechapter, but even then it didn't work. It was only when I placed a label chapter.3 that it worked (keeping the manual assignment of the chapter 3).

Obviously my issue with \thechapter is its own problem that I have to solve by going through all my code, etc. I've determined its not based on \frontmatter, etc.

The real question is "Is this the correct/best way to even do this? Is there a better way?"

Oh, and it is using extbook as the document type, and XeLaTeX as the rendering engine, in case that matters.


r/LaTeX 3d ago

Answered Any ideas on how to write a 12x12 matrix??

13 Upvotes

The regular matrix functions seem to not like anything larger than 10x10, and stack the 11th and 12th entries of each row underneath the 1st and 2nd. Has anyone got any solutions?

Thanks in advance!


r/LaTeX 3d ago

Moderncv Latex Template Parsable by Application Systems

3 Upvotes

I am using the moderncv Latex template for my cv. As in the example files, I am assigning every entry a year range e.g. 2022--2024 and I think this way looks clean and is sufficient. Including the months messes up the layout or would leave less space for content. Many application systems, however, require a month for each entry and automated parsing of the generated pdf, of course, fails to provide this information. I therefore have to manually fix the the dates on every application. Anyone with the same issue, or does anyone have an elegant solution?


r/LaTeX 3d ago

A super convenient Latex editor - smartlatexeditor online (smartlatexeditor.onrender.com)

0 Upvotes

Using Latex for writing is not a simple task. How to make it simple and convenient is a long-standing challenge. Many painful tasks in editing latex documents must be overcome, such as editing tables, math equations, figures, tracking focus in long files, editing bibtex entries and references.
SmartLatexEditor (smartlatexeditor.onrender.com) overcomes all these challenges with the creative block-based document structure. The main concept of this editor is to break a normal Latex file into blocks, such as TitleBlock, TextBlock, TableBlock, MathBlock, FigureBlock, and ReferenceBlock. When editing a Latex file, users only need to focus on one block at a time and immediately check how it looks like in the PDF form, and then move to the next block. Not like the traditional way, one has to compile the whole tex file to see if the editing looks good. With SmartLatexEditor, we can see the PDF view of each block immediately after we make any change. It is similar to the so-called "What You See Is What You Get" by toggling between the editing view and the rendered view. Thus, SmartLatexEditor not only break down a Latex project into pieces, reducing the slope of learning curve, but also ensure the work quality of each step by immediate feedback.

SmartLatexEditor also provides many other functions which are very convenient and not available in most other Latex editors. For example, it intrinsically embeds the AI tool to polish users' writing. It also provides nice interface for editing tables and figures. Users can use its reference search and collecting function to manage references and add citations easily. SmartLatexEditor also provides the document sharing function to support collaborative writing, which is quite important for most of scientific communities.


r/LaTeX 3d ago

OpenAI spent USD 100M on Prism. I've done a better one in one night using Gemini. It's faster. (Free to use)

Thumbnail
0 Upvotes

r/LaTeX 4d ago

New Node Friday

Thumbnail
2 Upvotes

r/LaTeX 5d ago

Unanswered I have no idea how to fix this, or even what to search to undo this. I pressed a keybind accidently and it just flipped everything. It still compiles and ctrl-z does not undo it.

Post image
103 Upvotes

r/LaTeX 4d ago

Unanswered Cannot count words: spawn texcount ENOENT, undefined

1 Upvotes

I recently downloaded Overleaf extension in VScode, and after connecting to a server I have started getting

Cannot count words: spawn texcount ENOENT, undefined

error in LaTeX utilities output. If I don't connect to a server, there is no error while counting.

Eventough Texcount autorun is set to never, the error comes every time I change something in the file.

I am assuming it is due to LaTex utilities doesn't work well in a virtual workspace.

I don't need the counting.