0
  • I'd like to change my font style in all equations of one document, not just a single equation. The font applied now is

enter image description here

  • I found the same question here, but it isn't working for me.

How can I change the font of all equations?

  • I mean, how do you force Latex to change the entire font style of equations? This font style for example :

enter image description here

The list of packages that i used

\documentclass[11pt,a4paper]{article}
\usepackage[left=1.5cm,top=1cm,right=1.5cm,bottom=60pt]{geometry}
\usepackage[T1]{fontenc}
\usepackage{amsmath,bm}
%\usepackage{kpfonts}
\usepackage[math]{blindtext}
%\usepackage[utf8]{inputenc}

\usepackage{kpfonts} %% To show that the equation is important or not \usepackage{bm}

%\usepackage[utf8]{inputenc}
\usepackage[english]{babel} % 'french', 'german', 'spanish', 'danish', etc.

%% To set time \usepackage{datetime} %\date{\currenttime}

%%% for set page number at right footer

\usepackage{fancyhdr} %%\usepackage{lipsum} % %% Turn on the style %\pagestyle{fancy} %% Clear the header and footer %%\fancyhead{} % %%\fancyfoot{} % %% Set the right side of the footer to be the page number %\fancyfoot[R]{\thepage} \pagestyle{fancy} \fancyhf{}% to clear existing header/footer if you don't want it \renewcommand\headrulewidth{0pt} %\cfoot{abc} \usepackage{lastpage} \fancyfoot[R]{\thepage\ of \pageref{LastPage}} %\cfoot{\thepage\ of \pageref{LastPage}} %\cfoot{\thepage\ of \pageref{LastPage}}

\newcounter{mypagecount}% create a new counter \setcounter{mypagecount}{0}% set it to something just in case \newenvironment{interlude}{% create a new environment for the unnumbered section(s) \clearpage \setcounter{mypagecount}{\value{page}}% use the new counter we created to hold the page count at the start of the unnumbered section \thispagestyle{empty}% we want this page to be empty (adjust to use a modified page style) \pagestyle{empty}% use the same style for subsequent pages in the unnumbered section } {% \clearpage \setcounter{page}{\value{mypagecount}}% restore the incremented value to the official tally of pages so the page numbering continues correctly }

%% To draw application fram \usepackage[latin1]{inputenc} \usepackage{tikz} \usetikzlibrary{patterns} \usepackage{verbatim}

%% To do list \usepackage{enumitem,amssymb}

% For lettrine
\usepackage{lettrine} \renewcommand{\LettrineTextFont}{\normalfont}

% For fancy chapter %\usepackage[Bjornstrup]{fncychap} %Bjornstrup

%% For minus shorter %\usepackage{amsfonts} %% <- also included by amssymb %\DeclareMathSymbol{\shortminus}{\mathbin}{AMSa}{"39} %\usepackage{mathpazo} %% <- because the OP uses mathpazo, optional

% for graphics .eps \usepackage{graphicx, epstopdf} % for section numbering figure - caption %\usepackage{chngcntr} %\numberwithin{figure}{section} \usepackage{chngcntr} \counterwithin{figure}{section}

% caption \usepackage{caption} \usepackage{subcaption} \captionsetup[figure]{name=Fig, labelsep=period, labelfont=bf} % hyperref \usepackage{url} \usepackage{hyperref} % math \usepackage{amssymb} \usepackage{amsmath} % Landscape \usepackage{pdflscape} % forest \usepackage{forest} % enumerate \usepackage{enumerate} \usepackage{enumitem} %\usepackage{itemize}

\usepackage{txfonts} \usepackage{mathdots} \usepackage[classicReIm]{kpfonts} \usepackage{graphicx}

%% For Tables / Tabular \usepackage{tabularx} %\usepackage{tabfigures} %\usepackage{tableau} %\usepackage{newpsstyle}

\usepackage{mathtools} % longtable \usepackage{longtable} %\usepackage{endheads} % color table \usepackage{colortbl} %\usepackage[table]{xcolor} % Space between columns \setlength{\tabcolsep}{14pt} % Space between rows \renewcommand{\arraystretch}{1.8} % for multirow tabular \usepackage{multirow}

\usepackage{amsmath,amssymb ,amsfonts,xcolor,tikz} \usepackage{multicol} \usepackage{enumitem}

%% For capitale letter \usepackage{stackengine,scalerel}

%%%%%%%%% Answer proposed for the Problem Box \usepackage{tikz,contour} \usepackage[most]{tcolorbox} \usepackage{amsmath,amssymb} \usepackage{multicol} \usepackage{pgf,tikz,pgfplots} \pgfplotsset{compat=1.15} \usepackage{mathrsfs} \usetikzlibrary{arrows} \definecolor{candyapplered}{rgb}{1.0, 0.03, 0.0} \definecolor{lime(colorwheel)}{rgb}{0.75, 1.0, 0.0} \usetikzlibrary{shapes.geometric} \renewcommand{\labelenumi}{% \begin{tikzpicture}[baseline=(1.base)] \nodedraw,regular polygon,regular polygon sides=4,inner sep=.5mm,fill=white,font=\bfseries{\arabic{enumi}}; \end{tikzpicture}} \renewcommand{\labelenumii}{% \begin{tikzpicture}[baseline=(1.base)] \nodedraw ,inner sep=.5mm,fill=white,font=\bfseries\footnotesize,minimum size=5mm{\alph{enumii}}; \end{tikzpicture}}

\usepackage{fancyhdr} \usepackage{multirow} %\cfoot{\thepage/\pageref{LastPage}}

%% Definition Box \usepackage[most]{tcolorbox} %\newsavebox{\mybox}

%% To include pdf file \usepackage{pdfpages} % Make ligatures and stuff copiable from pdf: \input{glyphtounicode} \pdfgentounicode=1

%% For Flow chart %\usepackage[tmargin=2cm,bmargin=1cm]{geometry} \usepackage{tikz} \usetikzlibrary{shapes,snakes}

%% For title format -- Section Style %% to change font color %\usepackage{xcolor} %\usepackage{sectsty} %\sectionfont{\color{col1}}

%\usepackage{titlesec} %block %display %drop %leftmargin %wrap

%\usepackage{xcolor} \usepackage[explicit]{titlesec} \usepackage[dotinlabels]{titletoc}

%% for bib \usepackage{nameref}

%% For Fancy Part

%% For Draw PV module \usepackage{circuitikz} \usetikzlibrary{calc}

%% For minitoc of a subsection %\usepackage{times} \usepackage{minitoc} \usepackage{mdframed} %\usepackage[undotted]{minitoc} % remove dots from minitoc

%% To Force figure placement in text %https://tex.stackexchange.com/questions/8625/force-figure-placement-in-text % Don't use the center environment but the \centering command for figures. \usepackage{placeins} % Or the shirt answer \usepackage{float} %\begin{figure}[H]

%% Quad-Rotor Draw %\usepackage{float} \usepackage{listings} \usepackage{color} \usepackage{textcomp} \usepackage{graphicx} %\usepackage{tikz} \usepackage{tikz-3dplot} \usepackage{relsize}

%\usepackage{blindtext} \newcommand{\CoverName}{Cover} \newcommand{\RefName}{Ref}

%% For Smile Face \usepackage{tikz-network}

%% Write text in a shape of heart %\usepackage{fontspec,microtype,shapepar,xcolor} %\setmainfont{TeX Gyre Chorus} %\documentclass{article} \usepackage{blindtext} \usepackage{shapepar}

Thanks.

David Carlisle
  • 757,742
Sam
  • 11
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 07 '21 at 13:18
  • I want to apply the font style presented in the second image to all equations in the document. – Sam Sep 07 '21 at 13:29
  • 1
    unlike text a math formula typically uses up to 16 different fonts each at three sizes so usually people use a package that sets everything up. If you said what font set you wanted (rather than make peope guess from an image) someone could tell you which package to use. If you have the pdf of that image the pdffonts utility or the font menu in your viewer should show the fonts used – David Carlisle Sep 07 '21 at 13:32
  • in your image for example almost certainly the x and y come from one font, the = s i n come from another and the 2 comes from a third. – David Carlisle Sep 07 '21 at 13:34
  • That said the y=sin^2 x example looks like the default computer modern font so all you have to do is use the standard settings. The first example seems to be taken from an answer showing the kpfonts from \usepackage{kpfonts} – David Carlisle Sep 07 '21 at 13:39
  • I use this package \usepackage{kpfonts} as you mentioned, but did not work with me. And I received the following message error about it: Option clash for package kpfonts. \usepackage – Sam Sep 07 '21 at 13:45
  • As with any programming language if you want help with a coding error you need to show your code and show what error you got, and also show what you want the code to do. (your desired output as shown in the y=sin" x image is not using kpfonts) look at the answer I posted and the answers in the question you reference each contains complete documents. You have shown no information at all. – David Carlisle Sep 07 '21 at 13:48
  • in the code you show you have multiple conflicting packages, only load packages that you use start from an empty preamble. You load kpfonts package to deletc kp fonts then you load txfonts package which undoes that and selects the tx fonts remove both those package to get the default set. You should delete almost all of that preamble it is doing nothing useful other than making it confusing, you load tikz 5 !!! times for example, bm is loaded twice, and do you really need shapepar in the document to have heart shaped paragraphs? – David Carlisle Sep 07 '21 at 14:22
  • are you sure you are using the legacy latin1 (iso-8859-1 encoding) almost all editors (and this website) use UTF-8 by default these days. You probably should remove \usepackage[latin1]{inputenc} never load both of these at the same time \usepackage{enumerate}\usepackage{enumitem} they are both trying to redefine enumerate, you need to choose which definition you want (use enumitem) – David Carlisle Sep 07 '21 at 14:28

2 Answers2

1

You have provided almost no information but as far as I can tell your first example is using the kpfonts

enter image description here

\documentclass{article}
\usepackage{kpfonts}
\begin{document}

[y=\sin^2 x]

\end{document}

And the desired second example is using the default latex computer modern, so all you have to do is not use the package selecting the non standard font set.

enter image description here

\documentclass{article}

\begin{document}

[y=\sin^2 x]

\end{document}

There are lots of other font sets available, eg stix2:

enter image description here

\documentclass{article}
\usepackage{stix2}
\begin{document}

[y=\sin^2 x]

\end{document}

David Carlisle
  • 757,742
  • I tried as you said but nothing changed. also I can't put all codes because it is very very long. – Sam Sep 07 '21 at 14:07
  • @Sam you need to remove txfonts package as well (why have you loaded kpfonts and txfonts at the same time, you can not use two fonts at the same time) – David Carlisle Sep 07 '21 at 14:23
  • When i removed the packages, the code is working fine and the font has changed to the default style. Thanks, teacher. – Sam Sep 07 '21 at 14:39
0

I use for example TeX Gyre Pagella/math font that it is very closer with your screenshot. See this example compilable with LuaLaTeX.

\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Pagella}
\setmathfont{TeX Gyre Pagella Math}
\begin{document}
   \[\bar x = \sum^{n}_{i=1}{x_1 + x_2+\ldots +x_n}=y=\sin(x)\]
\end{document}

enter image description here

Sebastiano
  • 54,118