Designing gears is very difficult for a variety of reasons. Let me list what you should take into account:
The shape of the teeth are very peculiar, trapezoid shape will not work as the meshing will not be constant. Exact shape is controlled by the pressure angle
In lower number of teeth, teeth shape must be modified to avoid any locks, these are called cutoffs
Reducing the amount of material to print requires careful design, most people simply place circles but they cause weak points.
Herringbone and double herringbone gears improve meshing but are even more difficult to design.
For the reasons stated above, creating gears by hand is next to impossible without special tools. Luckily for those who are searching for it, there are systems that generate gears for 3D printing. This customizer has many options and is very open about the licensing, which is another issue with many scripts. For example, it is explicitly forbidden to print parts imported from the McMaster-Carr Catalogue.
If you use OpenSCAD, this library can create racks to go with the gears.
The parameters of the customizer are explained in the page. The script also contains explanations of every module and function.
Disclaimer: Both scripts are mine, yet I do not earn anything when people use them. I created the library when I was unable to find the gears I needed, published with a relaxed license to help others.