How to export the cell above to pdf using the Export[] command (not using GUI)Image of input and output cells is not exported correctlySlideshow export to PDF (landscape)How to highlight the whole selected cellExport to PDF so that Adobe Illustrator does not convert PlotMarkers to fontsSave as PDF without cell numbersSaving all cell-groups to pdfs with filenamesHow to export a cell in Messages console to PDF?

Can I leave my car sitting outside for about 5 years?

Who owns copyright on works found in a storage unit/attic?

1 horizontal and 1 vertical line needs to be a different color in my table

Theoretically, what if I were to change some magic numbers in, say, AES?

What if I take Necrotic damage more than my hit point total?

Is it legal to use True Polymorph to become a really old adult dragon so that you become ancient with time?

Why is JavaScript not compiled to bytecode before sending over the network?

What are the common footprint naming conventions

Why should you have travel insurance?

How do i limit the use of projectiles in a high fantasy world?

Is my ESTA still valid though I've mislaid it?

Which species is proud of being conquered many times?

What are the ethical implications of lying to get into a course?

Why is Brownian motion useful in finance?

Twelve Labours - Conclusion

Expectation of 500 coin flips after 500 realizations

Being heavily recruited at new company: Should I tell them I’m trying to get pregnant?

Windows Defender reports Win64/Longage Trojan malware in Ubuntu 18.04.3 live server

Why does atmospheric pressure act on us?

Why did they design new connectors for USB?

what makes a disease deadly?

Is rotating a pawn so that it faces a different direction and then moves in that direction technically permitted according to the 2018 FIDE Laws?

Can you bring an adjustable spanner on an airplane from Åland?

Simulating these special dice on more regular dice



How to export the cell above to pdf using the Export[] command (not using GUI)


Image of input and output cells is not exported correctlySlideshow export to PDF (landscape)How to highlight the whole selected cellExport to PDF so that Adobe Illustrator does not convert PlotMarkers to fontsSave as PDF without cell numbersSaving all cell-groups to pdfs with filenamesHow to export a cell in Messages console to PDF?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;

.everyonelovesstackoverflowposition:absolute;height:1px;width:1px;opacity:0;top:0;left:0;pointer-events:none;








3















$begingroup$


Sorry if this was asked before. I googled and could not find anything.



Many times I need to export a cell to a PDF. It is always the cell above. Currently I do this using the GUI, by selecting the cell first, then File->Save selection As then save it to a PDF file.



But sometimes I lose track of what file I saved the cell to (If I do not remember to add a comment).



Is it possible to use the Export command? This way by looking at the command below the cell, I know the name of the file.



With plots and graphics, this is easy to do, since I could do p=Plot[...] then do Export["plot.pdf",p]



