• I am trying to create new commands and definitions in my preamble, but they are not working when I use the commands within my pages.

    Examples:
    \def\vx{\vec{x}}
    \newcommand{\beq}{\begin{displaymath}}

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author advanpix

    (@advanpix)

    Please provide complete code example you are using, with the tags ([preamble]…[/preamble]), etc, so that situation can be reproduced.

    Thread Starter gabehigginbotham

    (@gabehigginbotham)

    Preamble:

    %PREAMBLE:
    
    \textwidth 6.5in
    \textheight 9.0in
    \voffset=-.8in
    \hoffset=-.5in
    
    \usepackage[T1]{fontenc}
    \usepackage{mathptmx}
    \usepackage{graphicx}
    \usepackage{color}
    \usepackage{amsmath}
    \usepackage{xspace}
    \usepackage{latexsym}
    \usepackage[margin=10pt,width=3.0in,font=small,labelfont=bf]{caption}
    \usepackage{natbib} \bibpunct[, ]{(}{)}{;}{a}{}{,}
    \usepackage{esint}
    %\usepackage{undertilde}
    \def\undertilde#1{\mathord{\vtop{\ialign{##\crcr
       $\hfil\displaystyle{#1}\hfil$\crcr \noalign{\kern1.5pt\nointerlineskip}
       $\hfil\tilde{}\hfil$\crcr\noalign{\kern1.5pt}}}}}
    \newcommand{\utilde}{\undertilde}% replaces undertilde for the mac
    \usepackage{cancel}
    \usepackage{float}
    \usepackage{xcolor}
    \usepackage{subfiles}
    \usepackage{sidecap}
    \sidecaptionvpos{figure}{c}
    \usepackage{enumitem}
    \usepackage{empheq}
    \usepackage{hyperref}
    \usepackage[toc,page]{appendix}
    \usepackage{boxedminipage}
    \usepackage{capt-of}
    \usepackage[export]{adjustbox}
    \usepackage{makeidx}
    %\usepackage{showidx}
    \usepackage[totoc]{idxlayout}
    
    \newcommand{\s}{\, \text{s}}
    \newcommand{\m}{\, \text{m}}
    \newcommand{\ps}{\, \text{s}^{-1}}
    \newcommand{\kv}{\kappa_v}
    
    %\def\lc{\it}
    \def\lc{\color{blue}}
    
    \def\kh{\kappa_h}
    \def\eps{\varepsilon}
    \def\del { {\vec\nabla}}
    \def\delt{\Delta_h}
    \def\ni{\noindent}
    
    \def\haf{\frac{1}{2}}
    
    \def\vx{\vec{x}}
    \def\vy{\vec{y}}
    \def\vu{\vec{u}}
    \def\vv{\vec{v}}
    \def\vw{\vec{w}}
    \def\vz{\vec{z}}
    \def\vo{\vec{\omega}}
    \def\di{\partial}
    \def\ue{\utilde\epsilon}
    \def\uA{\utilde{A}}
    \def\uB{\utilde{B}}
    \def\uC{\utilde{C}}
    \def\uD{\utilde{D}}
    \def\uI{\utilde{I}}
    \def\udelta{\utilde{\delta}}
    \def\ur{\utilde{r}}
    \def\tk{\tilde{k}}
    \def\hw{\hat{w}}
    \def\hu{\hat{u}}
    \def\hv{\hat{v}}
    \def\hb{\hat{b}}
    \def\hp{\hat{\pi}}
    
    \def\prm{^\prime}
    \def\prmm{^{\prime\prime}}
    \def\prmmm{^{\prime\prime\prime}}
    \def\prmmmm{^{\prime\prime\prime\prime}}
    
    \def\sta{^\star}
    \def\dag{^\dagger}
    \def\limx{\lim_{|\Delta\vx |\rightarrow 0}~}
    
    \newcommand{\ddt}[1]{\frac{\di{#1}}{\dt}}
    
    % Abbreviations for unit vectors:
    \newcommand{\he}[1]{\hat{e}^{(#1)}}
    \newcommand{\hep}[1]{\hat{e}^{\prime(#1)}}
    
    % Abbreviation for k'th derivative:
    \newcommand{\fk}[1]{f^{(#1)}}
    
    % These abbreviations are useful for beginning and ending displayed equations:
    \newcommand{\beq}{\begin{displaymath}}
    \newcommand{\eeq}{\end{displaymath}}
    \newcommand{\beqn}{\begin{equation}}
    \newcommand{\eeqn}{\end{equation}}
    \newcommand{\be}{\begin{equation}}
    \newcommand{\ee}{\end{equation}}
    
    % Jeff added: -------------
    \def\pder#1#2{\frac{\partial #1}{\partial #2}}
    \def\md{\mathrm1gwpiim}
    \def\oder#1#2{\frac{\md #1}{\md #2}}
    %-------------------------------
    
    \newcommand{\nl}{\newline}
    
    \newcommand{\bmat}{\begin{quote}\color{blue}}
    \newcommand{\emat}{\color{black}\end{quote}}
    
    \newcommand{\mat}[1]{{\color{blue}\bf{#1}\color{black}}}
    \newcommand{\rast}{{\color{red}*\color{black}}}
    
    \makeindex
    
    \makeatletter
    \g@addto@macro\@floatboxreset\centering
    \makeatother
    
    %DOUBLESPACE
    \renewcommand{\baselinestretch}{1.0}
    \numberwithin{equation}{section}
    \bibliographystyle{ametsoc}
    
    \parskip=0.1in
    \parindent = 0in
    
    \newcommand{\toc}{\parskip=0in\tableofcontents\parskip=.1in}
    
    \DeclareRobustCommand{\gobblefour}[4]{}
    \newcommand*{\SkipTocEntry}{\addtocontents{toc}{\gobblefour}}
    
    %\renewcommand{\theequation}{\thesection.\arabic{equation}}
                          %At end of section add \setcounter{equation}{0}
    % My ''Example'' environment
    \newcounter{exa}
    \newenvironment{example}
    {\begin{quote} \bf Example \stepcounter{exa}\arabic{exa}\rm:}{\end{quote}}
    
    % My ''Exercise'' environment
    \newcounter{exer}
    \newenvironment{exercise}
    {\bf Exercise \stepcounter{exer}\arabic{exer}\rm:}
    
    %\newcommand{\sect}[1]{ \setcounter{equation}{0} \section{#1}}
    
    \renewcommand{\arraystretch}{1.5}

    Example equation:

    \beq
    \left[ {\begin{array}{*{20}{c}}
    x  \\
    y \\
    \end{array}} \right] \quad\textrm{to}\quad
    \left[ {\begin{array}{*{20}{c}}
    y  \\
    -x \\
    \end{array}} \right].
    \eeq
    Plugin Author advanpix

    (@advanpix)

    Wrap equation code with [latex]...[/latex]. QuickLaTeX detects only standard LaTeX environments, not custom defined. The ‘\beq’ will work fine if placed between the [latex]...[/latex].

    Rely on standards environments, if you do not want to use [latex]...[/latex].

    Thread Starter gabehigginbotham

    (@gabehigginbotham)

    Ok, thank you for your quick replies! It still does not work, but I think I will just use the normal environments. That works, at least. I took this project over from someone else, so the newcommands don’t really matter to me.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘\newcommand and \def not working’ is closed to new replies.