Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with \renewcommand{\vec}[1]{\mathbf{#1}} #463

Open
3 tasks done
ghost opened this issue May 9, 2018 · 4 comments
Open
3 tasks done

Problems with \renewcommand{\vec}[1]{\mathbf{#1}} #463

ghost opened this issue May 9, 2018 · 4 comments

Comments

@ghost
Copy link

ghost commented May 9, 2018

Description

I tried to redefine the vector definition with \usepackage{unicode-math} statement in the preamble but I could not get it working.

Check/indicate

A not working minimal example (CaseA.tex) demonstrating the issue

\documentclass{scrartcl}

\usepackage{fontspec}
\usepackage{unicode-math}

\renewcommand{\vec}[1]{\mathbf{#1}}

\begin{document}

$ \vec{a} $

\end{document}

A working minimal example (CaseB.tex) demonstrating the issue

\documentclass{scrartcl}

\usepackage{fontspec}
% \usepackage{unicode-math}

\renewcommand{\vec}[1]{\mathbf{#1}}

\begin{document}

$ \vec{a} $

\end{document}

Further details

As the two files only differ in the import of the unicode-math I would suspect the error within the unicode-math error.
Also newcommand work as expected:

\newcommand{\op}[1]{\hat{#1}}
\newcommand{\ham}{\mathcal{H}}
\newcommand{\hamop}{\op{\ham}}

Log and PDF files are attached below

CaseA.log
CaseA.pdf
CaseB.log
CaseB.pdf

@ghost ghost changed the title Problems with\renewcommand{\vec}[1]{\mathbf{#1}} Problems with \renewcommand{\vec}[1]{\mathbf{#1}} May 9, 2018
@ghost
Copy link
Author

ghost commented May 9, 2018

I looked further into it and I turned out that explicitly setting Latin Modern Math by

\setmathfont{Latin Modern Math}

as the math font solves the issue as can be shown by the following two test cases.

CaseC (not working)

\documentclass{scrartcl}

\usepackage{fontspec}
\usepackage{unicode-math}
% \setmathfont{Latin Modern Math}

\renewcommand{\vec}[1]{\mathbf{#1}}

\begin{document}

$ \vec{a} $

\end{document}

CaseD (working)

\documentclass{scrartcl}

\usepackage{fontspec}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}

\renewcommand{\vec}[1]{\mathbf{#1}}

\begin{document}

$ \vec{a} $

\end{document}

Attached files

CaseC.log
CaseC.pdf
CaseD.log
CaseD.pdf

@ghost
Copy link
Author

ghost commented May 9, 2018

I forgot the mention that all files were compiled by LuaTeX-1.0.4.

@u-fischer
Copy link
Member

unicode-math waits until \begin{document} to setup the default font and the default definitions. So if you don't use \setmathfont, you should delay your redefinition. I would also recommend to use \symbf instead of \mathbf:

\documentclass{scrartcl}

\usepackage{fontspec}
\usepackage{unicode-math}

\AtBeginDocument{\renewcommand{\vec}[1]{\symbf{#1}}}

\begin{document}

$ \vec{a} $

\end{document}

@ghost
Copy link
Author

ghost commented May 9, 2018

Thanks for the fast response. I couldn't find the information that the definitions were defined with the \begin{document} command so that really got me on the wrong foot, I have to admit. It still seems a bit odd to me, so perhaps you could mention it for future users in your manual.
But as the issue is solved for me, I think you could close the issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant