Featured Book

LaTeX Beginners Guide

Who is online

In total there are 7 users online :: 1 registered, 0 hidden and 6 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: Google [Bot] and 6 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

math text in caption in sf font - how to do it?

Add tags Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)

math text in caption in sf font - how to do it?

Postby loukote on Wed Feb 4th, 2009

Hi all.

I have captions in sf font. In some, there is some math text. But the math text renders the same way as all math texts in equations.

Is there a way to tell the math texts that are inside a caption to render in mathsf in an automatic way?

Thanks
loukote
 
Posts: 3
Joined: Tue Feb 3rd, 2009

Re: math text in caption in sf font - how to do it?

Postby localghost on Wed Feb 4th, 2009

I think there is a better way to set captions optically apart from the normal text.
Code: Select all  •  Open in writeLaTeX
\usepackage[font=small,labelfont=bf]{caption}

This looks nice and wouldn't cause any issues with math expressions in captions.


Best regards and welcome to the board
Thorsten¹
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses
User avatar
localghost
Site Moderator
 
Posts: 9219
Joined: Fri Feb 2nd, 2007
Location: Braunschweig, Germany

Re: math text in caption in sf font - how to do it?

Postby Keta on Thu Feb 5th, 2009

I've been willing to use sans-serifs captions for long time, well more than willing to use, kind of willing to know how to do it. If I recall correctly, I read somewhere that once math fonts are declared they're fixed for the rest of the document. I don't know it for sure, but I'm sure there are people in here who can tell us easily if this is correct or not.

If that's true, one solution could be to write code which first writes the caption to an external file, then processes that file with the desired options, and finally includes the output as a pdf or eps. Kind of how the examples where created in The LaTeX Companion book -- if I understood well the making process. I'm far from knowing how to do that, but there are real experts around here who might give us some useful hints.
Keta
 
Posts: 63
Joined: Tue Nov 25th, 2008

Re: math text in caption in sf font - how to do it?

Postby phi on Thu Feb 5th, 2009

It is possible, but very involved, to change the family automatically according to the text font family.
It is easier to declare a new math version. Here is an example using the Computer Modern fonts. Note that you get a warning because the sans-serif font doesn't use the correct encoding. Thus it is better to use the CM-Bright fonts. The following code shows both possibilities:
Code: Select all  •  Open in writeLaTeX
\documentclass{article}

\DeclareMathVersion{sans}
\SetSymbolFont{operators}{sans}{OT1}{cmss}{m}{n}
\SetSymbolFont{letters}{sans}{OT1}{cmss}{m}{sl}
\SetMathAlphabet\mathbf{sans}{OT1}{cmss}{bx}{n}
\SetMathAlphabet\mathsf{sans}{OT1}{cmss}{m}{n}
\SetMathAlphabet\mathit{sans}{OT1}{cmss}{m}{sl}

\DeclareMathVersion{sansbright}
\SetSymbolFont{operators}{sansbright}{OT1}{cmbr}{m}{n}
\SetSymbolFont{letters}{sansbright}{OML}{cmbrm}{m}{it}
\SetSymbolFont{symbols}{sansbright}{OMS}{cmbrs}{m}{n}
\SetMathAlphabet\mathbf{sansbright}{OT1}{cmbr}{bx}{n}
\SetMathAlphabet\mathsf{sansbright}{OT1}{cmbr}{m}{n}
\SetMathAlphabet\mathit{sansbright}{OT1}{cmbr}{m}{it}
\SetMathAlphabet\mathtt{sansbright}{OT1}{cmtl}{m}{n}

\begin{document}
\tableofcontents
\section{\sffamily\mathversion{sans}abc $a^2 + b^2 = c^2 \sum \prod \int$}
\section{\sffamily\mathversion{sansbright}abc $a^2 + b^2 = c^2 \sum \prod \int$}
\end{document
}
phi
 
Posts: 578
Joined: Tue Oct 21st, 2008

Re: math text in caption in sf font - how to do it?

Postby Keta on Thu Feb 5th, 2009

That was awesome phi, love it! :D :D I won't use it right now, but I'll save this thread as reference for the future. Thanks! :D
Keta
 
Posts: 63
Joined: Tue Nov 25th, 2008

Re: math text in caption in sf font - how to do it?

Postby sommerfee on Sat Feb 7th, 2009

An alternative solution:

Code: Select all  •  Open in writeLaTeX
\documentclass{article}
\usepackage{caption,sansmath}
\DeclareCaptionFont{sansmath}{\sansmath}
\captionsetup{textfont={sf,sansmath}}

\begin{document}
\begin{figure}
\caption{Some text and a formular: $E = mc^2$}
\end{figure}
\end{document
}


Regards,
Axel
User avatar
sommerfee
 
Posts: 493
Joined: Mon Apr 9th, 2007

Re: math text in caption in sf font - how to do it?

Postby loukote on Sat Feb 7th, 2009

sommerfee wrote:An alternative solution:
...
Regards,
Axel

Axel, this is not an alternative solution. This is THE solution. Thanks a lot.
Ondra
loukote
 
Posts: 3
Joined: Tue Feb 3rd, 2009


Return to Text Formatting

Who is online

Users browsing this forum: Google [Bot] and 6 guests