GeneralGetting latex to output Mathematica code as it's written

LaTeX specific issues not fitting into one of the other forums of this category.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Getting latex to output Mathematica code as it's written

Post by Cham »

Johannes_B wrote:As both are designed to do the same job, it would be better for document maintainability to decide for one.

Critical decision to make now, as i know your document is quite advanced. Either investing time and effort now to get everything unified, or hope and trust that everything will work as well in the future.

Ok, then if my present global subfig settup is this :

Code: Select all

\usepackage{subfig}
\captionsetup{figurename=Figure,margin=1cm,format=hang,font=small,format=plain,labelfont={bf,up},textfont={it}}
\captionsetup[subfigure]{margin=0cm,font=small,format=plain,labelfont={bf,up},textfont={up}}
\captionsetup[table]{tablename=Table,labelfont={bf,up}}
how do you suggest that I change it to the subcaption package ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Getting latex to output Mathematica code as it's written

Post by Cham »

Since this is vital to me, could you please confirm that this replacement is the proper one ?

Change this code :

Code: Select all

\usepackage{subfig}
\captionsetup{figurename=Figure,margin=1cm,format=hang,font=small,format=plain,labelfont={bf,up},textfont={it}}
\captionsetup[subfigure]{margin=0cm,font=small,format=plain,labelfont={bf,up},textfont={up}}
\captionsetup[table]{tablename=Table,labelfont={bf,up}}
to this new one :

Code: Select all

\usepackage{caption}
\usepackage{subcaption}
\captionsetup{figurename=Figure,margin=1cm,format=hang,font=small,format=plain,labelfont={bf,up},textfont={it}}
\captionsetup[subfigure]{margin=0cm,font=small,format=plain,labelfont={bf,up},textfont={up}}
\captionsetup[table]{tablename=Table,labelfont={bf,up}}
Apparently, it works (the output appears to be the same), but I absolutely need to be sure that I don't intruduce some mistakes or new bugs !

EDIT : Arrrgh ! I'm now getting several nag warnings, like this one :
Package nag Warning: \label in float, but not after \caption on input line 1091.
I don't understand this message. Here's the code around line 1091 :

Code: Select all

\begin{figure}[H]
		\centering
		\subfloat[Blabla bla 1.]{
		\includegraphics[height=6cm]{Figures/spirale.pdf}
		\label{a simple label}
		}
		\qquad
		\subfloat[Blabla bla 2.]{
		\includegraphics[height=6cm]{Figures/rosace.pdf}
		\label{another simple label}
		}
		\caption[Blabla bla.]{Blabla bla.}
	\end{figure}
What is wrong ?
Last edited by Cham on Thu Mar 26, 2015 11:23 pm, edited 2 times in total.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Getting latex to output Mathematica code as it's written

Post by Johannes_B »

The syntax of package subcaption is comletely different, which is what i meant. The styling shouldn't be any problem.


Package subcaption uses a syntax similar to minipages, with an extra caption and an extra label. So chaning really needs a bit of effort. The decision to change the whole document is a serious one.

btw, H provided by package float introduces the Hammer method and completely disables floating. If you don't want graphics and tables to float, and have them at very very special places, you wouldn't need captions at all. You could work with the captionof command. But that might be relevant for your next project.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Getting latex to output Mathematica code as it's written

Post by Cham »

Please, do you confirm that the captionsetup defined above is the proper change ? (there's no change at all, actually, except the packages called). This surprises me a bit.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Getting latex to output Mathematica code as it's written

Post by Johannes_B »

I would need a minimal example to confirm that, but since subfig does no styling at all, and all is done by package caption, i think there shouldn't be a problem.


Package subfig and package subcaption define a new counter for subfigures and subtables. Package caption doesn't care a bit who or what defined the counter and hence provides the accompanying caption command.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Getting latex to output Mathematica code as it's written

Post by Cham »

I checked the syntax of the subcaption package and I don't like it much. It is much less intuitive than subfig. And since I have hundreds of figures, it would be too much work for nothing new.

I would like to see some examples of the conflicts between subfig and hyperref. Can you give some examples and more details about that ?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Getting latex to output Mathematica code as it's written

Post by Johannes_B »

Cham wrote:I checked the syntax of the subcaption package and I don't like it much. It is much less intuitive than subfig. And since I have hundreds of figures, it would be too much work for nothing new.
As i said, this will require quite the effort.
I would like to see some examples of the conflicts between subfig and hyperref. Can you give some examples and more details about that ?
Sorry, nothing specific at the moment, but you can have a look at google -> https://www.google.de/?gfe_rd=cr&ei=wIY ... ef+problem



You can also have a look at a little chat transcript and the comment that egreg left me.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Getting latex to output Mathematica code as it's written

Post by Johannes_B »

The discussion went a bit off-topic and i am thinking of splitting the thread. It is easier for future visitors.


I just stumbled upon Fanciest way to include Mathematica code in LaTeX, which might be of interest here.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply