GeneralSpecial symbols in latex

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
ma501th
Posts: 50
Joined: Tue Apr 08, 2008 7:31 pm

Special symbols in latex

Post by ma501th »

I am trying to put the following script in a table all in one box with two columns, i need help to identify what are the special symbols in this coding:

var date=new Date(); //variable is set for date
var dayweek=date.getDay(); //variable day of the week is set for day
var dayweek_str:String; //variable day of the week is formatted as characters
var year=date.getFullYear(); //year will be displayed
var month=date.getMonth(); //variable is set for the month
var month_str:String; //variable month is formatted as characters
var days=date.getDate(); //variable is set for day
var days_str:String; //variable day is formatted as characters

switch (month){ //this section will declare a case value to correspond to a given month
case(0):month_str="January"; break;
case(1):month_str="February"; break;
case(2):month_str="March"; break;
case(3):month_str="April"; break;
case(4):month_str="May"; break;
case(5):month_str="June"; break;
case(6):month_str="July"; break;
case(7):month_str="August"; break;
case(8):month_str="September"; break;
case(9):month_str="Octomber"; break;
case(10):month_str="November"; break;
case(11):month_str="December"; break; }

if (days<10){ //this will read the current case value of the system date which will match a given month
days_str="0"+days;
}else{
days_str=days; }

switch (dayweek){ //this section will declare a case value to correspond to a given day of the week
case(0):dayweek_str="Sunday"; break;
case(1):dayweek_str="Monday"; break;
case(2):dayweek_str="Tuesday"; break;
case(3):dayweek_str="Wednesday "; break;
case(4):dayweek_str="Thursday"; break;
case(5):dayweek_str="Friday "; break;
case(6):dayweek_str="Saturday"; break; }

date_txt.text=dayweek_str+" "+days_str+" "+month_str+" "+year; //full date will be displayed as day date month year


Please can anybody help?

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

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Special symbols in latex

Post by Stefan Kottwitz »

Hi,

look at the listings package and its user's guide.

Stefan
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Special symbols in latex

Post by Stefan Kottwitz »

Hi,

you could also just use a verbatim environment, for example:

Code: Select all

\documentclass[a4paper,10pt]{article}
\begin{document}
{\footnotesize
\begin{verbatim}
var date=new Date(); //variable is set for date
var dayweek=date.getDay(); //variable day of the week is set for day
var dayweek_str:String; //variable day of the week is formatted as characters
var year=date.getFullYear(); //year will be displayed
var month=date.getMonth(); //variable is set for the month
var month_str:String; //variable month is formatted as characters
var days=date.getDate(); //variable is set for day
var days_str:String; //variable day is formatted as characters

switch (month){ //this section will declare a case value to correspond to a given month
case(0):month_str="January"; break;
\end{verbatim}
}
\end{document}
But this could be more difficult when you want to use it inside tables for example. But there are packages like examplep that can handle this.

Stefan
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Special symbols in latex

Post by localghost »

ma501th wrote:I am trying to put the following script in a table all in one box with two columns, i need help to identify what are the special symbols in this coding:
[...]
Please can anybody help?
Is that code of a specific programming language? If so, take a look a the listings package. It lets you format code in several predefined programming languages.


Best regards
Thorsten¹
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Special symbols in latex

Post by Stefan Kottwitz »

As I mentioned in my first answer and Thorsten recommended too: the listings package is very useful! Depending on what you are going to do, it may save you a lot of time.

If you want to look at the possibilities: Here is the user's guide.

Stefan
Post Reply