Any suggestions how to do this for cell? It will always be the cell above where the command is issued, if this makes it any easier. (So can't use any hardcoded specific current cell number, since the cell numbers can change when modifying the notebook)



Mathematica graphics



I am using V12 on windows 10.










share|improve this question











$endgroup$














  • $begingroup$
    Does Export["code.pdf", NotebookRead[PreviousCell[]]] do what you want?
    $endgroup$
    – Carl Woll
    Sep 29 at 2:53











  • $begingroup$
    @CarlWoll Yes !, thank you, that is very good command. If you post that as answer, will be happy to accept it.
    $endgroup$
    – Nasser
    Sep 29 at 2:58

















3















$begingroup$


Sorry if this was asked before. I googled and could not find anything.



Many times I need to export a cell to a PDF. It is always the cell above. Currently I do this using the GUI, by selecting the cell first, then File->Save selection As then save it to a PDF file.



But sometimes I lose track of what file I saved the cell to (If I do not remember to add a comment).



Is it possible to use the Export command? This way by looking at the command below the cell, I know the name of the file.



With plots and graphics, this is easy to do, since I could do p=Plot[...] then do Export["plot.pdf",p]



Any suggestions how to do this for cell? It will always be the cell above where the command is issued, if this makes it any easier. (So can't use any hardcoded specific current cell number, since the cell numbers can change when modifying the notebook)



Mathematica graphics



I am using V12 on windows 10.










share|improve this question











$endgroup$














  • $begingroup$
    Does Export["code.pdf", NotebookRead[PreviousCell[]]] do what you want?
    $endgroup$
    – Carl Woll
    Sep 29 at 2:53











  • $begingroup$
    @CarlWoll Yes !, thank you, that is very good command. If you post that as answer, will be happy to accept it.
    $endgroup$
    – Nasser
    Sep 29 at 2:58













3













3









3


1



$begingroup$


Sorry if this was asked before. I googled and could not find anything.



Many times I need to export a cell to a PDF. It is always the cell above. Currently I do this using the GUI, by selecting the cell first, then File->Save selection As then save it to a PDF file.



But sometimes I lose track of what file I saved the cell to (If I do not remember to add a comment).



Is it possible to use the Export command? This way by looking at the command below the cell, I know the name of the file.



With plots and graphics, this is easy to do, since I could do p=Plot[...] then do Export["plot.pdf",p]



Any suggestions how to do this for cell? It will always be the cell above where the command is issued, if this makes it any easier. (So can't use any hardcoded specific current cell number, since the cell numbers can change when modifying the notebook)



Mathematica graphics



I am using V12 on windows 10.










share|improve this question











$endgroup$




Sorry if this was asked before. I googled and could not find anything.



Many times I need to export a cell to a PDF. It is always the cell above. Currently I do this using the GUI, by selecting the cell first, then File->Save selection As then save it to a PDF file.



But sometimes I lose track of what file I saved the cell to (If I do not remember to add a comment).



Is it possible to use the Export command? This way by looking at the command below the cell, I know the name of the file.



With plots and graphics, this is easy to do, since I could do p=Plot[...] then do Export["plot.pdf",p]



Any suggestions how to do this for cell? It will always be the cell above where the command is issued, if this makes it any easier. (So can't use any hardcoded specific current cell number, since the cell numbers can change when modifying the notebook)



Mathematica graphics



I am using V12 on windows 10.







export cells






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 29 at 2:27







Nasser

















asked Sep 29 at 2:21









NasserNasser

72.9k4 gold badges95 silver badges219 bronze badges




72.9k4 gold badges95 silver badges219 bronze badges














  • $begingroup$
    Does Export["code.pdf", NotebookRead[PreviousCell[]]] do what you want?
    $endgroup$
    – Carl Woll
    Sep 29 at 2:53











  • $begingroup$
    @CarlWoll Yes !, thank you, that is very good command. If you post that as answer, will be happy to accept it.
    $endgroup$
    – Nasser
    Sep 29 at 2:58
















  • $begingroup$
    Does Export["code.pdf", NotebookRead[PreviousCell[]]] do what you want?
    $endgroup$
    – Carl Woll
    Sep 29 at 2:53











  • $begingroup$
    @CarlWoll Yes !, thank you, that is very good command. If you post that as answer, will be happy to accept it.
    $endgroup$
    – Nasser
    Sep 29 at 2:58















$begingroup$
Does Export["code.pdf", NotebookRead[PreviousCell[]]] do what you want?
$endgroup$
– Carl Woll
Sep 29 at 2:53





$begingroup$
Does Export["code.pdf", NotebookRead[PreviousCell[]]] do what you want?
$endgroup$
– Carl Woll
Sep 29 at 2:53













$begingroup$
@CarlWoll Yes !, thank you, that is very good command. If you post that as answer, will be happy to accept it.
$endgroup$
– Nasser
Sep 29 at 2:58




$begingroup$
@CarlWoll Yes !, thank you, that is very good command. If you post that as answer, will be happy to accept it.
$endgroup$
– Nasser
Sep 29 at 2:58










1 Answer
1






active

oldest

votes


















4

















$begingroup$

You can use PreviousCell for this purpose. For example:



Export["code.pdf", NotebookRead[PreviousCell[]]]


should grab the cell contents of the previous cell, and save it to your file.






share|improve this answer










$endgroup$















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "387"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f207036%2fhow-to-export-the-cell-above-to-pdf-using-the-export-command-not-using-gui%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown


























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4

















    $begingroup$

    You can use PreviousCell for this purpose. For example:



    Export["code.pdf", NotebookRead[PreviousCell[]]]


    should grab the cell contents of the previous cell, and save it to your file.






    share|improve this answer










    $endgroup$


















      4

















      $begingroup$

      You can use PreviousCell for this purpose. For example:



      Export["code.pdf", NotebookRead[PreviousCell[]]]


      should grab the cell contents of the previous cell, and save it to your file.






      share|improve this answer










      $endgroup$
















        4















        4











        4







        $begingroup$

        You can use PreviousCell for this purpose. For example:



        Export["code.pdf", NotebookRead[PreviousCell[]]]


        should grab the cell contents of the previous cell, and save it to your file.






        share|improve this answer










        $endgroup$



        You can use PreviousCell for this purpose. For example:



        Export["code.pdf", NotebookRead[PreviousCell[]]]


        should grab the cell contents of the previous cell, and save it to your file.







        share|improve this answer













        share|improve this answer




        share|improve this answer










        answered Sep 29 at 3:00









        Carl WollCarl Woll

        99.1k4 gold badges137 silver badges250 bronze badges




        99.1k4 gold badges137 silver badges250 bronze badges































            draft saved

            draft discarded















































            Thanks for contributing an answer to Mathematica Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f207036%2fhow-to-export-the-cell-above-to-pdf-using-the-export-command-not-using-gui%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown









            Popular posts from this blog

            Tamil (spriik) Luke uk diar | Nawigatjuun

            Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

            Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?