0

Latex symbol

Joshua Hernandez 11 years ago updated 11 years ago 4
Lately I have been using textastic as a LaTeX editor. So most of my LaTeX documents have user defined environments that I use. I have collected and made a handful to speed up my writing time. There is an odd issue with LaTeX symbol recognition with section/subsections from user defined environments using the \newenvironment{} command. As they are not even recognized. I am guessing that the current parsing algorithm does not even consider these situations. I have a hunch that this cannot be easily fixed, but I am still curious as to the likelihood of such a fix.

Hello, do you have an example LaTeX document?
Here is a part of the LaTeX document that I use.

\documentclass[12pt]{report}

\usepackage{amsthm}            % Introduces theorems

% Header and footer for when a page split occurs within a problem environment
\newcommand{\enterProblemHeader}[1]{
	\nobreak\extramarks{#1}{#1 continued on next page\ldots}\nobreak
	\nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak
}

% Header and footer for when a page split occurs between problem environments
\newcommand{\exitProblemHeader}[1]{
	\nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak
	\nobreak\extramarks{#1}{}\nobreak
}

\setcounter{secnumdepth}{0}         % Removes default section numbers
\newcounter{homeworkProblemCounter} % Creates a counter to keep track of the number of problems

\newcommand{\homeworkProblemName}{}
\newenvironment{homeworkProblem}[1][Problem \arabic{homeworkProblemCounter}]{ 
	% Makes a new environment called homeworkProblem which takes 1 argument (custom name) but the default is "Problem #"
	\stepcounter{homeworkProblemCounter}    % Increase counter for number of problems
	\renewcommand{\homeworkProblemName}{#1} % Assign \homeworkProblemName the name of the problem


	\section{\homeworkProblemName} % Make a section in the document with the custom problem count


	\enterProblemHeader{\homeworkProblemName} % Header and footer within the environment
}{
	\exitProblemHeader{\homeworkProblemName} % Header and footer after the environment
}

\newcommand{\problemAnswer}[1]{ 
	% Defines the problem answer command with the content as the only argument
	\noindent\framebox[\columnwidth][c]{\begin{minipage}{0.98\columnwidth}#1\end{minipage}} 
	% Makes the box around the problem answer and puts the content inside
	}

\newcommand{\homeworkSectionName}{}
\newenvironment{homeworkSection}[1]{ 
	% New environment for sections within homework problems, takes 1 argument - the name of the section
	% Assign \homeworkSectionName to the name of the section from the environment argument
	\renewcommand{\homeworkSectionName}{#1} 
	\subsection{\homeworkSectionName}        % Make a subsection with the custom name of the subsection
	\enterProblemHeader{\homeworkProblemName\ [\homeworkSectionName]} % Header and footer within the environment
}{
	\enterProblemHeader{\homeworkProblemName} % Header and footer after the environment
}
\begin{document}
	\begin{homeworkProblem}
		Sample Text Here
		\begin{homeworkSection}{NameSection}
			More text
		\end{homeworkSection}
			other text
	\end{homeworkProblem}

	\begin{homeworkProblem}
		\begin{thrm}{}
		\end{thrm}
		\begin{proof}
		\end{proof}
	\end{homeworkProblem}

\end{document}

This is mostly from templates I have found and modified a small portion. Anyways in textastic (the desktop or mobel version) in the symbol list I only see two symbols one is \homeworkProblemName and if clicked it reffers to the line inside the \newenvironment definition for homeworkProblem that creates the new section.

\newenvironment{homeworkProblem}[1][Problem \arabic{homeworkProblemCounter}]{ 
	...
	\section{\homeworkProblemName} % This line
	...
}

Similarly there is another symbol in the symbol list \homeworkSectionName which is marked as a subsection and when clicked, I am referred to the line in the \newenvironment definition for homeworkSection that creates the subsection.

\newenvironment{homeworkSection}[1]{ 
	...
	\subsection{\homeworkSectionName}        % This line
	...
}





I see. I don't think this can be done with the current implementation of the symbol list. The symbol list code really just sees "\section{\homeworkProblemName}" and does a regular expression search/replace operation which results in "\homeworkProblemName". It can't evaluate custom commands defined in another part of the document which would be necessary in this case.

So the symbol list would need to be much smarter and actually evaluate the LaTeX code to display something more sensible.
It is not that big a problem. It is only a minor inconvenience. Thank you for spending the time to look into this and letting me know. Thanks for all your hard work on Textastic.