Math & ScienceEquation Not Italic unless stated

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
BoudewijnD
Posts: 60
Joined: Wed Nov 18, 2009 4:18 pm

Equation Not Italic unless stated

Post by BoudewijnD »

Here I'm again,
Yet With another problem. In the data I'm using I have a lot of sub and super scripts (see example below). I put (or acctually Word2latex) between $'s to mark it as an equation, other wise I get allot of errors. But I don't want the sub or super script to be italic. Is there away a can prevent this for the whole document? And is there than away I can undo that for a few equations??

Thanx again for the help.

And ohey some expamples:

the Latex file: (it's part of a bigger project so this will not produce a pdf)

Code: Select all

% Chapter 1

\chapter{\bfseries{\textsf{General Introduction and Outline}}} % Write in your own chapter title
\label{Chapter1}
\lhead{\emph{Introduction}} % Write in your own chapter title to set the page header

\renewcommand{\bibname}{References}

\section{Biological Introduction}




\section{}
Kijken of we ook een ref kunnen gebruiken \cite{abdel1996}
\ce{H2SO4} [\alpha]^{22}_{\textsc{d}}
\subsection{A (not so short) Introduction to} 
test\cite{abdel1996}\\

\textbf{1,6-Anhydro-2-azido-3-\textit{O}-benzyl-2-deoxy-4-\textit{O}-methyl-\beta-\textsc{d}-glu\-co\-pyr\-anose (X):}\\

Compound X (xmmol, x g) was dissolved in DMF and cooled using an ice-bath 
and after stirring for 15 minutes NaH (1.5 equiv. x mmol, x g) was added 
portion wise. After 30 minutes the gas development stopped and MeI (1.2 
equiv. x mmol, x mL) was added drop wise. The reaction was quenched with 
MeOH after 1.5 hours. The reaction mixture was concentrated and purified 
using a short silica column (20{\%} EtOAc/PE) which gave product X as clear 
oil.\textbf{$^{1}$H NMR (400 MHz, CDCl$_{3}$)} $\delta$ 7.41 - 7.27 (m, 5H, 
CH$_{arom}$, Bn), 5.48 (s, 1H, H$_{1}$), 4.64 (m, 3H, CH$_{2}$Bn, H$_{5}$), 
4.08 (d, \textit{J} = 7.2 Hz, 1H, H$_{6'}$), 3.76 (dd, J = 13.0, 6.4 Hz, 1H, 
H$_{6}$), 3.59 (d, \textit{J} = 24.3 Hz, 1H, H$_{4}$), 3.39 (s, 3H, CH$_{3}$), 3.29 
(s, 1H, H$_{3}$), 3.20 (s, 1H, H$_{2}$); \textbf{$^{13}$C NMR (101 MHz, 
CDCl$_{3}$)} \delta 137.38 (C$_{q}$, Bn), 128.68-127.88 (CH$_{arom}$, Bn), 
100.64 (C-1), 78.80 (C-2), 75.92 (C-3), 73.75 (C-4), 72.51 (C-6), 65.34 
(CH$_{2}$, Bn), 59.87 (C-5), 57.16 (CH$_{3}$, Me); \textbf{IR:} 2096.5, 
1718.5, 1244.0, 1099.3, 1004.8, 929.6, 867.9; \\

\textbf{1,6-Di-\textit{O}-acteyl-2-azido-3-\textit{O}-benzyl-2-deoxy-4-\textit{O}-methyl-$\alpha 
-\beta$-\textbf{d}-glucopyranose (X):}

The clear oil (X) was taken up in \ce{Ac2o} and cooled with an ice bath. To 
this cooled solution TFA (10{\%} v/v) was added and the reaction was stirred 
overnight to room temperature. After complete conversion of the starting 
material on TLC the reaction was diluted with Toluene and co-evaporated to 
yellow oil. Purification using a short silica column (30{\%} EtOAc/PE) 
yielded compound X (2.62 g, 6.66 mmol, 90{\%}) as a white solid.\textbf{$^{ 
1}$H NMR} (400 MHz, CDCl$_{3}$)$\delta$ 7.43 -- 7.23 (m, 5H, 
CH$_{arom}$, Bn $\alpha $/$\beta $ ), 6.22 (d, $J$ = 3.6 Hz, 1H, H$_{1\alpha 
})$, 5.45 (d, $J$ = 8.1 Hz, 1H, H$_{1\beta })$ 4.88 -- 4.81 (m, 2H, CH$_{2}$ Bn 
$\alpha $/$\beta )$, 4.30 - 4.21 (m, 2H, CH$_{2, }$H$_{6\alpha /\beta })$, 
3.87 - 3.78 (m, 2H, H$_{5\alpha /\beta }$ H$_{4\alpha$/$\beta })$, 3.55 - 
3.45 (m, 4H, CH$_{3, }$Me, H$_{3\alpha$/$\beta })$, 3.30 (t, $J$ = 9.5 Hz, 1H, 
H$_{2\alpha /\beta })$, 2.09 (s, 3H, CH$_{3}$, OAc), 2.04 (s, 3H CH$_{3}$, 
OAc);\textbf{$^{13}$C NMR} (101 MHz, CDCl$_{3}$)$\delta $ 170.09 (C$_{q}$, 
Ac), 168.31 (C$_{q}$, Ac), 137.40 (C$_{q}$, Bn), 128.16-127.67 (CH$_{arom}$, 
Bn), 92.24 (C-1$_{\beta })$, 89.96 (C-1$_{\alpha })$, 82.38 (C-4$_{\beta 
})$, 79.90 (C-4$_{\alpha })$, 79.51 (C-3$_{\alpha })$, 79.12 (C-3$_{\beta 
})$, 75.10 (CH$_{2}$, Bn), 73.53 (C-5$_{\beta })$, 71.03 (C-5$_{\alpha })$, 
64.46 (CH$_{3}$, Me$_{\beta })$, 62.12 (CH$_{2}$, C-6$_{\alpha /\beta })$, 
62.06 (CH$_{3}$, Me$_{\alpha })$, 60.56 (C-2$_{\alpha })$, 60.40 
(C-2$_{\beta })$, 20.44 (CH$_{3}$, OAc), 20.30 (CH$_{3}$, OAc); \textbf{IR:} 
2106.1, 1753.2, 1733.9, 1373.2, 1136.0, 1109.0, 1004.8, 935.4, 906.5, 740.6

\bibliographystyle{achemso}
{\bibliography{chapter1}}
And a print screen of the pdf:
Image

\BoudewijnD

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Equation Not Italic unless stated

Post by frabjous »

I know how to do this with XeLaTeX using the mathspec package (see its documentation), but I don't know how to do it offhand with regular latex/pdflatex. Perhaps someone else will.

EDIT: Looking again, it looks like most of your subscripts are Greek letters. If those are the ones you want to change, you might try using the upgreek package, and then perhaps \renewcommand{\alpha}{\upalpha}, etc., to switch forms.
BoudewijnD
Posts: 60
Joined: Wed Nov 18, 2009 4:18 pm

Re: Equation Not Italic unless stated

Post by BoudewijnD »

Mmmh I working with TenicCenter. So I don't know if i can use the XeLaTeX commands/packages.

\BoudewijnD
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Equation Not Italic unless stated

Post by frabjous »

You can use XeLaTeX with TeXnicCenter, instructions here, though you can't really make full use of it since (unless you're using the pre-release alpha of 2.0, you can't use Unicode; though that's not necessary in this case, I don't believe.
BoudewijnD
Posts: 60
Joined: Wed Nov 18, 2009 4:18 pm

Re: Equation Not Italic unless stated

Post by BoudewijnD »

Maybe it just me but whats the difference between Latex en xetex??

\BoudewijnD
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: Equation Not Italic unless stated

Post by frabjous »

XeTeX is to XeLaTeX what TeX is to LaTeX. You'll want to use XeLaTeX, not plain XeTeX, unless you're migrating plain TeX code. You can use almost precisely the same code for them, except for a few lines in the header.

There's not much difference between them, except that Xe(La)TeX is set up to use TrueType and OpenType fonts (and can use any font you have installed on your system without hassle), and can handle unicode (UTF8) input without additional packages, whereas (La)TeX is set up for use with Type1 fonts only, and even then, it's a hassle to get the fonts installed for use, and unicode input requires the inputenc package or similar.

Here's its website:
http://scripts.sil.org/cms/scripts/page ... i&id=XeTeX

Most LaTeX packages can be used with XeLaTeX with a few (albeit notable) exceptions, like microtype and pstricks (though I think there may be a compatibility package for the latter).

I'm surprised no one knows how to get upright math by default in plain LaTeX. I'd still guess there's a way even if I don't know it.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Equation Not Italic unless stated

Post by svend_tveskaeg »

I am not sure if this is useful or not but you can take a look.


Morten Høgholm once came up with the following solution for writing sub- and superscripts in upright textmode, on a Danish mailing list:

Code: Select all

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}

\makeatletter
 \newcommand\textupperscript[2]{%
  \@textupperscript{\selectfont#1}{\selectfont#2}
 }
 \def\@textupperscript#1#2{%
  {\m@th\ensuremath{%
    ^{\mbox{\fontsize\sf@size\z@#1}}
    _{\mbox{\fontsize\sf@size\z@#2}}
  }}
 }
\def\@super{^}
\def\@sub{_}

\catcode`^\active
\catcode`_\active
  \def\@super@sub#1_#2{\textbothscript{#1}{#2}}
  \def\@sub@super#1^#2{\textbothscript{#2}{#1}}
    \def\@@super#1{\@ifnextchar_{\@super@sub{#1}}{\textsuperscript{#1}}}
    \def\@@sub#1{\@ifnextchar^{\@sub@super{#1}}{\textsubscript{#1}}}
      \def^{\let\@next\relax\ifmmode\@super\else\let\@next\@@super\fi\@next}
      \def_{\let\@next\relax\ifmmode\@sub\else\let\@next\@@sub\fi\@next}
\makeatother

\begin{document}
Something:
\begin{equation*}
  \Psi\textupperscript{Horse}{Fish}(x)
\end{equation*}
\end{document}
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
BoudewijnD
Posts: 60
Joined: Wed Nov 18, 2009 4:18 pm

Equation Not Italic unless stated

Post by BoudewijnD »

frabjous wrote:
There's not much difference between them, except that Xe(La)TeX is set up to use TrueType and OpenType fonts (and can use any font you have installed on your system without hassle), and can handle unicode (UTF8) input without additional packages, whereas (La)TeX is set up for use with Type1 fonts only, and even then, it's a hassle to get the fonts installed for use, and unicode input requires the inputenc package or similar.

Really like this option!! I downloaded Texworks and I will try it out. But I have to questions:
1) Is there any need to change my code (and packages) that I used in Latex
2) And really important can I still use the achemso package?

oke and a small number 3: So basically they both work the same and I don't need to learn a new code??
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Equation Not Italic unless stated

Post by frabjous »

I don't know anything about achemso--but the author (Joseph Wright) is a regular on these forums and could perhaps help clarify the issue. Still, there's a good chance, they'd work together with no special effort required.

For the most part, you can use almost unmodified LaTeX code with XeLaTeX. All you'd really need to do is include the following early on in your document header:

Code: Select all

\usepackage{mathspec} 
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\usepackage{xunicode}
\usepackage{xltxtra} 
And actually, the latter two packages probably aren't actually necessary, but they are recommended for XeLaTeX in general.

And then, to set the fonts:

Code: Select all

\setmainfont{DejaVu Serif}
\setsansfont{DejaVu Sans}
\setmonofont{DejaVu Sans Mono}
\setmathfont(Digits,Latin,Greek)[Lowercase=Regular,Uppercase=Regular]{DejaVu Serif}
Change "DejaVu Serif", etc., to the names of fonts installed on your system: whatever you want to use for regular text, sans-serif text, monospace text and math text, respectively. It's easiest if it's a rich unicode font like these that includes its own Greek letters. If not, you may need to separate Greek from Digits/Latin:

Code: Select all

\setmathfont(Digits,Latin)[Lowercase=Regular,Uppercase=Regular]{Sorts Mill Goudy}
\setmathfont(Greek)[Lowercase=Regular,Uppercase=Regular]{Linux Libertine O}
It's the Lowercase=Regular and Uppercase=Regular options that will make the math text default to upright. See the mathspec and fontspec documentation for more info.

Usually, this gives decent results. The only caveat is that the symbols used will still be the default ones from Computer Modern, and these are spaced for use with Computer Modern. Sometimes, when using mathspec, spacing needs to be tweaked. Details in the mathspec documentation.

Here's a miniature document using these options that can be compiled with XeLaTeX as is:

Code: Select all

\documentclass[12pt]{article} 
\usepackage{mathspec} 
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} 
\usepackage{xunicode} 
\usepackage{xltxtra} 
\usepackage[english]{babel} % sets language for blindtext
\usepackage{blindtext} % for auto-generating text
\setmainfont{DejaVu Serif}
\setsansfont{DejaVu Sans}
\setmonofont{DejaVu Sans Mono}
\setmathfont(Digits,Latin,Greek)[Lowercase=Regular,Uppercase=Regular]{DejaVu Serif}
\title{Brief Article}
\author{The Author}
\begin{document}
\maketitle
\blindmathpaper % auto-generates a short math paper
\end{document}
XeLaTeX compiles to PDF, not DVI, by default, so be sure to launch the PDF viewer afterwards.
BoudewijnD
Posts: 60
Joined: Wed Nov 18, 2009 4:18 pm

Re: Equation Not Italic unless stated

Post by BoudewijnD »

Hey frabjous,

Thanx your the extended explanation of Texworks. I will try it out when I got all the data properly in Tex.

Cheers,
\BoudewijnD
Post Reply